Primeng: Built application includes all PrimeNG modules (even unused ones)

Created on 9 Nov 2017  ·  9Comments  ·  Source: primefaces/primeng

I'm submitting a ... (check one with "x")

[x] bug report => Search github for a similar issue or PR before submitting
[ ] feature request => Please check if request is not on the roadmap already https://github.com/primefaces/primeng/wiki/Roadmap
[ ] support request => Please do not submit support request here, instead see http://forum.primefaces.org/viewforum.php?f=35

Current behavior
I use Angular CLI (v1.5.0) to build my application. Generated vendor.bundle.js asset is much bigger then previously (before version 5.0.0-RC0), because it includes every single PrimeNG module:
image

Expected behavior
It should contain only those PrimeNG modules included in the project, in version 4.* for me it was looking like that:
image

What is the motivation / use case for changing the behavior?
Keeping the application as small as possible.

  • Angular version: 5.0.0-rc0

  • PrimeNG version: 5.0.0-RC0

  • Language: [TypeScript 2.4.2]

  • Node (for AoT issues): node --version = 6.11.4

Most helpful comment

Using version 9, this form of import (import {TableModule} from 'primeng/components/table/table') is no longer implemented, leaving only this form (import {TableModule} from 'primeng/table') that ends up compiling all modules.

Any solution?

All 9 comments

I “suffered” from the same thing. Turns out if you just import from primeng/primeng the final bundle with include some stuff you haven't used. I fixed that by including directly the components that I was using. Something like

import { DataTableModule } from 'primeng/components/datatable/datatable';

Sure it's a bit more hassle but now I don't include the whole “jungle” :D

You can also refer to this post in the forum.

@dzhavat you are absolutely right. It worked! :)
Quite annoying IDEs are suggesting barrel imports by default, so it's necessary to amend those imports manually, but it's worth doing it anyway.

Thanks.

We'll update the docs import section to include the actual path to avoid future issues.

hi
i was wondering if with new versions the problem continue or is safe to use what is said in the docs
that way

import {TableModule} from 'primeng/table';

or

import {TableModule} from 'primeng/components/table/table'

Can I use import { TableModule } from 'primeng/primeng'; on ^6.1.4 version or is there the same problem?

Using version 9, this form of import (import {TableModule} from 'primeng/components/table/table') is no longer implemented, leaving only this form (import {TableModule} from 'primeng/table') that ends up compiling all modules.

Any solution?

Using version 9, this form of import (import {TableModule} from 'primeng/components/table/table') is no longer implemented, leaving only this form (import {TableModule} from 'primeng/table') that ends up compiling all modules.

Any solution?

I have the same problem

Using version 9, this form of import (import {TableModule} from 'primeng/components/table/table') is no longer implemented, leaving only this form (import {TableModule} from 'primeng/table') that ends up compiling all modules.
Any solution?

I have the same problem

i am facing a same problem it tooks 5 mins to compile all of modules ..

Hi,
I have the same issue, 5mb bundle size, it's exeed all budget limits.
With Latest primeng and latest angular.

any news on this?

Was this page helpful?
0 / 5 - 0 ratings

Related issues

mitosandov picture mitosandov  ·  3Comments

lilling picture lilling  ·  3Comments

SchneMa picture SchneMa  ·  3Comments

garethlewis picture garethlewis  ·  3Comments

miresk picture miresk  ·  3Comments