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
feature: Build ESM alongside CommonJS #413
feature: Build ESM alongside CommonJS #413
Conversation
rollup.config.js
Outdated
const config = modes.flatMap(mode => | ||
moduleFormats.map(moduleFormat => { | ||
let outputConfig; | ||
switch (moduleFormat) { |
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.
You can use an array as output
, so this switch-case is not necessary.
rollup.config.js
Outdated
case 'esm': | ||
outputConfig = { | ||
file: 'esm/recoil.${mode}.js', | ||
format: moduleFormat, |
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.
I think the option is called "es", not "esm" in rollup configs.
rollup.config.js
Outdated
switch (moduleFormat) { | ||
case 'esm': | ||
outputConfig = { | ||
file: 'esm/recoil.${mode}.js', |
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.
How do people use this esm output? import Recoil from 'recoil/esm'
?
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.
Since I added "module" property to package.json, many bundle tools (e.g webpack) using module file inside esm directory automatically, so no update import statement is needed.
@mondaychen |
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.
@mondaychen has imported this pull request. If you are a Facebook employee, you can view this diff on Phabricator.
The output in esm is expected. I think this PR should be fine:
|
@pocket7878 has updated the pull request. Re-import the pull request |
I'm just rebased to latest master. |
@mondaychen merged this pull request in 99b0400. |
Hmmmm I probably should notice it earlier, but esm/index.js is going to be this file
...which is a commonJS file, right? I think we'll need an ESM equivalent for this file. |
I think we'll want to follow how redux does it and provide different builds for CommonJS, ES, ES for browser and UMD dev/prod. https://github.com/reduxjs/redux/blob/master/rollup.config.js |
Sorry for my mistake and thank you for your review. https://gist.github.com/pocket7878/c7d3bef822e458b2aa71dcb151a56053 |
@pocket7878 can you start a new PR? |
Summary: Building EMS module alongside CommonJS to use with webpack + babel. Pull Request resolved: facebookexperimental/Recoil#413 Reviewed By: drarmstr Differential Revision: D22348922 Pulled By: mondaychen fbshipit-source-id: b54a31c76d90b75d49d294ae1583d49a580d329d
… UMD correctly. (#433) Summary: FIX issue from previous PR: facebookexperimental/Recoil#413 Pull Request resolved: facebookexperimental/Recoil#433 Reviewed By: drarmstr Differential Revision: D22419761 Pulled By: mondaychen fbshipit-source-id: c9f86304dfc33abd755db249ea9b3d2c30d16ff8
Summary: Building EMS module alongside CommonJS to use with webpack + babel. Pull Request resolved: facebookexperimental/Recoil#413 Reviewed By: drarmstr Differential Revision: D22348922 Pulled By: mondaychen fbshipit-source-id: b54a31c76d90b75d49d294ae1583d49a580d329d
… UMD correctly. (#433) Summary: FIX issue from previous PR: facebookexperimental/Recoil#413 Pull Request resolved: facebookexperimental/Recoil#433 Reviewed By: drarmstr Differential Revision: D22419761 Pulled By: mondaychen fbshipit-source-id: c9f86304dfc33abd755db249ea9b3d2c30d16ff8
Building EMS module alongside CommonJS to use with webpack + babel.