-
-
Notifications
You must be signed in to change notification settings - Fork 3.7k
Add ES6 default export for TypeScript/ES module support #8434
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -104,3 +104,4 @@ import './webgl/text'; | |
| import './core/init'; | ||
|
|
||
| module.exports = p5; | ||
| export default p5; | ||
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Having both
module.exports = p5;andexport default p5;in the same file can cause conflicts during the build process. When Babel transpiles ES6 to CommonJS,export defaultbecomesexports.default = p5, which creates a different export structure thanmodule.exports = p5.The order and interaction between these two statements depends on the Babel configuration and build system. Consider one of these approaches:
module.exports = p5and rely solely onexport default p5, letting Babel handle the CommonJS transformationmodule.exports = p5and ensure the build system's UMD wrapper properly exposes it for ES6 importsThe PR should include tests or build verification demonstrating that both CommonJS (
require('p5')) and ES6 (import p5 from 'p5') imports work correctly with the compiled output.