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

Add an option to generate esmodule imports/exports in babel-plugin-relay & relay-compiler #2841

Closed

Conversation

vincentriemer
Copy link
Contributor

In order to be compatible with bundlers like rollup, which without extra configuration does not support commonjs modules, so this PR adds an esmodules option to both babel-plugin-relay and relay-compiler so that it can generate es modules instead of commonjs. The new config option in both packages will default to esmodules: false so this shouldn't (hopefully) be a breaking change.

@alloy
Copy link
Contributor

alloy commented Sep 5, 2019

Rather than adding another configuration option, I wonder if this would be possible to do as a language plugin. For instance, our TypeScript plugin emits ES modules, rather than CommonJS (which is also why the Babel plugin is currently already able to read ES module files).

I would imagine the plugin would basically just re-export the Flow plugin, but amend the generated module. This also alleviates the need for a “hacky” approach to exist in the canonical code-base.

@vincentriemer
Copy link
Contributor Author

That makes sense to me, but I'd still need to keep the esmodule option on the babel plugin (thankfully not as hacky). I'll remove the relay-compiler commit.

@TrySound
Copy link
Contributor

TrySound commented Sep 9, 2019

@alloy @vincentriemer Did you see my PR?
#2781

@alloy
Copy link
Contributor

alloy commented Sep 9, 2019

@TrySound I did not, sorry, was out of the loop for a bit.

@jstejada Any thoughts?

adeira-github-bot pushed a commit to adeira/relay-example that referenced this pull request Sep 9, 2019
Inspired by:

- facebook/relay#2445
- facebook/relay#2781
- facebook/relay#2841

kiwicom-source-id: a0181e85ec323a361502ef8275739cf18ef114ac
adeira-github-bot pushed a commit to kiwicom/relay that referenced this pull request Sep 9, 2019
Inspired by:

- facebook/relay#2445
- facebook/relay#2781
- facebook/relay#2841

kiwicom-source-id: a0181e85ec323a361502ef8275739cf18ef114ac
@vincentriemer
Copy link
Contributor Author

@TrySound Sorry I didn't! Your PR looks cleaner so I'll close this one, thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants