无法将 Saxon-JS 2 与 Webpack 一起使用
Unable to use Saxon-JS 2 with Webpack
我尝试将最新版本的 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
我的问题可能与SaxonJS unusable with webpack
有关
这是一个已知问题,请参阅 https://saxonica.plan.io/issues/4669
我不完全理解这个问题,但仅 node.js 支持 Saxon-JS 的 npm 包,您最好使用浏览器版本。
我尝试将最新版本的 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
我的问题可能与SaxonJS unusable with webpack
有关这是一个已知问题,请参阅 https://saxonica.plan.io/issues/4669
我不完全理解这个问题,但仅 node.js 支持 Saxon-JS 的 npm 包,您最好使用浏览器版本。