sasstools / scss-tokenizer

A tokenzier for Sass' SCSS syntax
MIT License
24 stars 22 forks source link

Local .babelrc breaks scss-tokenizer #10

Closed nybblr closed 7 years ago

nybblr commented 7 years ago

I just clean installed node-sass (same patch version I think) and through a dependency of a dependency it now includes scss-tokenizer. I'm getting this cryptic error:

$ ./node_modules/.bin/node-sass

/Users/jonathan/my-app/node_modules/scss-tokenizer/node_modules/babel-core/lib/transformation/file/options/option-manager.js:126
      if (!option) this.log.error("Unknown option: " + alias + "." + key, ReferenceError);
                           ^

TypeError: Cannot read property 'error' of undefined
    at OptionManager.mergeOptions (/Users/jonathan/my-app/node_modules/scss-tokenizer/node_modules/babel-core/lib/transformation/file/options/option-manager.js:126:28)
    at OptionManager.addConfig (/Users/jonathan/my-app/node_modules/scss-tokenizer/node_modules/babel-core/lib/transformation/file/options/option-manager.js:107:10)
    at OptionManager.findConfigs (/Users/jonathan/my-app/node_modules/scss-tokenizer/node_modules/babel-core/lib/transformation/file/options/option-manager.js:168:35)
    at OptionManager.init (/Users/jonathan/my-app/node_modules/scss-tokenizer/node_modules/babel-core/lib/transformation/file/options/option-manager.js:229:12)
    at compile (/Users/jonathan/my-app/node_modules/scss-tokenizer/node_modules/babel-core/lib/api/register/node.js:117:22)
    at normalLoader (/Users/jonathan/my-app/node_modules/scss-tokenizer/node_modules/babel-core/lib/api/register/node.js:199:14)
    at Object.require.extensions.(anonymous function) [as .js] (/Users/jonathan/my-app/node_modules/scss-tokenizer/node_modules/babel-core/lib/api/register/node.js:216:7)
    at Module.load (module.js:487:32)
    at tryModuleLoad (module.js:446:12)
    at Function.Module._load (module.js:438:3)

I tried a few things, then nuked my local .babelrc config and node-sass worked. So my guess is scss-tokenizer is using my local .babelrc automatically?

Perhaps adding an explicit config to this package would prevent that?

nybblr commented 7 years ago

Ahh, this might also do the trick: https://babeljs.io/docs/usage/babelrc/#lookup-behavior

I'll test adding this option locally and see if it works.

nybblr commented 7 years ago

Ah, since this is using an older version of Babel, adding this to scss-tokenizer's package.json prevents the lookup behavior:

"babel": {
  "breakConfig": true
}

Quick PR, or is there another PR in progress that will fix this issue?

fozzle commented 7 years ago

Having the same issue. I have temporarily resolved it by forking node-sass to use a 2.1.1 dependency for sass-graph instead of ^2.1.1 . It appears sass-graph was updated yesterday and that's when this library as added as a dependency. The blessings and curses of the npm ecosystem :)

xzyfer commented 7 years ago

Thanks all. I unpublished sass-graph 2.2.0 but for some reason people were still getting it. Looks like there may be an issue for yarn users - https://github.com/yarnpkg/yarn/issues/3274

Testing #11 locally before publishing a new release.

xzyfer commented 7 years ago

Thanks all!