-
-
Notifications
You must be signed in to change notification settings - Fork 8.8k
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
Sharing a webpack bundle #628
Comments
You can do this with a combination of |
would output.library allow me to expose moduleA and moduleB of project 1 to reference as externals of project 2? I'm looking at http://webpack.github.io/docs/library-and-externals.html but I'm not seeing exactly how this can be accomplished. thanks! |
Bundle Project 1 with Then configure Project 2 like |
sorry, but that is not what i'm looking for. I'll explain further. define('project1/moduleB', [], function(){ I want webpack to bundle those 2 modules, and then share the bundle with another project. define('project2/moduleC', ['project1/moduleA', 'project1/moduleB'], function(moduleA, moduleB){ it seems like with the external, each module in project1 would need to be a separate bundle, and that is not desired. |
Is it necessary to bundle Your approach is somewhat contradictory. You want to export |
I don't want to use the library option, that is what was suggested to get it to work,and I stated why it didn't make sense to use. Using npm would require us to set up a private npm server. I was able to get this to work with browserify, which allows you to customize module ids with the label pipeline. You guys should consider doing something similar. |
You don't need a private npm server. You can specify any git tag/branch/commit: {
"my-module": "git://example.com/any/repo.git#v2.1.0"
} while v2.1.0 is a git tag. Pre-bundling dependencies is discouraged because it makes it harder to optimize in the end (e.g. deduping modules). |
Jason, I understand your need because I have the same problem. It would be nice to treat webpack bundle like it was external library in other languages (eg. dll). I have many webpack projects and sometimes want to use some bundled ones like i have sources in my current dir. I think we need something like external bundle option (and then we could add these bundles to html scripts or select to bundle it in our current project). |
So...does this means we need to put libraries as source directories, rather than packed files to be included? For example, if I have a library in ES6 module format:
And I want to use this
(note another issue is
And then to webpack whole
And maybe add some |
Right. |
@coderitual There is a This has negative impact on loading performance (more requests) and positive impact on caching (app can change independend from dll). The normal user don't want this. You want a single bundle. |
@sokra Thanks! Now I'm mostly using full sources of other local packages (symlinks in node_modules) but I'll check this plugin. |
@jasonmcaffee Safe to close? |
I have a similar scenario but the bundle is created by non-webpack bundlers (r.js). Does that mean webpack cannot read r.js built bundles and when there are multiple define blocks in a file they will not exposed to be required from other files? |
Hello, I'm trying to find a way to share a webpack bundle with another project.
In my webpack bundle I have moduleA and moduleB, and I would like to reference those modules inside of another webpack project.
e.g.
Project 1:
-> module A
-> module B
Project 2:
-> module C require('Project 1/module A', 'Project 1/module B')
I've done some searching and can't seem to find an example of this. (I've seen examples using the CommonChunksPlugin, but that only seems to work if both projects are built in the same process, and that is not the desired behavior)
Thanks
The text was updated successfully, but these errors were encountered: