forked from rollup/plugins
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: correctly wraps the default export from a CommonJS module when i…
…t is a class Fixes https://github.com/vitejs/vite/issues/10853 Since rollup@3c00191 the namespace became callable when requiring ESM with function default, but it isn't newable, leading to errors when the function is actually a class.
- Loading branch information
1 parent
570f77c
commit 32cd0c8
Showing
4 changed files
with
26 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
3 changes: 3 additions & 0 deletions
3
packages/commonjs/test/fixtures/samples/es-module-with-class-as-default-export/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,3 @@ | ||
const Foo = require('./other.js'); | ||
|
||
new Foo(1, 2) |
7 changes: 7 additions & 0 deletions
7
packages/commonjs/test/fixtures/samples/es-module-with-class-as-default-export/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,7 @@ | ||
export default class Foo { | ||
constructor(...args) { | ||
if (args.length !== 2) { | ||
throw new Error(`new Foo(...) requires exactly 2 arguments, received ${args.length}`); | ||
} | ||
} | ||
} |
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