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
[feature request] inline all imports into a single file #1681
Comments
Why should Babel support this? Don't Browserify and Webpack solve this problem well with an ecosystem of plugins, servers, watchers and other dev tools? (Not being snarky. Genuinely wondering.) |
@gaearon browserify and webpack kinda solved it, but having multiple source->ast->source steps really limits what you can do. Erasing the division between packaging and transformation makes sense. Think about it, packaging is just another transformation that just so happens to span multiple files. |
@gaearon I agree 100%
If we wanted to take this further as @sebmck and I talked about in meatspace: I think module formatters and the watcher should be dropped from babel... but until we do the great strip down of the library into a just a code "transformer", this enhancement does have a place. 🐳 💿 🌾 |
+1 |
I'm not sure of the benefits of having babel generated bundles. I let Webpack handle all of this functionality, and babel is just another transformer in the pipeline. Why are browserify or webpack bad tools for packing? |
+1 it would be really awesome to just use this in babelJS, since it would be a one step conversion |
I wrote a very minimalistic es6 bundler as a plugin for babel. You can find the source code here: https://gist.github.com/zbraniecki/649e0390d57ac353494d It looks like this: It turns sth like this:
./src/runtime/web/index.js
into:
It allows us to remove webpack from the toolchain (which is important because webpack cannot work on not-transpiled es6 code) and gives us a very readable output because the modules look as close to the original files as possible. I'd be happy to release our bundler as a separate module if there's interest from people. |
I'm willing to bet this wouldn't handle all cases well. What happens with
|
No support for cycles yet. Didn't need so far |
@samccone, clarifying question. Do you mean all dependencies including third party libraries? Or just 'internal' dependencies? In other words, if my point of entry file has: import $ from 'jquery';
import utils from './utils'; Would you want the flag to bundle up both jQuery and utils, or just utils? |
both @jmeas :) |
k, cool. 👍 |
Closing this and marking it as revisit for something to look into in the future. I'll delegate this to rollup for the timebeing. |
Use case:
You create a library/tool that has dependencies.
You want to distribute your library in a UMD format (and have it work in the browser without a user having to use something like system.js to polyfill "require")
Current solution:
Using browserify to do the inlining work or create a custom build system to support this.
Ideal solution:
A flag to enable this joining inside of babel.
Why does this belong in core?
If you support exporting to UMD, then for it to be truly universal inlining the dependencies is essential.
Thanks 👾
The text was updated successfully, but these errors were encountered: