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

_compilation property deprecated and undefined in latest webpack ? #42

Closed
AlexandreBonaventure opened this issue Jun 29, 2018 · 2 comments

Comments

@AlexandreBonaventure
Copy link

Hi,
with webpack@4.14.0, I'm unable to get this loader working. It throws an error at build time!
I can see _compilation in the deprecated properties in the loader API https://webpack.js.org/api/loaders/#deprecated-context-properties
Maybe it has been removed completely in the latest webpack versions ??

Cannot read property 'createChildCompiler' of undefined
    at Object.loader.pitch (/node_modules/workerize-loader/dist/index.js:28:41)

Here's what gives when I console.log(this._compilation)

{ version: 2,
  resolve: [Function: resolve],
  emitWarning: [Function: emitWarning],
  emitError: [Function: emitError],
  exec: [Function: exec],
  options:
   { context: '' },
  webpack: true,
  'thread-loader': true,
  sourceMap: true,
  context: '/src/core/shared/timer',
  loaderIndex: 1,
  loaders:
   [ { path: '/node_modules/babel-loader/lib/index.js',
       query: '',
       options: undefined,
       ident: undefined,
       normal: [Function],
       pitch: undefined,
       raw: undefined,
       data: null,
       pitchExecuted: true,
       normalExecuted: false,
       request: [Getter/Setter] },
     { path: '/node_modules/worker-loader/dist/cjs.js',
       query: '',
       options: undefined,
       ident: undefined,
       normal: [Function],
       pitch: [Function: pitch],
       raw: undefined,
       data: {},
       pitchExecuted: true,
       normalExecuted: false,
       request: [Getter/Setter] },
     { path: '/node_modules/eslint-loader/index.js',
       query: '??ref--13-0',
       options: [Object],
       ident: 'ref--13-0',
       normal: null,
       pitch: null,
       raw: null,
       data: null,
       pitchExecuted: false,
       normalExecuted: false,
       request: [Getter/Setter] } ],
  resourcePath: '/src/core/shared/timer/refresh.worker.js',
  resourceQuery: '',
  async: [Function: async],
  callback: [Function],
  cacheable: [Function: cacheable],
  addDependency: [Function: addDependency],
  dependency: [Function: addDependency],
  addContextDependency: [Function: addContextDependency],
  getDependencies: [Function: getDependencies],
  getContextDependencies: [Function: getContextDependencies],
  clearDependencies: [Function: clearDependencies],
  resource: [Getter/Setter],
  request: [Getter],
  remainingRequest: [Getter],
  currentRequest: [Getter],
  previousRequest: [Getter],
  query: [Getter],
  data: [Getter] }
{ version: 2,
  resolve: [Function: resolve],
  emitWarning: [Function: emitWarning],
  emitError: [Function: emitError],
  exec: [Function: exec],
  options:
   { context: '' },
  webpack: true,
  'thread-loader': true,
  sourceMap: true,
  context: '/src/location',
  loaderIndex: 1,
  loaders:
   [ { path: '/node_modules/babel-loader/lib/index.js',
       query: '',
       options: undefined,
       ident: undefined,
       normal: [Function],
       pitch: undefined,
       raw: undefined,
       data: null,
       pitchExecuted: true,
       normalExecuted: false,
       request: [Getter/Setter] },
     { path: '/node_modules/worker-loader/dist/cjs.js',
       query: '',
       options: undefined,
       ident: undefined,
       normal: [Function],
       pitch: [Function: pitch],
       raw: undefined,
       data: {},
       pitchExecuted: true,
       normalExecuted: false,
       request: [Getter/Setter] },
     { path: '/node_modules/eslint-loader/index.js',
       query: '??ref--13-0',
       options: [Object],
       ident: 'ref--13-0',
       normal: null,
       pitch: null,
       raw: null,
       data: null,
       pitchExecuted: false,
       normalExecuted: false,
       request: [Getter/Setter] } ],
  resourcePath: '/src/location/conflict-detector.worker.js',
  resourceQuery: '',
  async: [Function: async],
  callback: [Function],
  cacheable: [Function: cacheable],
  addDependency: [Function: addDependency],
  dependency: [Function: addDependency],
  addContextDependency: [Function: addContextDependency],
  getDependencies: [Function: getDependencies],
  getContextDependencies: [Function: getContextDependencies],
  clearDependencies: [Function: clearDependencies],
  resource: [Getter/Setter],
  request: [Getter],
  remainingRequest: [Getter],
  currentRequest: [Getter],
  previousRequest: [Getter],
  query: [Getter],
  data: [Getter] }

Hope to hear from you guys!
Thanks for this awesome package!

@AlexandreBonaventure
Copy link
Author

AlexandreBonaventure commented Jul 4, 2018

Turns out it was an issue caused by thread-loader used by vue-cli internally not giving the usual loader context. see webpack-contrib/thread-loader#27
However, since _compilation is deprecated, it would be worth to move to the webpack 4 way of using the loader API

@Jmingzi
Copy link

Jmingzi commented Jul 12, 2023

Suggest adding exclude to thread loader for specific files

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

2 participants