Skip to content

Commit

Permalink
[dev][fix] use NPM pathing when running bundlesize
Browse files Browse the repository at this point in the history
check_bundle.sh assumes it will be invoked by package.json with an NPM
PATH environment. This means you can't run it directly without the
bundlesize executable in your PATH.

The issue is resolved by wrapping the `bundlesize` invocation in npx.
Since [npx will auto-install by default], disable that behavior for
safety since the assumption is that the script will be invoked from the
MobileFrontend repo.

Unfortunately, CI does not have npx so the following hack is used
instead:

  PATH="$(npm bin):$(npm bin -g):$PATH" bundlesize

That is, get the local package.json executable directory, get the global
bin directory too, and prepend it to PATH.

[npx will auto-install by default]: npm/npx#9

Change-Id: I2e13633b1394ad7d7f2ede56416ca932a82a63db
  • Loading branch information
niedzielski authored and jrobson committed Jun 5, 2020
1 parent 44c1f97 commit cd256de
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion dev-scripts/check_bundle.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ Try running `npm run build` again or removing the node_modules folder and runnin
eof
exit 1;
}
bundlesize
PATH="$(npm bin):$(npm bin -g):$PATH" bundlesize
echo 'Your changes look good!'
exit 0;
}
Expand Down

0 comments on commit cd256de

Please sign in to comment.