Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for node bundle #345

Merged
merged 2 commits into from May 6, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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){}"
}
}