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

Allow to disable __esModule #2287

Merged
merged 1 commit into from
Jun 20, 2018
Merged

Conversation

TrySound
Copy link
Member

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

module.exports = React.default ? React.default : React;

Disabling __esModule will allow react to prepare their packages to esm.

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.
@guybedford
Copy link
Contributor

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 module.exports = React scenario, without an __esModule export? How does that not match the expected workflow in this case?

@TrySound
Copy link
Member Author

TrySound commented Jun 20, 2018

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.
https://github.com/facebook/react/blob/master/packages/react/src/React.js

@guybedford
Copy link
Contributor

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;

@guybedford
Copy link
Contributor

Or is the issue that you want to be able to run the "cjs" and "esm" build on the same rollup input options?

@TrySound
Copy link
Member Author

It's not achievable with reexport to default because of object.freeze which I can't disable because of react dependencies.

@guybedford
Copy link
Contributor

@TrySound I see, then it definitely makes sense to have a little more control. I can get behind this.

@lukastaegert
Copy link
Member

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!

@TrySound
Copy link
Member Author

Yes, we need to be very carefully here to not break existing stuff. The plan is continue supporting both import * as React from 'react' and import React from 'react' in react17 and upgrading community stuff (code, docs, tutorials). After that there will be a chance to get rid from default export.

@lukastaegert lukastaegert merged commit d4aed73 into master Jun 20, 2018
@TrySound TrySound deleted the allow-es-modules-disabling branch June 20, 2018 15:27
@lukastaegert lukastaegert added this to the 0.61.0 milestone Jun 20, 2018
@lukastaegert
Copy link
Member

Will put this into an 0.61.0 release today, together with some other stuff.

@lukastaegert
Copy link
Member

You might have left a solo:true in the tests. Will need to fix some things before I can release.

@TrySound
Copy link
Member Author

Oops, sorry

@TrySound
Copy link
Member Author

I will make a PR

@lukastaegert
Copy link
Member

Nah, I already fixed everything

calebeby pushed a commit to Pigmice2733/scouting-frontend that referenced this pull request Jun 21, 2018
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#&#8203;0611)
[Compare Source](rollup/rollup@v0.61.0...697f36d)
*2018-06-21*
* Do not try to deconflict "undefined" ([#&#8203;2291](`rollup/rollup#2291))
* Properly track values for loop interator declarations and reassigned namespaces, add smoke test ([#&#8203;2292](`rollup/rollup#2292))

---

### [`v0.61.0`](https://github.com/rollup/rollup/blob/master/CHANGELOG.md#&#8203;0610)
[Compare Source](rollup/rollup@v0.60.7...v0.61.0)
*2018-06-20*
* Declare file dependencies via transform plugin hooks ([#&#8203;2259](`rollup/rollup#2259))
* Handle undefined values when evaluating conditionals ([#&#8203;2264](`rollup/rollup#2264))
* Handle known undefined properties when evaluating conditionals ([#&#8203;2265](`rollup/rollup#2265))
* Access watch events via the plugin context ([#&#8203;2261](`rollup/rollup#2261))
* Add option to suppress `__esModule` flag in output ([#&#8203;2287](`rollup/rollup#2287))
* Fix issue when re-declaring variables, track reassignments in more cases ([#&#8203;2279](`rollup/rollup#2279))
* Add VSCode debug settings ([#&#8203;2276](`rollup/rollup#2276))

---

</details>




---

This PR has been generated by [Renovate Bot](https://renovatebot.com).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants