我曾尝试使用最新版本的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有关
发布于 2020-11-18 05:22:33
这是一个已知问题,请参阅https://saxonica.plan.io/issues/4669
我不完全理解这个问题,但是用于Saxon-JS的npm包只在node.js上受支持,您最好使用浏览器版本。
https://stackoverflow.com/questions/64880919
复制相似问题