-
-
Notifications
You must be signed in to change notification settings - Fork 592
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(commonjs): treat moduleSideEffects as __PURE__ comments for proxi…
…ed wrapped modules
- Loading branch information
1 parent
ccdf1c5
commit 3d78403
Showing
8 changed files
with
63 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 24 additions & 0 deletions
24
packages/commonjs/test/fixtures/function/module-side-effects-import-wrapped/_config.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
module.exports = { | ||
description: 'respects module-side-effects when importing wrapped dependencies', | ||
options: { | ||
plugins: [ | ||
{ | ||
name: 'test', | ||
async resolveId(source, importer, options) { | ||
if (source.endsWith('./foo.js')) { | ||
const resolved = await this.resolve(source, importer, options); | ||
return { ...resolved, moduleSideEffects: false }; | ||
} | ||
return null; | ||
} | ||
} | ||
] | ||
}, | ||
pluginOptions: { | ||
strictRequires: true | ||
}, | ||
global: (global, t) => { | ||
t.is(global.foo, undefined); | ||
t.is(global.bar, 'bar'); | ||
} | ||
}; |
1 change: 1 addition & 0 deletions
1
packages/commonjs/test/fixtures/function/module-side-effects-import-wrapped/bar.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
global.bar = 'bar'; |
1 change: 1 addition & 0 deletions
1
packages/commonjs/test/fixtures/function/module-side-effects-import-wrapped/foo.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
global.foo = 'foo'; |
2 changes: 2 additions & 0 deletions
2
packages/commonjs/test/fixtures/function/module-side-effects-import-wrapped/main.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
import { foo } from './foo.js'; | ||
import { bar } from './bar.js'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.