Preact-cli: options.sourceMap isn't set - CLI 2.0.0

Created on 16 Oct 2017  ·  17Comments  ·  Source: preactjs/preact-cli

Trying to track down why this error might be happening in dev. CLI version 1.4.1 was fine.

Seeing the following when I try to start the dev server.

@ ./node_modules/preact-cli/lib/lib/entry.js
⚠ WARN ./node_modules/preact-cli/lib/lib/webpack/proxy-loader.js?{"__proxy_loader__":{"loader":"sass-loader","cwd":"my-dir-here"},"sourceMap":true}!./src/components/menu/style.scss
(Emitted value instead of an instance of Error)

Previous source map found, but options.sourceMap isn't set.
In this case the loader will discard the source map entirely for performance reasons.
See https://github.com/postcss/postcss-loader#sourcemap for more information.

Details
npm 5.5.1
node 8.7.0

bug

Most helpful comment

Oohh... dev 🤦‍♂️ Derp.

Yup, I'll get a fix out.

All 17 comments

I have exactly the same issue following the same upgrade path.

npm 5.5.1
node 8.1.3

This was a change within postcss-loader that I overlooked. PR open, just waiting for another team member to approve & then we'll publish a patch release.

Thanks guys.

Now available in 2.0.1

Hi @lukeed

Based on your PR I think my issue is with the proxy-loader. If I update as you did to use isProd vs true that seems to work. Not sure is there is a reason for that to be forced to true.

use: [{
                    loader: 'proxy-loader',
                    options: {
                        cwd,
                        loader: 'sass-loader',
                        options: { sourceMap: isProd }
                    }
                }]

Hey, proxy-loader just passes the options along to the loader its proxying. They're all set to true to always enable it, initially.

In 1.4, the isProd value was still the final determinant.

The proxy-loader settings haven't changed from 1.4 to 2.0 --- only postcss-loader has & the last PR patches that difference.

Thanks!

@lukeed I've just updated to 2.0.1 and am still getting errors:
```⚠ WARN /Users/euan/.npm-packages/lib/node_modules/preact-cli/lib/lib/webpack/proxy-loader.js?{"__proxy_loader__":{"loader":"sass-loader","cwd":"/Users/euan/Development/Apps/xmas-2017-preact"},"sourceMap":true}!./src/components/day/style.scss
(Emitted value instead of an instance of Error)

⚠️ PostCSS Loader

Previous source map found, but options.sourceMap isn't set.
In this case the loader will discard the source map entirely for performance reasons.
See https://github.com/postcss/postcss-loader#sourcemap for more information.```

@euangoddard Can you verify that both your global _and_ local copies are on 2.0.1?

I still get the warning as well with the 2.0.1 version globally and locally (dev mode).

The server does run but the warning happens for each sass file.

If I log out the options (via preact.config.js) for the sass-loader it shows as

{ sourceMap: true }

If I modify the config -> sass-loader options to { sourceMap: false } the warning does go away.

Can you guys post a reproduction somewhere? I'm not getting it. Thanks!

Let's see what @euangoddard says ... than I'll see if I can reproduce in a test repo.

Sorry is the --sass flag gone?

preact create testproject --sass

@lukeed had a sec to reproduce here's a test repo:
https://github.com/timarney/preactcli-sass

Warning in dev

⚠ WARN ./node_modules/preact-cli/lib/lib/webpack/proxy-loader.js?{"cwd":"dir-here-preactcli-sass","loader":"sass-loader","options":{"sourceMap":true}}!./src/style/index.scss
(Emitted value instead of an instance of Error)

 ⚠️  PostCSS Loader

Previous source map found, but options.sourceMap isn't set.
In this case the loader will discard the source map entirely for performance reasons.
See https://github.com/postcss/postcss-loader#sourcemap for more information.

The build works - text in red
screen shot 2017-10-17 at 4 55 34 pm

Yes, --sass flag is gone, as are all other style flags.

Thanks 🙏 Check it out now.

 ⌁ ~/repos/testing/preactcli-sass ::  yarn build
yarn run v1.2.1
$ preact build
Build [==                  ] 10% (0.2s) building modules(node:18332) DeprecationWarning: Chunk.modules is deprecated. Use Chunk.getNumberOfModules/mapModules/forEachModule/containsModule instead.
Build [==================  ] 91% (0.5s) additional chunk assets processing
  Total precache size is about 144 kB for 14 resources.
✨  Done in 4.29s.

No warnings~

Oohh... dev 🤦‍♂️ Derp.

Yup, I'll get a fix out.

sorry guys, I'm getting this issue since yesterday... never happened before in two months on the same project and none of the solutions here are working. There is a more detailed way to how this thing should be fixed? logging my webpack config it seems that postcss-loader is already in sourceMap: true.

also, there are some best practice on how to debug the preact.config.js file?

it's not strictly blocking but hot-reload isnt triggered, and messages regards post-css are quite annoying.

thanks

ok, solved, but since it was quite challenging for me I'm gonna share my solution(s)

// #1 disable SASS source maps
const sass = helpers.getLoadersByName(config, 'proxy-loader')[1];
sass.loader.options.options.sourceMap = false;
// yes, its 2 times "options" :/

// ----- OR -----

// #2 enable PostCSS source maps
const pcss = helpers.getLoadersByName(config, 'postcss-loader')[0];
pcss.loader.options.sourceMap = true;
Was this page helpful?
0 / 5 - 0 ratings