Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make export information available after loading, detect reexports
- Loading branch information
1 parent
09e15b6
commit c2f0e1c
Showing
9 changed files
with
65 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
const assert = require('assert'); | ||
const path = require('path'); | ||
|
||
module.exports = { | ||
description: 'reports if a module has a default export', | ||
options: { | ||
plugins: [ | ||
{ | ||
async buildStart() { | ||
const ID_MAIN = path.join(__dirname, 'main.js'); | ||
const loadMain = this.load({ id: ID_MAIN }); | ||
assert.strictEqual(this.getModuleInfo(ID_MAIN).hasDefaultExport, null); | ||
assert.strictEqual((await loadMain).hasDefaultExport, false); | ||
|
||
assert.strictEqual( | ||
(await this.load({ id: path.join(__dirname, 'direct.js') })).hasDefaultExport, | ||
true, | ||
'direct' | ||
); | ||
assert.strictEqual( | ||
(await this.load({ id: path.join(__dirname, 'indirect.js') })).hasDefaultExport, | ||
true, | ||
'indirect' | ||
); | ||
assert.strictEqual( | ||
(await this.load({ id: path.join(__dirname, 'reexport1.js') })).hasDefaultExport, | ||
true, | ||
'reexport' | ||
); | ||
assert.strictEqual( | ||
(await this.load({ id: path.join(__dirname, 'reexport2.js') })).hasDefaultExport, | ||
true, | ||
'renamed reexport' | ||
); | ||
}, | ||
load(id) { | ||
assert.strictEqual(this.getModuleInfo(id).hasDefaultExport, null, `load ${id}`); | ||
}, | ||
transform(code, id) { | ||
assert.strictEqual(this.getModuleInfo(id).hasDefaultExport, null, `transform ${id}`); | ||
} | ||
} | ||
] | ||
} | ||
}; |
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 @@ | ||
export default 'direct'; |
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 @@ | ||
const indirect = 'indirect'; | ||
export { indirect as default }; |
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,9 @@ | ||
import direct from './direct.js'; | ||
import indirect from './indirect.js'; | ||
import reexport1 from './reexport1.js'; | ||
import reexport2 from './reexport2.js'; | ||
|
||
assert.strictEqual(direct, 'direct'); | ||
assert.strictEqual(indirect, 'indirect'); | ||
assert.strictEqual(reexport1, 'default'); | ||
assert.strictEqual(reexport2, 'foo'); |
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 @@ | ||
export default 'default'; | ||
export const foo = 'foo'; |
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 @@ | ||
export { default } from './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 @@ | ||
export { foo as default } from './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