neutrinojs / neutrino

Create and build modern JavaScript projects with zero initial configuration.
https://neutrinojs.org
Mozilla Public License 2.0
3.95k stars 214 forks source link

Named loader override from package.json throws without the loader key #61

Closed torifat closed 7 years ago

torifat commented 7 years ago
{
  "config": {
    "presets": [
      "neutrino-preset-react"
    ],
    "neutrino": {
      "module": {
        "rule": {
          "css": {
            "loader": {
              "css": {
                "options": {
                  "modules": true
                }
              }
            }
          }
        }
      }
    }
  }
}

Here's the stack-trace:

⠋ Starting development serverError: No loader specified
    at Function.normalizeUseItem (<ROOT_PATH>/node_modules/webpack/lib/RuleSet.js:265:9)
    at Function.normalizeUse (<ROOT_PATH>/node_modules/webpack/lib/RuleSet.js:227:18)
    at use.map (<ROOT_PATH>/node_modules/webpack/lib/RuleSet.js:223:41)
    at Array.map (native)
    at Function.normalizeUse (<ROOT_PATH>/node_modules/webpack/lib/RuleSet.js:223:14)
    at Function.RuleSet.normalizeRule (<ROOT_PATH>/node_modules/webpack/lib/RuleSet.js:174:25)
    at <ROOT_PATH>/node_modules/webpack/lib/RuleSet.js:84:19
    at Array.map (native)
    at Function.RuleSet.normalizeRules (<ROOT_PATH>/node_modules/webpack/lib/RuleSet.js:83:16)
    at new RuleSet (<ROOT_PATH>/node_modules/webpack/lib/RuleSet.js:76:23)
    at new NormalModuleFactory (<ROOT_PATH>/node_modules/webpack/lib/NormalModuleFactory.js:46:17)
    at Compiler.createNormalModuleFactory (<ROOT_PATH>/node_modules/webpack/lib/Compiler.js:439:28)
    at Compiler.newCompilationParams (<ROOT_PATH>/node_modules/webpack/lib/Compiler.js:452:29)
    at Compiler.compile (<ROOT_PATH>/node_modules/webpack/lib/Compiler.js:461:20)
    at <ROOT_PATH>/node_modules/webpack/lib/Compiler.js:45:17
    at next (<ROOT_PATH>/node_modules/tapable/lib/Tapable.js:138:11)
    at Compiler.compilerInvalid (<ROOT_PATH>/node_modules/webpack-dev-middleware/lib/Shared.js:144:5)
    at next (<ROOT_PATH>/node_modules/tapable/lib/Tapable.js:140:14)
    at Compiler.compiler.plugin (<ROOT_PATH>/node_modules/webpack/lib/CachePlugin.js:32:5)
    at Compiler.applyPluginsAsyncSeries (<ROOT_PATH>/node_modules/tapable/lib/Tapable.js:142:13)
    at Watching._go (<ROOT_PATH>/node_modules/webpack/lib/Compiler.js:43:16)
    at Watching.<anonymous> (<ROOT_PATH>/node_modules/webpack/lib/Compiler.js:34:8)
error Command failed with exit code 1.
eliperelman commented 7 years ago

This should now be fixed in neutrino@v4.2.1. Thanks!

torifat commented 7 years ago

Sadly it's not fixed yet for me 😢

screenshot 2017-02-27 17 27 17
eliperelman commented 7 years ago

@torifat could you maybe share an updated package.json? I tested this change to package.json locally and it worked for me. To confirm, I added a file called override.js, added it my presets, and put the following code in it to ensure the value was loaded:

package.json

"scripts": {
  "start": "neutrino start"
},
"dependencies": {
  "neutrino": "^4.2.1",
  "neutrino-preset-react": "^4.2.0",
  "react": "^15.4.2",
  "react-dom": "^15.4.2"
},
"config": {
  "presets": [
    "neutrino-preset-react",
    "override.js"
  ],
  "neutrino": {
    "module": {
      "rule": {
        "css": {
          "loader": {
            "css": {
              "options": {
                "modules": true
              }
            }
          }
        }
      }
    }
  }
}

override.js

module.exports = neutrino => {
  neutrino.on('prestart', () => {
    console.log(neutrino.config.module.rule('css').loaders.get('css').options);
    process.exit(0);
  });
};

console

❯ yarn start
yarn start v0.20.3
$ neutrino start
{ modules: true }
✨  Done in 1.13s.