question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Unexpected Webpack2 `use` merge

See original GitHub issue

Given the following merge:

merge.smart({
  rules: [{
    test: /\.js$/,
    use: 'babel'
  }]
}, {
  rules: [{
    test: /\.js$/,
    use: 'coffee'
  }]
});

I would expect the following according to the what the Webpack1 examples seem to suggest in the README:

{
  rules: [{
    test: /\.js$/,
    use: 'coffee'
  }]
}

Instead I get:

{
  rules: [{
    test: /\.js$/,
    use: ['babel','coffee']
  }]
}

There doesn’t seem to be a way to overwrite a string value in use as it always gets converted to an array and merged.

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:12 (8 by maintainers)

github_iconTop GitHub Comments

4reactions
bebrawcommented, Jan 26, 2017

I made a little fix. I think you should be able to use

const output = merge.smartStrategy(
  {
    'module.rules.use': 'replace'
  })(common, prod);

now to achieve the behavior you described.

Let’s leave this issue open for now, though, as this needs careful thought. It would be tempting to drop smart merging in 3.0 as it’s strategies that are valuable, not folding.

1reaction
bebrawcommented, Jan 26, 2017

@bmayen Ok, I’ll check that tomorrow. There’s something else biting. use is definitely complex to handle.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Webpack unexpected token - Urigo/merge-graphql-schemas
I am using Webpack to compile, running into an issue when trying to call fileLoader on types directory.. Webpack config const path =...
Read more >
Getting error when running npm-run after git merging conflicts
I get the following error when I run npm run watch/npm run dev after a git merge where I resolved some conflicts manually:....
Read more >
Webpack isn't noticing your file changes. Did you do ...
You're suffering from a stale file cache. And I have great news: it's easy to diagnose and even easier to resolve. Don't delete...
Read more >
"[webpack] 'dist': web-part.js from UglifyJs Unexpected token ...
We were using all the latest npm packages in the web part and the web part was also working in ... const merge...
Read more >
Code Splitting - webpack
Entry Points: Manually split code using entry configuration. ... Let's take a look at how we might split another module from the main...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found