Skip to content

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

@dominic-simplan

Description

@dominic-simplan

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions