dearrrfish/preprocess-loader

Handle loaderUtils.getOptions returning null

Closed this issue · 3 comments

Hello there!

My project has several dependencies that use preprocess-loader, so the project build is failing with 0.2.1, the most recent version at the moment.

The problem is that the code is creating query = loaderUtils.getOptions this, but this.query is undefined, so query is not an object, it is null. So it throws error is accessing query.ppOptions: TypeError: Cannot read property 'ppOptions' of null.

The same error

ModuleBuildError: Module build failed: TypeError: Cannot read property 'ppOptions' of null
    at Object.module.exports (node_modules/preprocess-loader/index.js:1:415)
    at DependenciesBlock.onModuleBuildFailed (node_modules/webpack-core/lib/NormalModuleMixin.js:315:19)
    at nextLoader (node_modules/webpack-core/lib/NormalModuleMixin.js:270:31)
    at node_modules/webpack-core/lib/NormalModuleMixin.js:292:15
    at runSyncOrAsync (node_modules/webpack-core/lib/NormalModuleMixin.js:173:4)
    at nextLoader (node_modules/webpack-core/lib/NormalModuleMixin.js:290:3)
    at node_modules/webpack-core/lib/NormalModuleMixin.js:259:5
    at Storage.finished (node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:38:16)
    at node_modules/graceful-fs/graceful-fs.js:78:16
    at FSReqWrap.readFileAfterClose [as oncomplete] (fs.js:445:3)

I've had the same problem with the latest update to 0.2.1 and it was caused by a loader that have no options.

Failing in 0.2.1:

{
	loader: 'preprocess-loader'
}

I fixed the problem, by simply adding an empty options object:

{
	loader: 'preprocess-loader',
	options: {}
}

@doberkofler your fix is not work for me