-
-
Notifications
You must be signed in to change notification settings - Fork 2.3k
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
Use browser-resolve to ignore fs inlining #523
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested the PR in a project importing aws-amplify
which depends on aws-sdk-js
. Seems to fix the issue for me. Thanks @fathyb !
Cool! another option would be to just not error on non-static file paths (e.g. with variables), and just skip inlining. The only thing I'd be concerned about would be that it might reduce debuggability for legit coding errors. thoughts? |
I agree on the debuggability point, it could be frustrating to not understand why it does not inline. What about passing an additional option to fs.readFileSync(Math.random().toString(), {
parcel: false
}) That way it can be ignored on node.js and can hint the visitor if the call wasn't meant to be parsed. It might not be applicable on certain use case tho. |
I don't think we should be changing the API. Also that won't work for existing node_modules that are already broken with Parcel. |
Alright, then I'd recommend to display a warning when it happens. #448 could be useful here to silent warnings on some files. |
Encountered the
@devongovett even if a specific Considering prior art, neither browserify nor webpack attach special meaning to the @fathyb I personally like the concise expression let ignore = (((asset||{}).package||{}).browser||{}).fs === false but the explicit form is probably clearer. |
i have problem that after use browser-resolve and it skip fs module i use parcel to bundler my node.js server code |
to work around parcel-bundler "Cannot statically evaluate fs argument" issue see parcel-bundler/parcel#523 (comment)
to prevent Parcel to crash with: "node_modules/handlebars/lib/index.js:18:39: Cannot statically evaluate fs argument" due to Handlebars use of 'fs.readFileSync', when used without precompile: somehow, Parcel doesn't figure-out that we won't need this piece of code and thus tries to inline the code to prevent to rely on fs.readFileSync, which isn't available in the browser See parcel-bundler/parcel#496 and parcel-bundler/parcel#523
to prevent Parcel to crash with: "node_modules/handlebars/lib/index.js:18:39: Cannot statically evaluate fs argument" due to Handlebars use of 'fs.readFileSync', when used without precompile: somehow, Parcel doesn't figure-out that we won't need this piece of code and thus tries to inline the code to prevent to rely on fs.readFileSync, which isn't available in the browser See parcel-bundler/parcel#496 and parcel-bundler/parcel#523
to prevent Parcel to crash with: "node_modules/handlebars/lib/index.js:18:39: Cannot statically evaluate fs argument" due to Handlebars use of 'fs.readFileSync', when used without precompile: somehow, Parcel doesn't figure-out that we won't need this piece of code and thus tries to inline the code to prevent to rely on fs.readFileSync, which isn't available in the browser See parcel-bundler/parcel#496 and parcel-bundler/parcel#523
to prevent Parcel to crash with: "node_modules/handlebars/lib/index.js:18:39: Cannot statically evaluate fs argument" due to Handlebars use of 'fs.readFileSync', when used without precompile: somehow, Parcel doesn't figure-out that we won't need this piece of code and thus tries to inline the code to prevent to rely on fs.readFileSync, which isn't available in the browser See parcel-bundler/parcel#496 and parcel-bundler/parcel#523
browser-resolve
has an option to skipfs
and other modules. This PR makes thefs
visitor check iffs
is ignored before processing it.This makes
aws-sdk-js
usable amongst other libraries using this feature.Fixes #496 and maybe #474