Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

[4.0.0-alpha.0] Cannot read property 'requestShortener' of undefined #722

Closed
machineloop opened this issue Feb 17, 2018 · 19 comments
Closed

Comments

@machineloop
Copy link

machineloop commented Feb 17, 2018

Using 4.0.0-alpha.0, Webpack 4.0.0-beta.1, Node 9.3.0 on macOS 10.12.6:

Thanks for the hard work on this! Thought I'd try out the new Alpha.0 with my build, looks like I may have found a bug. I'm getting the following error that clearly shows extract-text-webpack-plugin in the stack trace:

Fatal error: Cannot read property 'requestShortener' of undefined
TypeError: Cannot read property 'requestShortener' of undefined
    at ConcatenatedModule.source (/home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/webpack/lib/optimize/ConcatenatedModule.js:370:44)
    at Function.renderExtractedChunk (/home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/extract-text-webpack-plugin/dist/index.js:115:38)
    at ExtractTextPlugin.extractedChunks.forEach.extractedChunk (/home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/extract-text-webpack-plugin/dist/index.js:298:46)
    at Array.forEach (<anonymous>)
    at compilation.hooks.additionalAssets.tapAsync.assetCb (/home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/extract-text-webpack-plugin/dist/index.js:286:25)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/tapable/lib/HookCodeFactory.js:24:12), <anonymous>:7:1)
    at AsyncSeriesHook.lazyCompileHook [as _callAsync] (/home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/tapable/lib/Hook.js:35:21)
    at hooks.optimizeTree.callAsync.err (/home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/webpack/lib/Compilation.js:846:32)
    at _err0 (eval at create (/home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/tapable/lib/HookCodeFactory.js:24:12), <anonymous>:11:1)
    at _async2.default.forEach.err (/home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/extract-text-webpack-plugin/dist/index.js:281:11)
    at /home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:473:16
    at iteratorCallback (/home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:1050:13)
    at /home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:958:16
    at _async2.default.forEach.err (/home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/extract-text-webpack-plugin/dist/index.js:259:13)
    at /home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:473:16
    at iteratorCallback (/home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:1050:13)
    at /home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:958:16
    at _async2.default.forEach (/home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/extract-text-webpack-plugin/dist/index.js:253:20)
    at /home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:3096:16
    at eachOfArrayLike (/home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:1055:9)
    at eachOf (/home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:1103:5)
    at Object.eachLimit (/home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:3158:5)
    at _async2.default.forEach (/home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/extract-text-webpack-plugin/dist/index.js:214:27)
    at /home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:3096:16
    at eachOfArrayLike (/home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:1055:9)
    at eachOf (/home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:1103:5)
    at Object.eachLimit (/home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/extract-text-webpack-plugin/node_modules/async/dist/async.js:3158:5)
    at compilation.hooks.optimizeTree.tapAsync (/home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/extract-text-webpack-plugin/dist/index.js:208:25)
    at AsyncSeriesHook.eval [as callAsync] (eval at create (/home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/tapable/lib/HookCodeFactory.js:24:12), <anonymous>:7:1)
    at AsyncSeriesHook.lazyCompileHook [as _callAsync] (/home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/tapable/lib/Hook.js:35:21)
    at Compilation.seal (/home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/webpack/lib/Compilation.js:789:27)
    at hooks.make.callAsync.err (/home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/webpack/lib/Compiler.js:446:17)
    at _done (eval at create (/home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/tapable/lib/HookCodeFactory.js:24:12), <anonymous>:9:1)
    at _err332 (eval at create (/home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/tapable/lib/HookCodeFactory.js:24:12), <anonymous>:4004:22)
    at _addModuleChain (/home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/webpack/lib/Compilation.js:672:11)
    at processModuleDependencies.err (/home/app-user/agent/work/841aaf28d3ac9e7f/node_modules/webpack/lib/Compilation.js:614:8)
    at _combinedTickCallback (internal/process/next_tick.js:131:7)
    at process._tickCallback (internal/process/next_tick.js:180:9)
