-
-
Notifications
You must be signed in to change notification settings - Fork 571
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(commonjs): support remaining export modes
- Loading branch information
1 parent
5787666
commit 1417a4e
Showing
35 changed files
with
534 additions
and
197 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
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
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
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
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
6 changes: 6 additions & 0 deletions
6
packages/commonjs/test/fixtures/function/strict-require-semantic-circular/_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,6 @@ | ||
module.exports = { | ||
description: 'handles circular dependencies with strict require semantic', | ||
pluginOptions: { | ||
strictRequireSemantic: true | ||
} | ||
}; |
2 changes: 2 additions & 0 deletions
2
packages/commonjs/test/fixtures/function/strict-require-semantic-circular/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 @@ | ||
exports.foo = 'foo'; | ||
t.is(require('./other.js').foo, 'foo'); |
1 change: 1 addition & 0 deletions
1
packages/commonjs/test/fixtures/function/strict-require-semantic-circular/other.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 @@ | ||
exports.foo = require('./main.js').foo; |
20 changes: 20 additions & 0 deletions
20
packages/commonjs/test/fixtures/function/strict-require-semantic-entry/_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,20 @@ | ||
const assert = require('assert'); | ||
|
||
module.exports = { | ||
description: 'strict require semantic modules can be entry points', | ||
options: { | ||
input: [ | ||
'fixtures/function/strict-require-semantic-entry/main.js', | ||
'fixtures/function/strict-require-semantic-entry/other.js' | ||
], | ||
output: { | ||
chunkFileNames: 'generated-[name].js' | ||
} | ||
}, | ||
pluginOptions: { | ||
strictRequireSemantic: ['fixtures/function/strict-require-semantic-entry/main.js'] | ||
}, | ||
exports(exports) { | ||
assert.deepStrictEqual(exports, { foo: 'foo' }); | ||
} | ||
}; |
1 change: 1 addition & 0 deletions
1
packages/commonjs/test/fixtures/function/strict-require-semantic-entry/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 @@ | ||
exports.foo = 'foo'; |
1 change: 1 addition & 0 deletions
1
packages/commonjs/test/fixtures/function/strict-require-semantic-entry/other.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 @@ | ||
t.is(require('./main.js').foo, 'foo'); |
2 changes: 1 addition & 1 deletion
2
...ges/commonjs/test/fixtures/function/strict-require-semantic-exportmode-exports/_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
1 change: 1 addition & 0 deletions
1
...mmonjs/test/fixtures/function/strict-require-semantic-exportmode-exports/assignExports.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 |
---|---|---|
@@ -1,2 +1,3 @@ | ||
exports.foo = 'foo'; | ||
module.exports.bar = 'bar'; | ||
global.hasAssignExportsRun = true; |
16 changes: 8 additions & 8 deletions
16
packages/commonjs/test/fixtures/function/strict-require-semantic-exportmode-exports/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 |
---|---|---|
@@ -1,17 +1,17 @@ | ||
t.is(global.hasAssignExportsRun, undefined, 'before require'); | ||
t.is(require('./assignExports.js').foo, 'foo'); | ||
t.deepEqual(require('./assignExports.js'), { foo: 'foo', bar: 'bar' }); | ||
|
||
t.is(global.hasAssignExportsRun, true, 'after require'); | ||
delete global.hasAssignExportsRun; | ||
|
||
t.is(global.hasReassignModuleExportsRun, undefined, 'before require'); | ||
t.is(require('./reassignModuleExports.js').foo, 'foo'); | ||
|
||
t.is(global.hasReassignModuleExportsRun, true, 'after require'); | ||
delete global.hasReassignModuleExportsRun; | ||
|
||
t.is(global.hasCompiledEsmRun, undefined, 'before require'); | ||
t.is(require('./compiledEsm.js').foo, 'foo'); | ||
t.deepEqual(require('./compiledEsm.js'), { foo: 'foo', __esModule: true }); | ||
|
||
t.is(global.hasCompiledEsmRun, true, 'after require'); | ||
delete global.hasCompiledEsmRun; | ||
|
||
t.is(global.hasWrappedExportsRun, undefined, 'before require'); | ||
t.deepEqual(require('./wrappedExports.js'), { foo: 'foo' }); | ||
|
||
t.is(global.hasWrappedExportsRun, true, 'after require'); | ||
delete global.hasWrappedExportsRun; |
3 changes: 0 additions & 3 deletions
3
...est/fixtures/function/strict-require-semantic-exportmode-exports/reassignModuleExports.js
This file was deleted.
Oops, something went wrong.
4 changes: 4 additions & 0 deletions
4
...monjs/test/fixtures/function/strict-require-semantic-exportmode-exports/wrappedExports.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,4 @@ | ||
exports.foo = 'foo'; | ||
exports = {}; | ||
exports.bar = 'bar'; | ||
global.hasWrappedExportsRun = true; |
6 changes: 6 additions & 0 deletions
6
...ages/commonjs/test/fixtures/function/strict-require-semantic-exportmode-module/_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,6 @@ | ||
module.exports = { | ||
description: 'supports using function wrappers for modules for export mode "module"', | ||
pluginOptions: { | ||
strictRequireSemantic: ['fixtures/function/strict-require-semantic-exportmode-module/*E*.js'] | ||
} | ||
}; |
3 changes: 3 additions & 0 deletions
3
...est/fixtures/function/strict-require-semantic-exportmode-module/assignModuleAndExports.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,3 @@ | ||
module.exports = { foo: 'foo' }; | ||
module.exports.bar = 'bar'; | ||
global.hasAssignModuleAndExportsRun = true; |
6 changes: 6 additions & 0 deletions
6
...s/test/fixtures/function/strict-require-semantic-exportmode-module/assignModuleExports.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,6 @@ | ||
if (Math.random() > 0.5) { | ||
module.exports = { foo: 'foo' }; | ||
} else { | ||
module.exports = { foo: 'foo' }; | ||
} | ||
global.hasAssignModuleExportsRun = true; |
Oops, something went wrong.