Skip to content

Support ES modules for use in Webpack2/Rollup#939

Closed
baer wants to merge 8 commits intographql:masterfrom
baer:feature/add-es-modules
Closed

Support ES modules for use in Webpack2/Rollup#939
baer wants to merge 8 commits intographql:masterfrom
baer:feature/add-es-modules

Conversation

@baer
Copy link
Copy Markdown
Contributor

@baer baer commented Jul 4, 2017

This PR changes the build in the following ways:

  • A clean step is added to ensure predictable builds
  • Babel config has been divided by env
  • The build now outputs both a dist/es5 and a dist/modules version of the code
  • jsnext:main was added

As of this PR, DCE from Rollup/Webpack 2+ should be supported!

@baer
Copy link
Copy Markdown
Contributor Author

baer commented Jul 12, 2017

This PR is up to date and should work as designed :D

@baer baer changed the title [RFC] Support ES modules for use in Webpack2/Rollup Support ES modules for use in Webpack2/Rollup Jul 12, 2017
Comment thread .babelrc
"last 2 chrome versions",
"last 2 edge versions",
"last 2 firefox versions",
"env": {
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: The babel config merging strategy does not allow the common plugins to be defined at the top level. I'm investigating this babel bug and will file an issue on that project when I have a good repro.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any updates on this?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No, not at present. Is it blocking?

Copy link
Copy Markdown

@danez danez Aug 14, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the env option is broken conceptually in some ways, that's why there is still discussion to deprecate it in favor of the new .babelrc.js config coming in babel 7. That's also why there is currently no effort put into fixing all the broken cases with env.

A workaround for babel 6.x is to create a local preset and reference it in the babel config. That way you have full control about which plugin is activated in which environment by simply using javascript + environment variables.

babel/babel#5276

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wow! Thanks @danez, that's really exciting news!

Comment thread package.json Outdated
"license": "BSD-3-Clause",
"main": "index.js",
"main": "es5/index.js",
"jsnext:main": "modules/index.js",
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@baer, jsnext:main is deprecated. Use module instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done! Thanks, I did not know that.

leebyron added a commit that referenced this pull request Dec 1, 2017
Alternative to #939 which requires less alteration of existing build config and dist file layout

Enables tree shaking for Rollup/Webpack

Closes #939
@leebyron leebyron mentioned this pull request Dec 1, 2017
leebyron added a commit that referenced this pull request Dec 1, 2017
Alternative to #939 which requires less alteration of existing build config and dist file layout

Enables tree shaking for Rollup/Webpack

Closes #939
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.

5 participants