-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Allow to disable __esModule #2287
Conversation
Ref #708 This option will be useful for projects who distribute only cjs and would like to migrate their codebase from default to named exports but don't loose the ability to import in both ways. For example react makes a hacky reexport right now ```js module.exports = React.default ? React.default : React; ``` Disabling __esModule will allow react to prepare their packages to esm.
Just thinking through this here, if I made an entrypoint like: react-entry.js export { default } from './react.js'; Surely that would collapse down to the |
The case is that I want to migrate react from default exports to named exports without breaking changes. So there won't be default export in react esm but it will be achievable in cjs. This will allow to do more work before achieving esm support. |
This sounds like a great effort, I'm just trying to understand why this isn't possible today. What if the entry above was written: react-rollup-entry.js: import * as React from './react.js';
export default React; |
Or is the issue that you want to be able to run the "cjs" and "esm" build on the same rollup input options? |
It's not achievable with reexport to default because of object.freeze which I can't disable because of react dependencies. |
@TrySound I see, then it definitely makes sense to have a little more control. I can get behind this. |
So between the lines I read that React will eventually be distributed as ESM as well? I remember a discussion that seemed to go nowhere at the end of last year. Great to hear you are moving forward here! |
Yes, we need to be very carefully here to not break existing stuff. The plan is continue supporting both |
Will put this into an 0.61.0 release today, together with some other stuff. |
You might have left a |
Oops, sorry |
I will make a PR |
Nah, I already fixed everything |
This Pull Request updates dependency [rollup](https://github.com/rollup/rollup) from `v0.60.7` to `v0.61.1` <details> <summary>Release Notes</summary> ### [`v0.61.1`](https://github.com/rollup/rollup/blob/master/CHANGELOG.md#​0611) [Compare Source](rollup/rollup@v0.61.0...697f36d) *2018-06-21* * Do not try to deconflict "undefined" ([#​2291](`rollup/rollup#2291)) * Properly track values for loop interator declarations and reassigned namespaces, add smoke test ([#​2292](`rollup/rollup#2292)) --- ### [`v0.61.0`](https://github.com/rollup/rollup/blob/master/CHANGELOG.md#​0610) [Compare Source](rollup/rollup@v0.60.7...v0.61.0) *2018-06-20* * Declare file dependencies via transform plugin hooks ([#​2259](`rollup/rollup#2259)) * Handle undefined values when evaluating conditionals ([#​2264](`rollup/rollup#2264)) * Handle known undefined properties when evaluating conditionals ([#​2265](`rollup/rollup#2265)) * Access watch events via the plugin context ([#​2261](`rollup/rollup#2261)) * Add option to suppress `__esModule` flag in output ([#​2287](`rollup/rollup#2287)) * Fix issue when re-declaring variables, track reassignments in more cases ([#​2279](`rollup/rollup#2279)) * Add VSCode debug settings ([#​2276](`rollup/rollup#2276)) --- </details> --- This PR has been generated by [Renovate Bot](https://renovatebot.com).
Ref #708
This option will be useful for projects who distribute only cjs
and would like to migrate their codebase from default to named
exports but don't loose the ability to import in both ways.
For example react makes a hacky reexport right now
Disabling __esModule will allow react to prepare their packages to esm.