Primeng: Error: AOT does not work with rc.3

Created on 5 Nov 2016  路  7Comments  路  Source: primefaces/primeng

ngc command works ok without error.
When the rollup command is given, the following error is reported:
Error: 'InputTextModule' is not exported by node_modulesprimengprimeng.js (imported by appapp.module.js)

Can a working example be provided?

Most helpful comment

I was able to get mine rolled up combining Jim and Ctrl's suggestions.

import nodeResolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import uglify from 'rollup-plugin-uglify';

export default {
    entry: 'app/main-aot.js',
    dest: 'aot/main.js', // output a single application bundle
    sourceMap: false,
    format: 'iife',
    plugins: [
        nodeResolve({ jsnext: true, module: true }),
        commonjs({
            include: [
            'node_modules/rxjs/**',
            'node_modules/primeng/**'
            ],
            namedExports: {
            'node_modules/primeng/primeng.js': [ 'TabViewModule', 'DialogModule' ]
        },
        }),
        uglify()
    ]
};

This was using [email protected], [email protected], [email protected].

All 7 comments

try to to add this to plugins in rollup.config.js

    commonjs({
        namedExports: {
            // left-hand side can be an absolute path, a path relative to the current directory, or the name of a module in node_modules
            'node_modules/primeng/primeng.js': [ 'InputTextModule' ]
        }

No this does not work.
Can You provide an example of end-to-end aot application using primeng?
The example of angular.io works fine.
As soon as I put primeng modules in app.module.ts, I get error.

I don't use aot yet, but I had similar issue with rollup and the configuration above fixed it. You can google more for namedExports there are might be some other options.
But I have another huge issue with rollup. The code just simple doesn't work after tree shake. Rollup removes some chunks which it shouldn't.

I'm pretty sure this is because the PrimeNG NPM package is distributed as CommonJS modules. I don't know if that will ever change, but adding PrimeNG to the Rollup CommonJS plugin includes seems to work just fine.

For reference, my Rollup config looks like this (note that this is basically verbatim from the Angular AOT cookbook with PrimeNG included):

...
plugins: [
      nodeResolve({jsnext: true, module: true}),
      commonjs({
        include: [
          'node_modules/rxjs/**',
          'node_modules/primeng/**'
        ]
      }),
      uglify()
  ]
...

I was able to get mine rolled up combining Jim and Ctrl's suggestions.

import nodeResolve from 'rollup-plugin-node-resolve';
import commonjs from 'rollup-plugin-commonjs';
import uglify from 'rollup-plugin-uglify';

export default {
    entry: 'app/main-aot.js',
    dest: 'aot/main.js', // output a single application bundle
    sourceMap: false,
    format: 'iife',
    plugins: [
        nodeResolve({ jsnext: true, module: true }),
        commonjs({
            include: [
            'node_modules/rxjs/**',
            'node_modules/primeng/**'
            ],
            namedExports: {
            'node_modules/primeng/primeng.js': [ 'TabViewModule', 'DialogModule' ]
        },
        }),
        uglify()
    ]
};

This was using [email protected], [email protected], [email protected].

@meekbot Thank you!

Please try with the latest PrimeNG version and comment if the issue still persists.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Helayxa picture Helayxa  路  3Comments

pchristou picture pchristou  路  3Comments

SchneMa picture SchneMa  路  3Comments

mitosandov picture mitosandov  路  3Comments

jisqaqov picture jisqaqov  路  3Comments