globalize-webpack-plugin icon indicating copy to clipboard operation
globalize-webpack-plugin copied to clipboard

Cannot read property 'call' of undefined

Open paulgrock opened this issue 7 years ago • 14 comments

I am trying to integrate Globalize via the this webpack plugin and am running into an Cannot read property 'call' of undefined error. It seems like this error happens with the latest version of webpack at least to my limited understanding. I cloned the example app from globalizejs/globalize and updated it here and am getting the same error. I'm not sure if this is a bug or if I've done something wrong. Any idea?

paulgrock avatar Nov 13 '17 18:11 paulgrock

Please, can you try with https://github.com/globalizejs/globalize/tree/master/examples/app-npm-webpack

rxaviers avatar Nov 13 '17 19:11 rxaviers

Thanks for the quick response. I tried that and it works but it uses webpack@^1.9.0 and 0.4.x of this plugin. I didn't see anywhere that has an example with the newest version of this plugin.

paulgrock avatar Nov 13 '17 22:11 paulgrock

Same as https://github.com/rxaviers/globalize-webpack-plugin/issues/73 I believe.

loctn avatar Nov 13 '17 23:11 loctn

Also getting this as well. Between this and some of the other issues in this repo, is this plugin still used by users of globalize?

jeremyong avatar Dec 18 '17 03:12 jeremyong

Experiencing this as well. Appears to be a regression introduced in v1.1.2. Will try to dig into it shortly.

brymacto avatar Mar 15 '18 15:03 brymacto

I'm seeing same issue with globalize/examples/app-npm-webpack-2 example. I had to make some changes to the file webpack-config.js.

  1. The syntax for CommonsChunkPlugin has changed
  2. DedupePlugin is obsolete
  3. __dirname was not defined without specifying node: { __dirname: true}

After all that, node run build succeeds and creates /dist folder. However, navigating to localhost:8080/dist/index.html produces the following error:

Uncaught TypeError: Cannot read property 'call' of undefined
    at t (vendor.74b587537ef92c04abcf.js:1)
    at Object.10 (app.74b587537ef92c04abcf.js:1)
    at t (vendor.74b587537ef92c04abcf.js:1)
    at window.webpackJsonp (vendor.74b587537ef92c04abcf.js:1)
    at app.74b587537ef92c04abcf.js:1

chuyler avatar Mar 29 '18 18:03 chuyler

I am also seeing this issue that @chuyler is seeing.

SteveLillis avatar May 05 '18 11:05 SteveLillis

I'm also running into this with Webpack 4. I've created a repo with a minimal project that causes this: https://github.com/jou/globalize-webpack-plugin-bug-77

jou avatar Dec 12 '18 16:12 jou

I am getting the same error with with Chromium. With Firefox it is 'TypeError: e[n] is undefined*

I also have made a configuration to dynamically switch locale which dynamically loads locale chunks. It works with webpack 3, but with webpack 4 i get 'modules[moduleId] is undefined' in development. In production it becomes 'e[t] is undefined', so i guess it is the same error and modules[moduleId] is more informative. See https://github.com/metaclass-nl/switch-language-example-globalize/issues/2

* configuration in https://github.com/metaclass-nl/globalize/tree/app-npm-webpack4

metaclass-nl avatar Feb 05 '19 11:02 metaclass-nl

With some debugging i found that modules[moduleId] is in a __webpack_require__ function which is defined in the webpackBootstrap section of i18n/en.<hash>.js. modules[moduleId] is undefined with call __webpack_require__(2). Actually only 65, 135, 143, 151 are available in this var modules, these are all defined in in the i18n/en.<hash>.js chunk itself. Module 2 is in vendor.<hash>.js which does not contain a __webpack_require__ function function but just adds its functions to window.webpackJsonp.

Another __webpack_require__ function is defined in main.<hash>.js, but has a different implementation, it loops through window["webpackJsonp"] passing elements to webpackJsonpCallback who adds stuff to modules[moduleId], deferredModules and installedChunks. I wonder if i18n/en.<hash>.js should define its own __webpack_require__ function. Maybe if it just added its functions to window.webpackJsonp, __webpack_require__ from main.<hash>.js would be used and it would take care of adding everything to modules so modules[moduleId] would work. OTOH dynamic loading of aditional locale chunks would then not work i guess, so maybe the implementation of the webpackBootstrap section of each locale chunk should be there, but should be compatible with the one in main.<hash>.js.

But if i take a look at the code of globalize webpack plugin i got no idea how all this could be related to what it does...

metaclass-nl avatar Feb 06 '19 11:02 metaclass-nl

I have the exact same problem. Setting production to false fixes the problem, but obviously is not the right solution.

ManuSevenval avatar Mar 13 '19 07:03 ManuSevenval

ran into the same Problem. as is see, the CommonsChunkPlugin is obsolete and should be replaced with optimization splitChunks. This is how my webpack config looks now: https://gist.github.com/Darth-Alex/181e6efe687d8f029d66672d8ede4414 But didn´t get it running. just seeing a white screen now.

Darth-Alex avatar Nov 05 '19 15:11 Darth-Alex

image it works in development mode, but production

kun-guo avatar Feb 12 '20 08:02 kun-guo

For a workaround that uses skip-amd-webpack-plugin and cldr instead of the globalize-webpack-plugin, see https://github.com/metaclass-nl/switch-language-example-globalize

metaclass-nl avatar Feb 13 '20 11:02 metaclass-nl