Skip to content

Commit

Permalink
postinstall: set node_modules/handlebars/package.json .browser.fs=false
Browse files Browse the repository at this point in the history
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
  • Loading branch information
maxlath committed Oct 5, 2020
1 parent a8d21b0 commit 4be4058
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions scripts/postinstall
Original file line number Diff line number Diff line change
@@ -1,6 +1,16 @@
#!/usr/bin/env bash

echo "need to update postinstall"

# set browser.fs=false to work around parcel-bundler "Cannot statically evaluate fs argument" issue
# see https://github.com/parcel-bundler/parcel/pull/523#issue-161973498
disable_browser_fs(){
cat $1 | jq '.browser.fs = false' > $1.fixed
mv $1.fixed $1
}

disable_browser_fs node_modules/handlebars/package.json

# set -eu

# If public/js/app.js already exist, assume that it's a re-install
Expand Down

0 comments on commit 4be4058

Please sign in to comment.