Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Do no fail if the source attribute is
undefined
in an unused named …
…export (#3211)
- Loading branch information
1 parent
5cbfdee
commit 33b15cd
Showing
4 changed files
with
20 additions
and
1 deletion.
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
15 changes: 15 additions & 0 deletions
15
test/function/samples/handle-missing-export-source/_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,15 @@ | ||
module.exports = { | ||
description: | ||
'does not fail if a pre-generated AST is omitting the source property of an unused named export (#3210)', | ||
options: { | ||
plugins: { | ||
transform(code, id) { | ||
if (id.endsWith('foo.js')) { | ||
const ast = this.parse(code); | ||
delete ast.body.find(node => node.type === 'ExportNamedDeclaration').source; | ||
return { code, ast }; | ||
} | ||
} | ||
} | ||
} | ||
}; |
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 const unused = 42; |
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 @@ | ||
import './foo.js'; | ||
|
||
export const foo = 42; |