tivac/modular-css

Webpack plugin does not properly propagate errors

Closed this issue · 1 comments

chiel commented

As discussed on gitter, failure to find/parse a file spits out an error which does not indicate what the error actually is.

Expected Behavior

If there is an error finding or parsing a file, I would expect the resulting error to reflect this.

Current Behavior

I'm using webpack as part of a storybook build. The resulting error is the following:

✖ 「wdm」: TypeError: Cannot read property 'root' of undefined
    at Processor.output (/Users/ckunkels/dev/act-team-js/node_modules/@modular-css/processor/processor.js:266:41)
    at runMicrotasks (<anonymous>)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)

However after some digging, I can see the following error actually occurred:

  before: LazyResult {
    stringified: false,
    processed: false,
    error: CssSyntaxError: /Users/ckunkels/dev/act-team-js/node_modules/@usabilla/nucleus/tokens/colors.css:49:11: Unknown word

Possible Solution

So to me it looks like the error does not travel up properly, I don't know whether this originates in the Processor's output function or simply in the propagation to webpack.

Steps to Reproduce (for bugs)

Try to do import a css file with some sass-style comments (//) in it while building a project with webpack.

Context

I was trying to include values from another value, so originally I thought the issue was caused by trying to import from a file in a node module.

Your Environment

Executable Version
modular-css 25.2.0
yarn --version 1.16.0
node --version v12.14.1
OS Version
macOS Mojave 10.14.3
tivac commented

This is released in @modular-css/webpack@25.6.0