Skip to content

Commit

Permalink
add commands for fusebox
Browse files Browse the repository at this point in the history
  • Loading branch information
evanw committed Feb 17, 2020
1 parent 92d8505 commit 236194e
Show file tree
Hide file tree
Showing 4 changed files with 1,199 additions and 3 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
/github/
/node_modules/
/pkg/
/.fusebox/
35 changes: 35 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,21 @@ PARCEL_FLAGS += --no-autoinstall
PARCEL_FLAGS += --out-dir .
PARCEL_FLAGS += --public-url ./

FUSEBOX_RUN += const { FuseBox, QuantumPlugin } = require('fuse-box');
FUSEBOX_RUN += const [,, entryPoint, bundleName] = process.argv;
FUSEBOX_RUN += const fuse = FuseBox.init({
FUSEBOX_RUN += homeDir: '..',
FUSEBOX_RUN += target: 'browser@esnext',
FUSEBOX_RUN += output: './$$name.js',
FUSEBOX_RUN += package: { name: 'THREE', main: entryPoint },
FUSEBOX_RUN += globals: { THREE: 'THREE' },
FUSEBOX_RUN += sourceMaps: true,
FUSEBOX_RUN += useTypescriptCompiler: true,
FUSEBOX_RUN += plugins: [QuantumPlugin({ bakeApiIntoBundle: true, containedAPI: true, uglify: { es6: true } })],
FUSEBOX_RUN += });
FUSEBOX_RUN += fuse.bundle(bundleName).instructions('>' + entryPoint);
FUSEBOX_RUN += fuse.run();

node_modules/.bin/rollup:
npm ci

Expand All @@ -85,6 +100,9 @@ node_modules/.bin/webpack:
node_modules/.bin/parcel:
npm ci

node_modules/.bin/fuse:
npm ci

################################################################################

github/three:
Expand All @@ -100,6 +118,7 @@ bench/three: | github/three
echo > bench/three/entry.js
for i in 1 2 3 4 5 6 7 8 9 10; do test -d "bench/three/copy$$i" || cp -r github/three/src "bench/three/copy$$i"; done
for i in 1 2 3 4 5 6 7 8 9 10; do echo "import * as copy$$i from './copy$$i/Three.js'; export {copy$$i}" >> bench/three/entry.js; done
find bench/three -name '*.js' | xargs wc -l

################################################################################

Expand Down Expand Up @@ -130,6 +149,14 @@ demo-three-parcel: node_modules/.bin/parcel | demo/three
cd demo/three/parcel && time -p ../../../node_modules/.bin/parcel build ../src/Three.js $(PARCEL_FLAGS) --out-file Three.parcel.js
du -h demo/three/parcel/Three.parcel.js*

demo-three-fusebox: node_modules/.bin/fuse | demo/three
rm -fr demo/three/fusebox .fusebox
mkdir -p demo/three/fusebox
echo "$(FUSEBOX_RUN)" > demo/three/fusebox/run.js
cd demo/three/fusebox && time -p node run.js src/Three.js Three.fusebox.js
rm -f demo/three/tsconfig.json
du -h demo/three/fusebox/Three.fusebox.js*

################################################################################

bench-three: bench-three-esbuild bench-three-rollup bench-three-webpack bench-three-parcel
Expand Down Expand Up @@ -160,3 +187,11 @@ bench-three-parcel: node_modules/.bin/parcel | bench/three
mkdir -p bench/three/parcel
cd bench/three/parcel && time -p ../../../node_modules/.bin/parcel build ../entry.js $(PARCEL_FLAGS) --out-file entry.parcel.js
du -h bench/three/parcel/entry.parcel.js*

bench-three-fusebox: node_modules/.bin/fuse | bench/three
rm -fr bench/three/fusebox .fusebox
mkdir -p bench/three/fusebox
echo "$(FUSEBOX_RUN)" > bench/three/fusebox/run.js
cd bench/three/fusebox && time -p node --max-old-space-size=8192 run.js entry.js entry.fusebox.js
rm -f bench/three/tsconfig.json
du -h bench/three/fusebox/entry.fusebox.js*
Loading

0 comments on commit 236194e

Please sign in to comment.