Unable to use globalize webpack plugin with TypeScript and CommonJs
Hi, I am having issue getting the globalize-webpack-plugin to work in my Typescript project which is using CommonJS.
I have created a sample project here. When I build the project, I am getting the following error:
ERROR in ./node_modules/Globalize/dist/globalize.js
Module not found: Error: Can't resolve 'cldr/event' in 'C:\Projects\webpack2-testing\node_modules\Globalize\dist'
@ ./node_modules/Globalize/dist/globalize.js 22:2-25:14
@ ./node_modules/Globalize/dist/node-main.js
@ ./app/index.ts
Seems like webpack tries to use AMD instead of CommonJS?
If I remove the globalize import from the index.ts, it builds without error, but I get an error in the browser:
Uncaught ReferenceError: Globalize is not defined
In another attempt, I added a globalize.d.ts with the following content:
declare module 'globalize' {
export = Globalize;
}
and changed the import to import * as Globalize from 'globalize';. This works in development mode, but as soon as I change to production, I get the following error:
Uncaught TypeError: Cannot read property 'call' of undefined
at __webpack_require__ (vendor.js:55)
Whereas the vendor.js:55 line is:
// Execute the module function
/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
Is there something wrong in my configuration or what could be the cause of the issue...?
Thanks, Dominic
Nevermind, issue was that I was excluding the node_modules folder when configuring the ts-loader in the webpack-config.js. Sorry for creating this ticket.
Sorry need to reopen this again... the issue was not excluding node_modules. Unintentionally I had changed the plugin mode back to development, which also worked before. Changing back to production lead to the same error as before (Cannot read property 'call' of undefined).
If I change the typeScript module to "amd", I am getting the following error instead:
Uncaught TypeError: currencyFormatter is not a function
at component (bundle.js:12)
at Object.<anonymous> (bundle.js:16)
at Object.4 (bundle.js:17)
at __webpack_require__ (vendor.js:55)
at webpackJsonpCallback (vendor.js:26)
at bundle.js:1