TehShrike / svelte-preprocess-postcss

Use PostCSS to preprocess your styles in Svelte components

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Breaks if --config was used on command line

RedHatter opened this issue · comments

If this preprocessor gets executed with a command having the --config argument (e.g. rollup --config) I get the following error.

TypeError [ERR_INVALID_ARG_TYPE]: The "path" argument must be of type string. Received type boolean
    at assertPath (path.js:39:11)
    at Object.resolve (path.js:1090:7)
    at module.exports (/home/timothy/Projects/svelte-material-ui/node_modules/cosmiconfig/index.js:23:31)
    at postcssrc (/home/timothy/Projects/svelte-material-ui/node_modules/postcss-load-config/index.js:48:10)
    at module.exports (/home/timothy/Projects/svelte-material-ui/node_modules/svelte-preprocess-postcss/index.js:10:25)
    at Object.<anonymous> (/home/timothy/Projects/svelte-material-ui/rollup.config.js:25:16)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.require.extensions..js (/home/timothy/Projects/svelte-material-ui/node_modules/rollup/bin/rollup:1271:24)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)

huh, I can't imagine how that would happen. postcss-load-config doesn't look at process.argv. Can you paste some more details, maybe your rollup/svelte config?

It doesn't require rollup to reproduce. See the following example

const postcss = require('svelte-preprocess-postcss')
const svelte = require('svelte')

svelte.preprocess(`
<style>
  span {
    color: red;
  }
</style>
`, {
  style: postcss()
}).then(console.log)

run with

 node index.js --config

While postcss-load-config doesn't look at process.argv the version of cosmiconfig that it uses (2.1.0) does. See index.js#L23

d'oh. That's dumb.

It looks like options are passed straight through from postcss-load-config to cosmiconfig, so passing in argv: false on the options object would probably fix it.

I wonder if that change should be made in postcss-load-config... that seems like bad default behavior