Skip to content

Commit

Permalink
(optim): don't parse ammo, keep three external
Browse files Browse the repository at this point in the history
- speeds up builds
- tests still pass, so I think it's okay to do, but this may be
  different from how developers use it so not necessarily ideal
  test-prod parity
  - though it may make sense to advocate for noParse as
    performance optimizations

- getting three to be properly require'd as an external with webpack
  meant I had to use libraryTarget for some reason...
  - otherwise it would expect it as a global
  • Loading branch information
agilgur5 committed Nov 25, 2019
1 parent 1cc5f7c commit ea682a5
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 5 additions & 1 deletion browserify.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,9 @@ const fs = require('fs')

browserify({
entries: './test-utils/browserify/_export-to-window.js',
}).bundle()
// don't parse ammo
noParse: ['vendor/ammo.js'],
// don't bundle three
}).external('three')
.bundle()
.pipe(fs.createWriteStream('./build/browserify.bundle.js'))
12 changes: 10 additions & 2 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,16 @@ module.exports = {
entry: './test-utils/webpack/_export-to-window.js',
output: {
path: path.join(__dirname, '/build/'),
filename: 'webpack.bundle.js'
filename: 'webpack.bundle.js',
library: 'Physijs',
libraryTarget: 'umd'
},
// fast builds, build is only used for testing purposes
mode: 'development'
mode: 'development',
// don't bundle three
externals: /^three$/,
// don't parse ammo
module: {
noParse: path.join(__dirname, '/vendor/ammo.js')
}
}

0 comments on commit ea682a5

Please sign in to comment.