Skip to content
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

chore/babel-esm #80

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft

chore/babel-esm #80

wants to merge 2 commits into from

Conversation

PaulieScanlon
Copy link
Owner

@PaulieScanlon PaulieScanlon commented Sep 10, 2020

  • change babel config to export ESM

@spences10 If you happen to speak to Chris again i think this is what we'll need but i've gotta be honest i've run out talent with Babel.

Before this PR i was transforming syntax to cjs, and now i've removed @babel/plugin-transform-modules-commonjs and set @babel/preset-env to "modules": false which i think now will export just the ES syntax.

If you give this a pull and run yarn build and have a look at the dist folder the exported code looks much more like the kinda thing we'd write.

Also made a small change to tsconfig as i was exporting the types to a types dir but wasn't point the declarationDir at that dir so we would have proabably had a "types not found" error if we'd tried to use the package in a TypeScirpt project.

@spences10
Copy link
Collaborator

I think that's it mate, Chris said that we'd need to ship an ESM build to do that configure TS to pass through ESM, compile the JSX and remove the Type annotations then output the ESM to module.

Chris also referenced the keys options in microbundle for how to export: https://www.npmjs.com/package/microbundle

And the TS Handbook, but I can't find specifically where he was referencing, sorry: https://www.typescriptlang.org/docs/handbook/modules.html

@spences10
Copy link
Collaborator

Found it!

--esModuleInterop

@PaulieScanlon
Copy link
Owner Author

@spences10 i have that already in the tsconfig i'm assuming it has to be true right?

@PaulieScanlon PaulieScanlon marked this pull request as draft September 15, 2020 19:56
@PaulieScanlon
Copy link
Owner Author

@spences10 lets shelve this for the moment. With export to ES Modules rather than Common Js both the Next demos break. I don't know enough about this to know what needs to be changed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants