-
Notifications
You must be signed in to change notification settings - Fork 31
babel-loader complains about syntax errors in code that should be removed #31
Copy link
Copy link
Open
Description
I have a .js file with an entry that looks like this:
{
text: 'link text',
/// #if CONDITION
url: 'url/if/true'
/// #else
url: 'url/if/false
/// #endif
}
I have tried setting up my webpack.config.js rules in a couple of different ways, neither of which is currently working:
webpackConfig.rules version 1
[
{ test: /\.(js|jsx)$/,
use: [ 'babel-loader' ],
exclude: /node_modules/ },
...
{ test: /\.(js|jsx)$/,
use: [{ loader: 'ifdef-loader', options: { CONDITION: false } } ],
exclude: /node_modules/ }
];
webpackConfig.rules version 2
[
{ test: /\.(js|jsx)$/,
use: [ 'babel-loader', { loader: 'ifdef-loader', options: { CONDITION: false } } ],
exclude: /node_modules/ },
...
];
What happens is the babel-loader complains about a missing comma on the url: 'url/if/true' line, when that line (or the other one, depending on the condition) should not even be getting to the babel-loader, if my understanding of loaders is correct.
exact errors look like this:
ERROR in SyntaxError: path\to\folder \file.js: Unexpected token, expected "," (linenumber)
I can see that the ifdef-loader appears to be getting applied correctly if I turn on verbose, but the babel-loader still fails after that.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels