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

Support Tree Shaking through the module field in package.json #843

Closed
jwickens opened this issue May 4, 2017 · 5 comments
Closed

Support Tree Shaking through the module field in package.json #843

jwickens opened this issue May 4, 2017 · 5 comments

Comments

@jwickens
Copy link

jwickens commented May 4, 2017

Webpack and rollup use the module field in the package.json to find a build with ES6 imports which enables tree shaking.

You can use babel to transpile with

{
  "presets": [["es2015", {"modules": false}]]
}

You will have configure babel to transpile flow too.

Enabling this in this library could potentially reduce client builds by around 100kb

@wincent
Copy link
Contributor

wincent commented May 4, 2017

Thanks for posting this issue, @jwickens. I thought we already had one to track this, but I can't find it. I must have been thinking of this one on the Relay repo.

@baer
Copy link
Contributor

baer commented May 26, 2017

@wincent PR #880 is a step in this direction since it allows for variable output types. After that is merged, implementing this should just be using the BABEL_ENV variable to create different build targets. I'm more than happy to take on this work.

@baer
Copy link
Contributor

baer commented Jul 4, 2017

Okay, now that #880 is merged, this should be somewhat straightforward! The holdup is that there is a unique build/deploy process that will have to change to support it.

@leebyron @wincent I spent a minute looking through how this gets all bundled up, and it seems like the build steps in the package.json are never used. I don't see any references to dist in the code. Instead, there are a couple of bash scripts here and here that build the project.

Would you mind if I consolidate the duplicate sed and babel commands and use npm scripts to get this tidied up? I'm not sure I see how to do a secondary "modules" build with babel running in the root like it is now.

@baer
Copy link
Contributor

baer commented Jul 4, 2017

Okay, I've got a first pass at what this type of change would look like. Before I get it all tucked in, I'd love to get some feedback.

#939

@leebyron
Copy link
Contributor

leebyron commented Dec 7, 2017

Supported in master (thanks to @baer's hard work) and will be included with the next release

@leebyron leebyron closed this as completed Dec 7, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants