Update diff to 4.0.2 and work around tree-shaking issues#21994
Update diff to 4.0.2 and work around tree-shaking issues#21994
Conversation
|
An added note: I checked the notes for the release, and it doesn't look like there were any breaking changes that concern us on the move from 3 to 4. |
|
Size Change: -5.87 kB (0%) Total Size: 819 kB
ℹ️ View Unchanged
|
Reference: https://github.com/kpdecker/jsdiff/blob/master/release-notes.md#v400---january-5th-2019 |
According to Bundlephobia, because it doesn't declare diff --git a/webpack.config.js b/webpack.config.js
index 340728cfe1..b2a8f962ee 100644
--- a/webpack.config.js
+++ b/webpack.config.js
@@ -5,7 +5,7 @@ const { DefinePlugin } = require( 'webpack' );
const CopyWebpackPlugin = require( 'copy-webpack-plugin' );
const postcss = require( 'postcss' );
const { get, escapeRegExp, compact } = require( 'lodash' );
-const { basename, sep } = require( 'path' );
+const { basename, sep, resolve } = require( 'path' );
/**
* WordPress dependencies
@@ -54,6 +54,10 @@ module.exports = {
},
module: {
rules: compact( [
+ {
+ include: resolve( 'node_modules', 'diff' ),
+ sideEffects: false,
+ },
mode !== 'production' && {
test: /\.js$/,
use: require.resolve( 'source-map-loader' ),With or without this change, I see 390kb for |
Thanks for looking into this, @aduth! It appears that the library has some more fundamental issues than just a missing Here are some experiments, with
The latter doesn't need |
|
Rebased on Edit: Looking at the updated results, that does appear to be the case. They make a lot more sense now. |
|
I'm not sure why the |
I can see local changes, but only after first removing diff --git a/package-lock.json b/package-lock.json
index 172654b86d..5905049454 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -31146,9 +31146,9 @@
}
},
"mkdirp-classic": {
- "version": "0.5.2",
- "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.2.tgz",
- "integrity": "sha512-ejdnDQcR75gwknmMw/tx02AuRs8jCtqFoFqDZMjiNxsu85sRIJVXDKHuLYvUUPRBUtV2FpSZa9bL1BUa3BdR2g==",
+ "version": "0.5.3",
+ "resolved": "https://registry.npmjs.org/mkdirp-classic/-/mkdirp-classic-0.5.3.tgz",
+ "integrity": "sha512-gKLcREMhtuZRwRAfqP3RFW+TK4JqApVBtOIftVgjuABpAtpxhPGaDcfvbhNvD0B8iD1oUr/txX35NjcaY6Ns/A==",
"dev": true
},
"mkdirp-promise": { |
|
@aduth I had the same issue, I commited this change to master |
The 3.x.x version range is no longer getting any updates.
|
Thanks, @youknowriad! I rebased on |
|
Everything looks green now 👍 Since I'm working around tree-shaking issues as well now, I'm re-requesting a review in case you want to take another look, @aduth |
aduth
left a comment
There was a problem hiding this comment.
Still appears to work well in testing 👍
|
Thank you for the reviews, @aduth! 👍 |
Description
Update the
diffdependency to4.0.2or later, as the 3.x.x version range is no longer getting any updates.The PR also works around tree-shaking issues in the library, which results in a substantial improvement in bundle size. Bumping the version will also allow for the Gutenboarding project in Calypso to not require its own copy of
diff.How has this been tested?
Unit tests and ad-hoc testing of this functionality. To test:
Types of changes
Dependency update only; no code changes.
Checklist: