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

Use .mjs for module code #1244

Merged
merged 1 commit into from
Feb 15, 2018
Merged

Use .mjs for module code #1244

merged 1 commit into from
Feb 15, 2018

Conversation

leebyron
Copy link
Contributor

@leebyron leebyron commented Feb 14, 2018

  • Writes .mjs instead of .js for es-module code
  • Moves .mjs files out of ./module to top level since they no longer conflict with .js files

Fixes #1217

@leebyron
Copy link
Contributor Author

Looks like we'll also need iterall to support mjs

@jaydenseric
Copy link

Is there a reason why the .mjs files are nested under a module directory, instead of being .js file siblings? Other than looking tidier, imports like this could then work the same whether or not --experimental-modules is enabled:

import { GraphQLError } from 'graphql/error'

@leebyron
Copy link
Contributor Author

I've been trying to discourage keying deeply into the package contents, which should be implementation details, but you're right that it's no longer necessary if the files would have different extensions

@leebyron
Copy link
Contributor Author

Just released https://github.com/leebyron/iterall/releases/tag/v1.2.0 which helps unblock this

* Writes .mjs instead of .js for esmodules code.
* Moves .mjs out of ./module into the top level since it no longer conflicts with .js

Fixes #1217
@leebyron leebyron merged commit 65afbaf into master Feb 15, 2018
@leebyron leebyron deleted the module-mjs branch February 15, 2018 22:15
jaydenseric added a commit to jaydenseric/express-graphql that referenced this pull request May 2, 2018
Relates to graphql#425.

- Swapped deprecated babel-preset-es2015 for babel-preset-env.
- Added package.json engines field.
- Configured babel-preset-env to target the Node.js version defined in package.json engines field.
- Kept Babel at v6, but moved config into a v7 ready .babelrc.js file for dynamic config via env.
- Tidied the package.json scripts, added an ESM build step that generates .mjs dist files. Follow the lead of graphql/graphql-js#1244, although I do things quite different for my own projects with Babel v7.
- Updated package.json main field for ESM/CJS cross compatibility.
- Added a package.json module field for tree-shaking bundlers.
@felixfbecker
Copy link

This broke bundling with webpack: #1536

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.

4 participants