Skip to content

Excluding files in bundled javascript #11844

@pjordaan

Description

@pjordaan

Bug Report or Feature Request (mark with an x)

- [ ] bug report
- [ X] feature request

Command (mark with an x)

- [ ] new
- [X] build
- [ ] serve
- [ ] test
- [ ] e2e
- [ ] generate
- [ ] add
- [ ] update
- [ ] lint
- [ ] xi18n
- [ ] run
- [X ] config
- [ ] help
- [ ] version
- [ ] doc

Versions

Any Angular Cli

Repro steps

Webpack has a nice feature to generate code for dynamic requires, for example: require('@angular/' + lib); would write code and bundle all @angular packages together. The downside of this feature is that it often includes too much at the same time.
There are quite a few node.js libraries that do something like require('./i18n/' + language + '.js') to load the correct i18n. That works nice on a node.js server, but if used with Webpack the bundled output will contain all languages.

As a solution you would need to modify the Webpack configuration to exclude all languages you do not use. However since the Webpack config can not be altered without 'ng eject' there is no way for me to exclude javascript from bundling.

Desired functionality

Being able to exclude files from the bundled files to reduce filesize without having to call ng eject.

Mention any other details that might be useful

Example blog: https://bjacobel.com/2016/12/04/highlight-bundle-size/

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions