question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Excluding files in bundled javascript

See original GitHub issue

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/

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:2
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

3reactions
jonrimmercommented, Mar 5, 2019

Would also be useful for Chart.js, as it includes the whole of Moment, even though it is technically an optional dependency with v2.8: https://github.com/chartjs/Chart.js/pull/5978

0reactions
angular-automatic-lock-bot[bot]commented, Jun 27, 2020

This issue has been automatically locked due to inactivity. Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to exclude directory from getting bundled by Webpack?
When I build with webpack, all my JS files get bundled except for the files in the ./src/Portfolio directory as per my Webpack.config.js...
Read more >
How to exclude files from being bundled #6941 - GitHub
I'm little bit struggling now with replicate my construct from parcel v1, where i used parcel-plugin-html-externals for exclude js files from being bundled...
Read more >
How to Exclude Specific File from JS Bundling in Magento 2
In this tutorial, Today I will explain to how to exclude specific file from JS Bundling in Magento 2. In Magento 2, to...
Read more >
Is it possible to ignore a file from being bundled in webpack ...
I have a very unique case here where I need a file excluded from the final build but want to retain the calls...
Read more >
Selectively exclude Javascript files from bundle in Vaadin 14 ...
Selectively exclude Javascript files from bundle in Vaadin 14 builds ... I am using a component (in my case the excellent Full Calendar...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found