SaxonJS unusable with webpack

左心房为你撑大大i 提交于 2021-02-11 13:36:28

问题


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);
    };
}

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


回答1:


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).

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!

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.)



来源:https://stackoverflow.com/questions/60792808/saxonjs-unusable-with-webpack

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!