Task 'webpack:production' took 38925ms

Not sure what the best way is to create a minimal project showing issue. Happy to follow-up with more info... Thanks!

@michael-ciniawsky
Copy link
Member

@TheLarkInn
Copy link

Do you think you could reduce this to a minimal reproduction in a repository? This would help us significantly solve this.

@circlingthesun
Copy link

@phaistonian
Copy link

The visual way - in case it helps any more.

image

@peter-mouland
Copy link

peter-mouland commented Feb 26, 2018

I can reproduce but only when my webpack config mode is set to production. I also noticed my old code had:

System.import('./app/utils/analytics').then((analytics) => analytics.init());

Please correct me if I am wrong, but I think system.import is deprecated and we should now be using import(). anyway, I commented out the offending line and everything is now dandy.


also, I had a number of plugins, and when I removed ExtractTextPlugin the error also went with it (i.e. i still had system.import in my code)

I was using "extract-text-webpack-plugin": "^4.0.0-alpha.0",

note: the reduced test case did not import any less/scss/css

Hope this helps.

@peter-mouland
Copy link

peter-mouland commented Feb 26, 2018

test case

// src/entry.js
  System.import('./app/utils/analytics').then((analytics) => analytics.init());
  console.log('test case');
// webpack.config.js
const ExtractTextPlugin = require('extract-text-webpack-plugin');

module.exports = {
  mode: 'production',
  entry: {
    app: ['./src/entry.js']
  },
  plugins: [
    new ExtractTextPlugin('[name].css'),
  ],
};

The above give an the error. The error can be resolved by either:

  • remove the use of System.import from entry.js
  • remove the use of new ExtractTextPlugin('[name].css'), from webpack config

@circlingthesun
Copy link

I'm not using System.import (at least not directly) and I'm still experiencing this issue.

@peter-mouland
Copy link

are you using ExtractTextPlugin?
do you think you could try to reproduce a minimal test case as I've done above to help narrow down your problem code?

@circlingthesun
Copy link

@peter-mouland I tried to reproduce it with a minimal example, but have not been able to. I can't even make it choke on System.import.

@DNLHC
Copy link

DNLHC commented Feb 27, 2018

Seems like it breaks with any dynamic imports not just System.import
I have several dynamic imports

const Contacts = () => import('./contacts' /* webpackChunkName: "contacts" */);

after changing it to

import Contacts from './contacts';

everything builds fine

@andybarron
Copy link

Confirming the above comment - changing ES async imports to standard ES imports fixes this.

@andybarron
Copy link

Additionally, I can confirm that removing extract-text-webpack-plugin from my webpack.config.js fixes the issue.

@circlingthesun
Copy link

@TheLarkInn I've systematically hollowed out a project and ended up with this minimal reproduction: https://github.com/circlingthesun/extract-text-webpack-plugin-bug

@michael-ciniawsky
Copy link
Member

Released in v4.0.0-beta.0 🎉

@peter-mouland
Copy link

peter-mouland commented Feb 28, 2018

that commit looks like it should do the job 👍 I'll be able to test when i get back from work. thanks @michael-ciniawsky!

@circlingthesun looking at your reduced test case, your problem is the same as previously mentioned (i.e. dynamic imports) so you should be good to go also 🎉

my reduced test case above now certainly works 💃

@circlingthesun
Copy link

@peter-mouland looks like it works 👍

@alexander-akait
Copy link
Member

Thanks everyone 👍

@DotCoyote
Copy link

DotCoyote commented Mar 1, 2018

Webpack: 4.0.1, extract-text-webpack-plugin: 4.0.0-alpha.0, Node 9.4.0

I still got that bug when I use dynamic imports like this:

const Contacts = () => import('./contacts' /* webpackChunkName: "contacts" */);

as it has to be used for https://router.vuejs.org/en/advanced/lazy-loading.html

@DotCoyote
Copy link

Sorry, missed the beta-release

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

No branches or pull requests

10 participants