Skip to content

webpack-merge v5 #491

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed

webpack-merge v5 #491

wants to merge 3 commits into from

Conversation

bpinto
Copy link

@bpinto bpinto commented Aug 18, 2021

  • Upgrades webpack-merge to latest.
  • Add a test covering plugins merge.

Disclaimer: I did not reimplement merge.smart because we may not need it. I thought it would be better to keep it simple and in case someone has a special need then we work on the code to handle that instead of potentially add unnecessary code.

@bpinto bpinto mentioned this pull request Aug 18, 2021
1 task
@erezrokah erezrokah added the type: feature code contributing to the implementation of a feature and/or user facing functionality label Aug 18, 2021
@bpinto
Copy link
Author

bpinto commented Aug 18, 2021

@erezrokah I noticed I hadn't run npm run format before pushing, now I've done it. Could you allow the workflow to run again? Thank you!

@bpinto
Copy link
Author

bpinto commented Aug 31, 2021

@erezrokah have you had the time to review this PR? Is there any change you would like to see me doing?

@erezrokah
Copy link
Contributor

Hi @bpinto, sorry for the delay here - can you detail the changes between merge and merge.smart?
This might be a breaking change (as well as #492) so we'll need to put it under a major version bump

@bpinto
Copy link
Author

bpinto commented Sep 1, 2021

I'll share some links that explain how merge.smart used to work, as it's useful to see the examples.

This is the commit that removed merge.smart method from webpack-merge library.

This is the docs for the removed method:

webpack-merge tries to be smart about merging loaders when merge.smart is used. Loaders with matching rule fields, including test/enforce/include/exclude, will be merged into a single loader value.

The standard webpack configuration that is used is very simple:

netlify-lambda/lib/build.js

Lines 137 to 177 in 2493319

var webpackConfig = {
mode: webpackMode,
resolve: {
extensions: ['.wasm', '.mjs', '.js', '.json', '.ts'],
mainFields: ['module', 'main'],
},
module: {
rules: [
{
test: /\.(m?js|ts)?$/,
exclude: new RegExp(
`(node_modules|bower_components|${testFilePattern})`,
),
use: {
loader: require.resolve('babel-loader'),
options: { ...babelOpts, babelrc: useBabelrc },
},
},
],
},
context: dirPath,
entry: {},
target: 'node',
plugins: [
new webpack.IgnorePlugin(/vertx/),
new webpack.DefinePlugin(defineEnv),
],
output: {
path: functionsPath,
filename: '[name].js',
libraryTarget: 'commonjs',
},
optimization: {
nodeEnv,
},
bail: true,
devtool: false,
stats: {
colors: true,
},
};

The only option I thought we could have an issue with the basic merge was the module.rules however since we support a custom babelrc file I think that's not a problem. As far as I could see, we did not need the smart merge. That said, it's possible I've missed something and in that case we would need to tweak the merge strategy to handle any incompatibility issue that may arise.

The only change I can think of is that it's now not possible to disable the babel-loader, but then not sure why someone would be using netlify-lambda if they don't want webpack + babel.

By bumping the major version, I think that possible backwards incompatibility problem is reduced as most projects using this won't have issues after running a regular npm update.

@bpinto
Copy link
Author

bpinto commented Sep 1, 2021

P.S.: I've rebased code on top of latest main.

@bpinto
Copy link
Author

bpinto commented Sep 9, 2021

@erezrokah Sorry to ping you, but I'd love to see this PR merged :)

@bpinto
Copy link
Author

bpinto commented Oct 12, 2021

Any news? Thank you!

@bpinto
Copy link
Author

bpinto commented Nov 16, 2021

Any updates?

@laurentlaporte
Copy link

Why is this not merged?

bpinto added 3 commits April 4, 2022 12:31
It's not a direct replacement, however this may cover all the needs. If
needed, we can work on the merge strategy.

Jest has a file system cache that is not cleared, not even using
`jest.resetModules()`. As a workaround, we create the webpack config
files with a unique suffix.

Ref:
jestjs/jest#11426 (comment)
@bpinto bpinto force-pushed the webpack-merge-v5 branch from 4a5b7cd to 2762461 Compare April 4, 2022 11:31
@danez
Copy link
Contributor

danez commented Feb 13, 2023

We are deprecating netlify-lambda and therefore won't need this PR anymore. Thanks for your contributions and sorry it wasn't used.

@danez danez closed this Feb 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: feature code contributing to the implementation of a feature and/or user facing functionality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants