Skip to content

Commit 33b15cd

Browse files
authored
Do no fail if the source attribute is undefined in an unused named export (#3211)
1 parent 5cbfdee commit 33b15cd

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

src/Module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -703,7 +703,7 @@ export default class Module {
703703
const source = node.source.value;
704704
this.sources.add(source);
705705
this.exportAllSources.add(source);
706-
} else if (node.source !== null) {
706+
} else if (node.source instanceof Literal) {
707707
// export { name } from './other'
708708

709709
const source = node.source.value;
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
module.exports = {
2+
description:
3+
'does not fail if a pre-generated AST is omitting the source property of an unused named export (#3210)',
4+
options: {
5+
plugins: {
6+
transform(code, id) {
7+
if (id.endsWith('foo.js')) {
8+
const ast = this.parse(code);
9+
delete ast.body.find(node => node.type === 'ExportNamedDeclaration').source;
10+
return { code, ast };
11+
}
12+
}
13+
}
14+
}
15+
};
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const unused = 42;
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
import './foo.js';
2+
3+
export const foo = 42;

0 commit comments

Comments
 (0)