I've tried to use the latest version of saxon-js with webpack as a module bundler – but trying to build the bundle produces an error. Saxon-js was installed using npm
.
I've used the following code to import saxon-js:
import * as SaxonJS from 'saxon-js';
as well as
import SaxonJS from 'saxon-js';
While trying to import saxon-js this way webpack produces the following error:
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
My question may be related to SaxonJS unusable with webpack
This is a known issue, see https://saxonica.plan.io/issues/4669
I don't fully understand the issue, but the npm package for Saxon-JS is supported only on node.js and you're probably better off using the browser version.