swc-loader icon indicating copy to clipboard operation
swc-loader copied to clipboard

Bad configuration should prevent compilation attempt

Open duncanbeevers opened this issue 6 years ago • 1 comments

If the config supplied to swc-loader is invalid, instead of running with defaults swc should warn the operator and halt compilation.

duncanbeevers avatar Jul 11 '19 06:07 duncanbeevers

This may no longer be an issue. When I use the following invalid config:

{
  loader: 'swc-loader',
  options: {
    module: {
      type: 'foo',
    },
  },
}

I get the error:

Module build failed (from ../node_modules/swc-loader/src/index.js):
Error: Failed to deserialize swc::config::Options from json string (`{"module":{"type":"foo"},"filename":"/path/to/myfile.js","sourceMaps":true,"sourceFileName":"/path/to/myfile.js"}`)

Caused by:
    unknown variant `foo`, expected one of `commonjs`, `umd`, `amd`, `es6` at line 1 column 175

meshulam avatar Jan 04 '22 23:01 meshulam