0

我尝试将最新版本的 saxon-js 与 webpack 一起用作模块捆绑器——但尝试构建捆绑包会产生错误。Saxon-js 是使用npm.

我使用以下代码导入 saxon-js:

import * as SaxonJS from 'saxon-js';

import SaxonJS from 'saxon-js';

在尝试以这种方式导入 saxon-js 时,webpack 会产生以下错误:

Module not found: Error: Can't resolve 'stream' in '/Users/bastian/Documents/Coding-Projekte/newversioningmachine/node_modules/saxon-js'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "stream": require.resolve("stream-browserify") }'
        - install 'stream-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "stream": false }
 @ ./src/js/index.js 1:0-36

ERROR in ./node_modules/saxon-js/SaxonJS2N.js 4661:277-292
Module not found: Error: Can't resolve 'path' in '/Users/bastian/Documents/Coding-Projekte/newversioningmachine/node_modules/saxon-js'

BREAKING CHANGE: webpack < 5 used to include polyfills for node.js core modules by default.
This is no longer the case. Verify if you need this module and configure a polyfill for it.

If you want to include a polyfill, you need to:
        - add a fallback 'resolve.fallback: { "path": require.resolve("path-browserify") }'
        - install 'path-browserify'
If you don't want to include a polyfill, you can use an empty module like this:
        resolve.fallback: { "path": false }
 @ ./src/js/index.js 1:0-36

ERROR in ./node_modules/saxon-js/SaxonJS2N.js 4661:335-348
Module not found: Error: Can't resolve 'fs' in '/Users/bastian/Documents/Coding-Projekte/newversioningmachine/node_modules/saxon-js'
 @ ./src/js/index.js 1:0-36

我的问题可能与webpack 无法使用的 SaxonJS 有关

4

1 回答 1

1

这是一个已知问题,请参阅https://saxonica.plan.io/issues/4669

我不完全理解这个问题,但仅 node.js 支持 Saxon-JS 的 npm 包,您最好使用浏览器版本。

于 2020-11-17T21:22:32.567 回答