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

Error after upgrading to v5: The module created for a LoaderDependency must have an original source #1249

Closed
thomasledoux1 opened this issue Jan 18, 2021 · 2 comments

Comments

@thomasledoux1
Copy link

Hi,

All the plugins listed below are on the latest version.
less-loader: 7.2.1
css-loader: 5.0.1
file-loader: 6.2.0
postcss-loader: 4.1.0
extract-loader: 5.1.0
autoprefixer: 10.2.1

My postcss config:

module.exports = {
  plugins: [require('autoprefixer')],
};

I have the following rule in my webpack (5) config:

        test: /\.less$/,
        /* include: [
          settings.PATHS.CSS_SOURCE,
          ...settings.PATHS.CSS_FEATURES_SOURCE,
        ], */
        use: [
          {
            loader: 'file-loader',
            options: cssOptions,
          },
          {
            loader: 'extract-loader',
          },
          {
            loader: 'css-loader',
            options: {
              importLoaders: 2,
              sourceMap: process.env.npm_lifecycle_event.indexOf('watch') > -1,
              url: false,
            },
          },
          {
            loader: 'postcss-loader',
            options: {
              postcssOptions: {
                config: path.resolve(__dirname, '../postcss.config.js'),
              },
            },
          },
          {
            loader: 'less-loader',
            options: {
              lessOptions: {
                paths: [path.resolve(__dirname, 'node_modules')],
              },
            },
          },
        ],
      },

I'm using the importLoaders: 2 because I saw in the documentation for css-loader this would be necesarry if the previous loaders did something to the @import's too?
Now I'm getting the following error:

 UnhandledPromiseRejectionWarning: Error: The module created for a LoaderDependency must have an original source
    at compilation.handleModuleCreation.err (C:\Projects\Carglass\carglass930-source\src\Projects\Platform\code\node_modules\webpack\lib\dependencies\LoaderPlugin.js:79:16)
    at buildModule.err (C:\Projects\Carglass\carglass930-source\src\Projects\Platform\code\node_modules\webpack\lib\Compilation.js:1556:8)
    at hooks.result.callAsync.hookError (C:\Projects\Carglass\carglass930-source\src\Projects\Platform\code\node_modules\webpack\lib\util\AsyncQueue.js:281:5)
    at Hook.eval [as callAsync] (eval at create (C:\Projects\Carglass\carglass930-source\src\Projects\Platform\code\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:6:1)
    at AsyncQueue._handleResult (C:\Projects\Carglass\carglass930-source\src\Projects\Platform\code\node_modules\webpack\lib\util\AsyncQueue.js:254:21)
    at _processor (C:\Projects\Carglass\carglass930-source\src\Projects\Platform\code\node_modules\webpack\lib\util\AsyncQueue.js:237:11)
    at _modulesCache.store.err (C:\Projects\Carglass\carglass930-source\src\Projects\Platform\code\node_modules\webpack\lib\Compilation.js:1263:15)
    at C:\Projects\Carglass\carglass930-source\src\Projects\Platform\code\node_modules\webpack\lib\HookWebpackError.js:69:3
    at Hook.eval [as callAsync] (eval at create (C:\Projects\Carglass\carglass930-source\src\Projects\Platform\code\node_modules\tapable\lib\HookCodeFactory.js:33:10), <anonymous>:15:1)
    at Cache.store (C:\Projects\Carglass\carglass930-source\src\Projects\Platform\code\node_modules\webpack\lib\Cache.js:107:20)

When I delete the importLoaders property, I get the following error:

TypeError: Cannot read property 'sources' of undefined
    at cssWithMappingToString (C:\Projects\Carglass\carglass930-source\src\Projects\Platform\code\node_modules\css-loader\dist\runtime\cssWithMappingToString.js:25:33)
    at C:\Projects\Carglass\carglass930-source\src\Projects\Platform\code\node_modules\css-loader\dist\runtime\api.js:14:21
    at Array.map (<anonymous>)
    at Array.toString (C:\Projects\Carglass\carglass930-source\src\Projects\Platform\code\node_modules\css-loader\dist\runtime\api.js:13:17)
    at extractExports (C:\Projects\Carglass\carglass930-source\src\Projects\Platform\code\node_modules\extract-loader\lib\extractLoader.js:182:269)
    at C:\Projects\Carglass\carglass930-source\src\Projects\Platform\code\node_modules\extract-loader\lib\extractLoader.js:171:45
    at Generator.next (<anonymous>)
    at step (C:\Projects\Carglass\carglass930-source\src\Projects\Platform\code\node_modules\babel-runtime\helpers\asyncToGenerator.js:17:30)
    at C:\Projects\Carglass\carglass930-source\src\Projects\Platform\code\node_modules\babel-runtime\helpers\asyncToGenerator.js:28:13

What am I doing wrong?
This started happening after I upgraded css-loader to v5.0.1

@alexander-akait
Copy link
Member

Problem in extract-loader peerigon/extract-loader#99, nothing to fix here, sorry

@thomasledoux1
Copy link
Author

Thank you for pointing me in the right direction @alexander-akait !

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