【发布时间】:2020-07-02 16:35:29
【问题描述】:
我在尝试使用 webpack 将 SaxonJS 集成到更大的 Web 应用程序时遇到问题。据我所知,webpack 将SaxonJS 视为另一个模块,但SaxonJS 不是AMD 或CommonJS 模块。相反,Big.js(SaxonJS 依赖项)劫持了导出。我相信修复 Node.js 支持也会解决这个问题。
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 正在被浏览器调用。
【问题讨论】: