SaxonJS 无法与 webpack 一起使用 [英] SaxonJS unusable with webpack

查看:58
本文介绍了SaxonJS 无法与 webpack 一起使用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在尝试使用 webpackSaxonJS 集成到更大的 Web 应用程序中时遇到了问题.据我所知,webpackSaxonJS 视为另一个模块,但 SaxonJS 的结构并不像 AMDCommonJS 模块.相反,Big.js(一个 SaxonJS 依赖项)会劫持导出.我相信修复 Node.js 支持也会解决这个问题.

I'm running into an issue when trying to integrate SaxonJS into a larger web application using webpack. From what I can tell, webpack views SaxonJS as just another module, but SaxonJS is not structured as an AMD or CommonJS module. Instead, the Big.js (a SaxonJS dependency) hijacks the export. I believe that fixing Node.js support will also fix this issue.

import * as SaxonJS from "./Saxon-JS/SaxonJS.js";
export class Transformer {

    public static transform(inputStr: string, sefFile: string, cb: Function) {
        // wrap the JSON in XML, as required by XSLT transform
        let wrappedJson = `<root xmlns="http://www.w3.org/2005/xpath-functions">${inputStr}</root>`;
        SaxonJS.transform({
            sourceText: wrappedJson,
            stylesheetLocation: `xslt/${sefFile}`,
            initialTemplate: "start",
            destination: "application"
        }, cb);
    };
}

请注意这是一个网络场景;浏览器正在调用 SaxonJS.

Please note this is a web scenario; SaxonJS is being invoked by the browser.

推荐答案

看到人们如何尝试使用 Saxon-JS 总是很好的.我们 Saxonica 肯定有兴趣了解更多关于您正在尝试做什么以及如何做的事情.您尝试的集成目前不起作用,这并不奇怪.Saxon-JS 1 并不是真正构建为 JS 模块(例如,请注意 Big.js 的副本包含在 SaxonJS 中,它不是模块依赖项).

it's always good to see how people are trying to use Saxon-JS. We at Saxonica would certainly be interested to hear more about what you are trying to do, and how. It is not too surprising that the integration you are attempting does not currently work. Saxon-JS 1 is not really built as a JS module (e.g. note that a copy of Big.js is contained inside SaxonJS, it is not a module dependency).

我们正在努力开发下一个主要版本 Saxon-JS 2.0,其中将包含一个用于 Node.js 的版本(如您所知,Saxon-JS 1 仅适用于浏览器).这次我们希望正确打包模块,以便像您这样的 JavaScript 开发人员确实可以像您期望的那样集成 SaxonJS 模块.非常欢迎您的见解!

We are working hard on the next major release, Saxon-JS 2.0, which will include a version for Node.js (as you know, Saxon-JS 1 is for the browser only). We want to get the module packaging right this time so that JavaScript developers such as yourself can indeed integrate the SaxonJS module as you'd expect to. Your insights would be very welcome!

到目前为止,我们倾向于专注于使用 XSLT 和提供的 IXSL 扩展构建独立的 Web 应用程序,但我们确实想更好地了解用户可以/希望如何将 Saxon-JS 集成到更大的现有应用程序中.请问您能否直接与您的用例的更多详细信息联系?(例如,有关支持电子邮件地址,请参阅 Saxonica 网站上的联系人"部分.)

We have so far tended to focus on building stand alone web applications using XSLT and the IXSL extensions provided, but we do want to understand better how users can/would like to integrate Saxon-JS into larger existing applications. Please could you get in touch directly with more details of your use case? (e.g. see the Contacts section on the Saxonica website for the support email address.)

这篇关于SaxonJS 无法与 webpack 一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