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

Supporting multiple entry points #113

Closed
guybedford opened this issue Dec 5, 2018 · 6 comments · Fixed by #410
Closed

Supporting multiple entry points #113

guybedford opened this issue Dec 5, 2018 · 6 comments · Fixed by #410
Labels
enhancement New feature or request priority Important issue or pull request to fast-track

Comments

@guybedford
Copy link
Contributor

In our own build we build all of the various entry points separately.

It should be possible to have all the entry points be a single "build operation".

The thing about this is that it does involve an API change - no longer just returning { code, map } but returning a { code, map } pair for each entry point built.

We could possibly even just have the build output a single files: { [name]: source } object where files[filename] contains the entry points, and do this as a breaking API change.

Alternatively the single-file v multiple entry point builds could be seen as separate APIs.

When done, the benefit of this would be that instead of duplicating code between the entry point builds, webpack can ensure they have code sharing between them.

This should reduce the self-hosting footprint size considerably too.

@rauchg
Copy link
Member

rauchg commented Dec 5, 2018

Not sure I agree with this one (at least yet).

If you want multiple entrypoints, wouldn't you invoke ncc build multiple times? Perhaps using -e if you need to exclude something?

@guybedford
Copy link
Contributor Author

If you want multiple entrypoints, wouldn't you invoke ncc build multiple times? Perhaps using -e if you need to exclude something?

The benefit of permitting multiple entry points is you can get chunks that share code between them. So for example, it might be possible for acorn to be shared between Webpack and the asset reloader plugin for example (if they're the same version). This in turn reduces the build size and lazy load times.

@rauchg
Copy link
Member

rauchg commented Dec 5, 2018

True but there's still the tradeoff in hitting disk in that case, as well as increasing complexity in the API. Open to thinking about this one, but probably not a priority.

@rauchg rauchg added duplicate This issue or pull request already exists enhancement New feature or request and removed duplicate This issue or pull request already exists labels Dec 10, 2018
@macklinu macklinu mentioned this issue Dec 26, 2018
2 tasks
@guybedford
Copy link
Contributor Author

guybedford commented May 23, 2019

It turns out this is a prerequisite to the next.js integration due to the use of webpack internals effectively requiring a multiple entrypoints build.

@guybedford
Copy link
Contributor Author

Since we're doing a major here I think this is a good opportunity to make output just a files map for ncc, as that will naturally support the multi-entry case a lot more nicely.

Hoping to get a PR up for this soon.

@styfle styfle added the priority Important issue or pull request to fast-track label May 28, 2019
@LecrisUT
Copy link

LecrisUT commented Jul 6, 2023

@guybedford @styfle, was this never re-implemented? I am guessing this could still be done programmatically, but an example of that would be nice.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request priority Important issue or pull request to fast-track
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants