Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(commonjs): Infer type for unidentified modules (#1038)
- Loading branch information
1 parent
2b3d215
commit 2aa0ac9
Showing
50 changed files
with
220 additions
and
63 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
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
31 changes: 31 additions & 0 deletions
31
packages/commonjs/test/fixtures/function/strict-requires-entry-node-resolve/_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,31 @@ | ||
const assert = require('assert'); | ||
|
||
const { nodeResolve } = require('@rollup/plugin-node-resolve'); | ||
|
||
module.exports = { | ||
description: | ||
'strict require semantic modules can be entry points when the node-resolve plugin is used', | ||
pluginOptions: { | ||
strictRequires: true | ||
}, | ||
options: { | ||
plugins: [ | ||
{ | ||
name: 'before-node', | ||
buildStart({ plugins }) { | ||
assert.deepStrictEqual( | ||
plugins.map((plugin) => plugin.name), | ||
['before-node', 'after-node', 'commonjs', 'node-resolve'] | ||
); | ||
} | ||
}, | ||
nodeResolve(), | ||
{ | ||
name: 'after-node' | ||
} | ||
] | ||
}, | ||
exports(exports) { | ||
assert.deepStrictEqual(exports, { foo: 'foo' }); | ||
} | ||
}; |
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...re-semantic-exportmode-exports/_config.js → ...ct-requires-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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module.exports = { | ||
description: 'supports using function wrappers for modules for export mode "exports"', | ||
pluginOptions: { | ||
strictRequires: ['fixtures/function/strict-require-semantic-exportmode-exports/*E*.js'] | ||
strictRequires: ['fixtures/function/strict-requires-exportmode-exports/*E*.js'] | ||
} | ||
}; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...ire-semantic-exportmode-module/_config.js → ...ict-requires-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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module.exports = { | ||
description: 'supports using function wrappers for modules for export mode "module"', | ||
pluginOptions: { | ||
strictRequires: ['fixtures/function/strict-require-semantic-exportmode-module/*E*.js'] | ||
strictRequires: ['fixtures/function/strict-requires-exportmode-module/*E*.js'] | ||
} | ||
}; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
...re-semantic-exportmode-replace/_config.js → ...ct-requires-exportmode-replace/_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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module.exports = { | ||
description: 'supports using function wrappers for modules for export mode "replace"', | ||
pluginOptions: { | ||
strictRequires: ['fixtures/function/strict-require-semantic-exportmode-replace/*E*.js'] | ||
strictRequires: ['fixtures/function/strict-requires-exportmode-replace/*E*.js'] | ||
} | ||
}; |
File renamed without changes.
File renamed without changes.
7 changes: 7 additions & 0 deletions
7
packages/commonjs/test/fixtures/function/strict-requires-file-without-module-type/_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,7 @@ | ||
module.exports = { | ||
description: | ||
'identifies files without module features as commonjs if they are required by another file', | ||
pluginOptions: { | ||
strictRequires: true | ||
} | ||
}; |
1 change: 1 addition & 0 deletions
1
packages/commonjs/test/fixtures/function/strict-requires-file-without-module-type/error.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 @@ | ||
throw new Error('FAIL'); |
2 changes: 2 additions & 0 deletions
2
packages/commonjs/test/fixtures/function/strict-requires-file-without-module-type/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 @@ | ||
// eslint-disable-next-line global-require | ||
t.is(0 && require('./error.js'), 0); |
2 changes: 1 addition & 1 deletion
2
...rict-require-semantic-from-esm/_config.js → ...ction/strict-requires-from-esm/_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 |
---|---|---|
@@ -1,6 +1,6 @@ | ||
module.exports = { | ||
description: 'handles importing wrapped modules from ESM', | ||
pluginOptions: { | ||
strictRequires: ['fixtures/function/strict-require-semantic-from-esm/strict.js'] | ||
strictRequires: ['fixtures/function/strict-requires-from-esm/strict.js'] | ||
} | ||
}; |
File renamed without changes.
File renamed without changes.
File renamed without changes.
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
packages/commonjs/test/fixtures/function/strict-requires-multiple-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'; |
File renamed without changes.
Oops, something went wrong.