Skip to content

Commit

Permalink
fix: replace require.d without checking exports
Browse files Browse the repository at this point in the history
  • Loading branch information
pionxzh committed Aug 5, 2023
1 parent 448595d commit ebee03b
Showing 1 changed file with 19 additions and 1 deletion.
20 changes: 19 additions & 1 deletion packages/unpacker/src/extractors/webpack4.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,25 @@ function convertRequireHelpers(j: JSCodeshift, collection: Collection<any>) {
},
arguments: [{
type: 'Identifier' as const,
name: 'exports' as const,
/**
* The first argument is the exports object
* But it's not always called `exports`
* The common case is this `exports` object
* is come from the function parameter
* ```js
* function(module, exports, require) {
* require.d(exports, key, function() { return moduleContent })
* }
* ```
*
* But another case is this `exports` object
* is just an object created in the module
* ```js
* var exports = {}
* require.d(exports, key, function() { return moduleContent })
* ```
*/
// name: 'exports' as const,
}, {
type: 'Literal' as const,
}, {
Expand Down

0 comments on commit ebee03b

Please sign in to comment.