Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CJS code parse error #297

Closed
huozhi opened this issue Dec 6, 2023 · 1 comment · Fixed by #299
Closed

CJS code parse error #297

huozhi opened this issue Dec 6, 2023 · 1 comment · Fixed by #299

Comments

@huozhi
Copy link
Owner

huozhi commented Dec 6, 2023

cjs code will trigger parse error

module.exports = 'cjs'
    (preserve-directives plugin) [rollup-preserve-directives]: failed to parse "bunchee/test/fixtures/cjs-relative-imports/cjs-dep.cjs" and extract the directives.
make sure you have added "rollup-preserve-directives" to the last of your plugins list, after swc/babel/esbuild/typescript or any other transform plugins.
    Error [RollupError]: Unterminated string constant
@huozhi huozhi transferred this issue from huozhi/rollup-preserve-directives Dec 6, 2023
@huozhi
Copy link
Owner Author

huozhi commented Dec 6, 2023

Looks like caused by commonjs plugin

    parse: id /Users/huozhi/code/bunchee/test/fixtures/cjs-relative-imports/cjs-dep.cjs code import * as commonjsHelpers from "
    parse: id /Users/huozhi/code/bunchee/test/fixtures/cjs-relative-imports/js-dep.js code import * as commonjsHelpers from "
    parse: id /Users/huozhi/code/bunchee/test/fixtures/cjs-relative-imports/index.js code import * as commonjsHelpers from "
    parse: id commonjsHelpers.js code
    export var commonjsGlobal = typeof globalThis !== 'undefined' ? globalThis : typeof window !== 'undefined' ? window : typeof global !== 'undefined' ? global : typeof self !== 'un
defined' ? self : {};

The injected commonjsHelpers helper is not correct

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant