Skip to content

Commit 02bb296

Browse files
committed
Add bundle-collapser when --no-flat is used, closing #9
1 parent 1a086c0 commit 02bb296

File tree

3 files changed

+154
-7
lines changed

3 files changed

+154
-7
lines changed

index.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
var packFlat = require('browser-pack-flat/plugin')
2+
var collapser = require('bundle-collapser/plugin')
23
var packFlatStream = require('browser-pack-flat')
34
var commonShake = require('common-shakeify')
45
var unassertify = require('unassertify')
@@ -50,9 +51,14 @@ module.exports = function (b, opts) {
5051
}
5152
})
5253

53-
// Output a flat bundle, without function wrappers for each module.
54-
if (opts.flat) {
55-
b.plugin(packFlat)
54+
if (!b._options.fullPaths) {
55+
if (opts.flat) {
56+
// Output a flat bundle, without function wrappers for each module.
57+
b.plugin(packFlat)
58+
} else {
59+
// Replace file paths in require() calls with module IDs.
60+
b.plugin(collapser)
61+
}
5662
}
5763

5864
// Remove unused exports from modules.

package-lock.json

Lines changed: 144 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
},
99
"dependencies": {
1010
"browser-pack-flat": "^3.0.0",
11+
"bundle-collapser": "^1.3.0",
1112
"common-shakeify": "^0.4.3",
1213
"envify": "^4.1.0",
1314
"minify-stream": "^1.1.0",

0 commit comments

Comments
 (0)