Skip to content

Commit 757c12e

Browse files
authored
Merge pull request #345 from Spikef/master
add support for node bundle
2 parents 06e6b39 + 77403b1 commit 757c12e

File tree

4 files changed

+32
-0
lines changed

4 files changed

+32
-0
lines changed

CHANGELOG.md

+3
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@ _Note: Gaps between patch versions are faulty, broken or test releases._
1212

1313
## UNRELEASED
1414

15+
* **Improvement**
16+
* Added support for exports.modules when webpack target = node
17+
1518
<!-- Add changelog entries for new changes under this section -->
1619

1720
## 3.7.0

src/parseUtils.js

+16
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,22 @@ function parseBundle(bundlePath) {
2525
ast,
2626
walkState,
2727
{
28+
AssignmentExpression(node, state) {
29+
if (state.locations) return;
30+
31+
// Modules are stored in exports.modules:
32+
// exports.modules = {};
33+
const {left, right} = node;
34+
35+
if (
36+
left &&
37+
left.object && left.object.name === 'exports' &&
38+
left.property && left.property.name === 'modules' &&
39+
isModulesHash(right)
40+
) {
41+
state.locations = getModulesLocations(right);
42+
}
43+
},
2844
CallExpression(node, state, c) {
2945
if (state.locations) return;
3046

test/bundles/validNodeBundle.js

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
exports.ids = ["common"];
2+
exports.modules = {
3+
0: function(e,t,n){n(1),n(21),n(96),n(306),n(23),n(150),n(57),n(56),n(34),n(138),e.exports=n(348)},
4+
3: function(e,t,n){"use strict";e.exports=n(680)},
5+
5: function(e,t){}
6+
};
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
{
2+
"modules": {
3+
"0": "function(e,t,n){n(1),n(21),n(96),n(306),n(23),n(150),n(57),n(56),n(34),n(138),e.exports=n(348)}",
4+
"3": "function(e,t,n){\"use strict\";e.exports=n(680)}",
5+
"5": "function(e,t){}"
6+
}
7+
}

0 commit comments

Comments
 (0)