Skip to content

Commit

Permalink
Merge pull request #345 from Spikef/master
Browse files Browse the repository at this point in the history
add support for node bundle
  • Loading branch information
th0r committed May 6, 2020
2 parents 06e6b39 + 77403b1 commit 757c12e
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Expand Up @@ -12,6 +12,9 @@ _Note: Gaps between patch versions are faulty, broken or test releases._

## UNRELEASED

* **Improvement**
* Added support for exports.modules when webpack target = node

<!-- Add changelog entries for new changes under this section -->

## 3.7.0
Expand Down
16 changes: 16 additions & 0 deletions src/parseUtils.js
Expand Up @@ -25,6 +25,22 @@ function parseBundle(bundlePath) {
ast,
walkState,
{
AssignmentExpression(node, state) {
if (state.locations) return;

// Modules are stored in exports.modules:
// exports.modules = {};
const {left, right} = node;

if (
left &&
left.object && left.object.name === 'exports' &&
left.property && left.property.name === 'modules' &&
isModulesHash(right)
) {
state.locations = getModulesLocations(right);
}
},
CallExpression(node, state, c) {
if (state.locations) return;

Expand Down
6 changes: 6 additions & 0 deletions test/bundles/validNodeBundle.js
@@ -0,0 +1,6 @@
exports.ids = ["common"];
exports.modules = {
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)},
3: function(e,t,n){"use strict";e.exports=n(680)},
5: function(e,t){}
};
7 changes: 7 additions & 0 deletions test/bundles/validNodeBundle.modules.json
@@ -0,0 +1,7 @@
{
"modules": {
"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)}",
"3": "function(e,t,n){\"use strict\";e.exports=n(680)}",
"5": "function(e,t){}"
}
}

0 comments on commit 757c12e

Please sign in to comment.