Skip to content

Commit

Permalink
(fix): resolve incorrect browserify noParse config
Browse files Browse the repository at this point in the history
- upon further testing, ammo was still being parsed by browserify
  until now
  - had to time both webpack and browserify in order to tell it wasn't
    being parsed, as they don't error if the module isn't found
    - but they both compile significantly faster when it's not, so
      that's how I could tell I did it correctly (probably could've
      used verbose mode as well)
    - webpack was not parsing it, but had to double check

- browserify apparently only uses absolute paths, so require.resolve
  is the primary way of using noParse (would be great if this were
  better documented...)
  - while this is not strictly necessary for webpack, and it was
    working prior to this, changed the webpack config to use
    require.resolve as well for consistency
  • Loading branch information
agilgur5 committed Nov 25, 2019
1 parent 41a9963 commit ac3f5ee
Show file tree
Hide file tree
Showing 9 changed files with 7 additions and 9 deletions.
2 changes: 1 addition & 1 deletion browserify-worker-stub.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@
// all code outside of the function will be run in main thread
// quite different from Webpack's worker-loader
module.exports = function init () {
require('./physijs_worker.js')
require('./physijs/physijs_worker.js')
}
2 changes: 1 addition & 1 deletion browserify.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@ function PhysijsWorker () {
};

// inject Three.js and Physijs's Worker
var Physijs = require('./physi.js')(THREE, PhysijsWorker);
var Physijs = require('./physijs/physi.js')(THREE, PhysijsWorker);

module.exports = Physijs;
4 changes: 1 addition & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,7 @@
"description": "PhysiJS port for bundlers with out-of-the-box support for Webpack and Browserify",
"main": "webpack.js",
"files": [
"physi.js",
"physijs_worker.js",
"vendor/*",
"physijs/*",
"webpack.js",
"browserify.js",
"browserify-worker-stub.js"
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion test/build-config/_browserify.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const fs = require('fs')
browserify({
entries: './test/utils/browserify/_export-to-window.js',
// don't parse ammo
noParse: ['vendor/ammo.js'],
noParse: [require.resolve('../../physijs/vendor/ammo.js')],
// don't bundle three
}).external('three')
.bundle()
Expand Down
2 changes: 1 addition & 1 deletion test/build-config/_webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,6 @@ module.exports = {
externals: /^three$/,
// don't parse ammo
module: {
noParse: path.join(process.cwd(), '/vendor/ammo.js')
noParse: require.resolve('../../physijs/vendor/ammo.js')
}
}
4 changes: 2 additions & 2 deletions webpack.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
var THREE = require('three');
var PhysijsWorker = require('worker-loader!./physijs_worker.js');
var PhysijsWorker = require('worker-loader!./physijs/physijs_worker.js');

// inject Three.js and Physijs's Worker
var Physijs = require('./physi.js')(THREE, PhysijsWorker);
var Physijs = require('./physijs/physi.js')(THREE, PhysijsWorker);

module.exports = Physijs;

0 comments on commit ac3f5ee

Please sign in to comment.