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

Module not found: Error: Cannot resolve module 'cldr/event' #603

Closed
aarkerio opened this issue Apr 2, 2016 · 12 comments
Closed

Module not found: Error: Cannot resolve module 'cldr/event' #603

aarkerio opened this issue Apr 2, 2016 · 12 comments

Comments

@aarkerio
Copy link

aarkerio commented Apr 2, 2016

webpack returns:

ERROR in .//globalize/dist/globalize.js
Module not found: Error: Cannot resolve module 'cldr/event' in /home/myapp/node_modules/globalize/dist
@ ./
/globalize/dist/globalize.js 22:2-25:14

18 // UMD returnExports
19 if ( typeof define === "function" && define.amd ) {
21 // AMD
22 define([
23 "cldr",
24 "cldr/event"
25 ], factory );
26 } else if ( typeof exports === "object" ) {

event.js is on cldrjs module.

@aarkerio
Copy link
Author

aarkerio commented Apr 2, 2016

Looks like it was not a Globalize issue but a React kind. globalize-webpack-plugin fixed the problem.

@rxaviers
Copy link
Member

rxaviers commented Apr 2, 2016

Globalize modules are wrapped by UMD offering AMD, CJS and global choices. Webpack tries to use AMD (the one that appears first) and can't resolve paths correctly. globalize-webpack-plugin makes webpack to use CJS over AMD in globalize packages, which resolves these paths correctly. I'm glad it's working for you, if you notice any issue feel free to reopen.

@rxaviers rxaviers closed this as completed Apr 2, 2016
@AlexPresso
Copy link

Got the same issue, tried with both react-globalize and react-webpack-globalize, ReactJS compiler returns:

`Failed to compile.

./node_modules/globalize/dist/globalize.js
Module not found: Can't resolve 'cldr/event' in '/Applications/MAMP/htdocs/node_modules/globalize/dist'`

@outsidergiant
Copy link

outsidergiant commented Apr 13, 2018

Hi,

@TheDarangel, I faced the same issue, however, the mentioned plugin didn't resolve the issue.
My webpack version is 4.5.0;

But I was able to resolve this issue by manual resolving paths as was suggested in the
DevExtreme with Webpack and Angular and Globalize example:

resolve: {
        alias: {
            globalize$: path.resolve(__dirname, root.webroot + "js/globalize.js"),
            globalize: path.resolve(__dirname, root.webroot + "js/globalize"),
            cldr$: path.resolve(__dirname, root.webroot + "js/cldr.js"),
            cldr: path.resolve(__dirname, root.webroot + "js/cldr")
        },
        extensions: ['.ts', '.js', '.json']
    }

My packajes.json also includes the following dependencies related to globalize:
"globalize": "1.3.0",
"globalize-compiler": "1.0.0",
"globalizejs": "0.0.1",
"globalize-webpack-plugin": "2.1.0",
"cldrjs": "0.5.0",
"cldr": "4.8.0",
"cldr-data": "32.0.1",
"fs": "0.0.1-security"

I hope, you will find it helpful.

@EdwardSalter
Copy link
Contributor

I have achieved this in the same way by using the following snippet from my webpack config:

      alias: {
        'cldr$': 'cldrjs',
        'cldr': 'cldrjs/dist/cldr'
      }

This is the first library I have come across in the world of JS today that requires this kind of special configuration.
I'd imagine this is due to the fact that all the source is written using AMD modules. Would it not be better to write the source code using ES6 modules and generate the UMD bundle during the build using rollup or webpack?

@rxaviers
Copy link
Member

Not related to source files, but distribution wrapped by UMD. Please, use https://github.com/rxaviers/skip-amd-webpack-plugin or https://github.com/rxaviers/globalize-webpack-plugin/ in webpack.

@gaearon
Copy link

gaearon commented May 29, 2018

To give you some context: some tools built on top of Webpack (such as Create React App) intentionally don't support adding custom webpack plugins. In part this is exactly because the approach of every other library asking people to add stuff to their configs doesn't really scale for the larger ecosystem. A developer shouldn't need to mess with their configs to just be able to use a library.

I know it's frustrating when UMD wrappers mess things up, but maybe you could reconsider this? I don't think Webpack complains about the UMD wrappers generated by e.g. Rollup, so maybe the wrapper itself could be better?

@rxaviers
Copy link
Member

Thanks for the context. There was no objection to stop supporting AMD in #810 and therefore I'm open to reconsider different distribution that should be released as 2.0. We need someone interested to champion this effort.

@Peterabsolon
Copy link

This is unfortunate

@mohanasundarR
Copy link

Hi @rxaviers how to use Skip AMD Webpack Plugin?? can you please explain

@joshtune
Copy link

joshtune commented Aug 28, 2019

Using https://www.npmjs.com/package/globalize-webpack-plugin actually worked for me

@avtblspd
Copy link

avtblspd commented Jan 12, 2023

@rxaviers
how can i use https://github.com/rxaviers/skip-amd-webpack-plugin to Skip AMD Webpack Plugin ?

so i'm using a library called as react-flow which somehow requires react-script and it requires webpack 5 to work with storybook, which has forced me to use webpack 5

so due to that i can't really use globalizeplugin since its not compatible with webpack 5

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

10 participants