6
votes

Is here anybody who know how to make PrimeNG under Webpack working?

We have project on angular2-webpack-starter but the PrimeNG have todo just with System.js loader

I get the point when the PrimeNG is loading fine, but i can get success with PrimeUI library... let say for example file primeng/components/togglebutton/togglebutton.ts

error TS2503: Cannot find namespace 'PrimeUI'.

I even tried magic formula with declare in ...togglebutton.ts

declare var PrimeUI:any;

and in my webpack.config

plugins: [ 
  new webpack.ProvidePlugin({
    PrimeUI: 'primeui',
  })
  .
  .
 ],

but if I try something like

import * as PrimeUI from 'primeui';

error TS2307: Cannot find module 'primeui'.

I just remind I did npm install primeui and the primeui is present in node_modules with all dependencies

1
We'll probably switch to common.js and provide a sample quickstart with webpack soon. d.ts for PrimeUI is at github.com/primefaces/primeng/blob/master/showcase/resources/… - Cagatay Civici
PrimeNG uses commonjs as of 0.6.0 - Cagatay Civici
Have got PrimeNG running? Loading PrimeNG and PrimeUI is working for me but i do get JQuery errors. - sigi
I stop trying that. For now I using just jQuery DataTable and Select2 based on bootstrap - m1uan
There is a PrimeNG+WebPack sample here. github.com/primefaces/primeng-quickstart-webpack - Cagatay Civici

1 Answers

1
votes

If you are getting error on :

import * as PrimeUI from 'primeui';

You need to do

declare module 'primeui' {
    var foo:any;
    export = foo
}