Closed
Description
It crashes at this stage, so I assume when building a browser bundle:
> [email protected] build:browser
> browserify src/index.ts -s jstt -p tsify > dist/bundle.js
SyntaxError: 'import' and 'export' may appear only with 'sourceType: module' (2:0) while parsing {project_path}\node_modules\@bcherny\json-schema-ref-parser\lib\index.js while parsing file: {project_path}\node_modules\@bcherny\json-schema-ref-parser\lib\index.js
at DestroyableTransform.end [as _flush] ({project_path}\node_modules\insert-module-globals\index.js:114:21)
at DestroyableTransform.prefinish ({project_path}\node_modules\readable-stream\lib\_stream_transform.js:138:10)
at DestroyableTransform.emit (node:events:514:28)
at prefinish ({project_path}\node_modules\readable-stream\lib\_stream_writable.js:619:14)
at finishMaybe ({project_path}\node_modules\readable-stream\lib\_stream_writable.js:627:5)
at endWritable ({project_path}\node_modules\readable-stream\lib\_stream_writable.js:638:3)
at Writable.end ({project_path}\node_modules\readable-stream\lib\_stream_writable.js:594:22)
at DestroyableTransform.onend ({project_path}t\node_modules\readable-stream\lib\_stream_readable.js:577:10)
at Object.onceWrapper (node:events:628:28)
at DestroyableTransform.emit (node:events:526:35)
Possibly related to building on Windows 10 with Node v20.9.0.
I've looked at the similar browserify
issues but all of them seem to be unrelated:
- ParseError: 'import' and 'export' may appear only with 'sourceType: module' browserify/browserify#1998
Is about transforming from CJS to ESM and the underlying issue was babel config. - ES6 target : 'import' and 'export' may appear only with 'sourceType: module' TypeStrong/tsify#86
Is about"target": "es6"
while the project is using"es5"
- https://stackoverflow.com/questions/33719064/syntaxerror-import-and-export-may-appear-only-with-sourcetype-module-in
Some gulp-related stuff, but does involvetsify
too, has no answer and is at least 8 years old, so probably not applicable to the current version ofbrowserify
.
Seeing @bcherny\json-schema-ref-parser
in the logs, it's probably the problem with the build output of that fork, I'll check it out later.