Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to use globalize webpack plugin with TypeScript and CommonJs #73

Open
dominic-simplan opened this issue Oct 12, 2017 · 2 comments

Comments

@dominic-simplan
Copy link

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

@dominic-simplan
Copy link
Author

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.

@dominic-simplan
Copy link
Author

dominic-simplan commented Oct 12, 2017

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant