Skip to content
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

chore: Upgrade Webpack to v5 #16701

Merged
merged 21 commits into from
Sep 22, 2021
Merged

chore: Upgrade Webpack to v5 #16701

merged 21 commits into from
Sep 22, 2021

Conversation

kgabryje
Copy link
Member

@kgabryje kgabryje commented Sep 14, 2021

SUMMARY

What's been done:

  • Bump webpack from 4.42.0 to 5.52.1
  • Bump webpack-cli, webpack-dev-server, plugins and loaders to latest versions
  • Remove redundant plugins and loaders
  • Refactor webpack config file according to the migration guide (https://webpack.js.org/migrate/5/) and bumped plugins changelogs
  • Replace url-loaders and file-loaders with Asset Modules
  • Replace mathjs with math-expression-evaluator. Mathjs was causing an import error, but we've been using it in only 1 component (AnnotationLayer), so I replaced it instead of investigating the error. Pulling an 11MB lib just to parse 1 expression was a waste anyway

Next steps:

  • Bump other plugins (especially those marked by dependabot to be security vulnerabilities)
  • Attempt to simplify our webpack config file - it's quite complex and some parts of it might be unnecessary

BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF

no visual changes

TESTING INSTRUCTIONS

  1. Everything should build like before
  2. The whole app should work like before - verify that images, fonts, libs are getting loaded properly and there are no runtime errors anywhere
  3. Linking superset-ui libraries should work like before

ADDITIONAL INFORMATION

  • Has associated issue:
  • Required feature flags:
  • Changes UI
  • Includes DB Migration (follow approval process in SIP-59)
    • Migration is atomic, supports rollback & is backwards-compatible
    • Confirm DB migration upgrade and downgrade tested
    • Runtime estimates and downtime expectations provided
  • Introduces new feature or API
  • Removes existing feature or API

@codecov
Copy link

codecov bot commented Sep 14, 2021

Codecov Report

Merging #16701 (46595d2) into master (b92358b) will increase coverage by 0.00%.
The diff coverage is 81.25%.

Impacted file tree graph

@@           Coverage Diff           @@
##           master   #16701   +/-   ##
=======================================
  Coverage   76.98%   76.99%           
=======================================
  Files        1007     1007           
  Lines       54174    54180    +6     
  Branches     7463     7467    +4     
=======================================
+ Hits        41708    41714    +6     
  Misses      12226    12226           
  Partials      240      240           
Flag Coverage Δ
javascript 71.31% <81.25%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...c/visualizations/FilterBox/FilterBoxChartPlugin.js 75.00% <0.00%> (ø)
...c/visualizations/TimeTable/TimeTableChartPlugin.js 75.00% <0.00%> (ø)
...ontrols/AnnotationLayerControl/AnnotationLayer.jsx 83.84% <91.66%> (+0.43%) ⬆️
superset-frontend/src/components/Icons/Icon.tsx 100.00% <100.00%> (ø)
...rset-frontend/src/components/ListView/ListView.tsx 96.19% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update b92358b...46595d2. Read the comment docs.

@kgabryje kgabryje requested review from ktmud, rusackas, michael-s-molina, etr2460, suddjian and villebro and removed request for ktmud and rusackas September 14, 2021 13:47
@kgabryje
Copy link
Member Author

/testenv up

@github-actions
Copy link
Contributor

@kgabryje Ephemeral environment spinning up at http://35.163.128.192:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

Copy link
Member

@etr2460 etr2460 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

amazing, thanks for tackling this! let's let it soak for a couple days, but we can probably merge by EOW if no one has any concerns

@@ -129,7 +129,7 @@
"lodash": "^4.17.21",
"lodash-es": "^4.17.21",
"match-sorter": "^6.1.0",
"mathjs": "^8.0.1",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this will be a great perf win too!

superset-frontend/webpack.config.js Outdated Show resolved Hide resolved
@junlincc
Copy link
Member

/testenv up

@github-actions
Copy link
Contributor

@junlincc Ephemeral environment spinning up at http://54.200.57.4:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@junlincc
Copy link
Member

junlincc commented Sep 16, 2021

  1. export sample dashboard from homescreen is loading forever. double checked on production, working properly. not sure this is related to this PR, please confirm. also the file i downloaded is in JSON format, should be .zip instead
Screen.Recording.2021-09-16.at.11.15.38.AM.mov

@villebro
Copy link
Member

  1. export sample dashboard from homescreen is loading forever. double checked on production, working properly. not sure this is related to this PR, please confirm. also the file i downloaded is in JSON format, should be .zip instead

Screen.Recording.2021-09-16.at.11.15.38.AM.mov

I was able to repro this locally. This seems to be an unrelated bug affecting json exports, and I was able to repro this on master, too. Exporting zip files requires enabling the VERSIONED_EXPORT feature flag, and with this FF enabled exporting works as expected. I believe we should enable VERSIONED_EXPORT by default, as the legacy export feature appears to not work properly anymore.

Copy link
Member

@villebro villebro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some comments, but in general LGTM and seems to work great!

Comment on lines -28 to -31
let numScripts = 0;
cy.get('script').then(nodes => {
numScripts = nodes.length;
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: we should maybe update the test name to reflect the fact that we're testing the edit feature.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Comment on lines -29 to -32
xit('Should not load mathjs when not needed', () => {
cy.get('script[src*="mathjs"]').should('have.length', 0);
});

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note to other reviewers: we're fully removing mathjs as a dependency right now due to bundle size and compatibility problems with Webpack 5. Related PR removing mathjs from superset-ui: apache-superset/superset-ui#1362

Comment on lines -144 to -154
// clean up built assets if not from dev-server
if (!isDevServer) {
plugins.push(
new CleanWebpackPlugin({
dry: false,
// required because the build directory is outside the frontend directory:
dangerouslyAllowCleanPatternsOutsideProject: true,
}),
);
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this no longer needed? I remember this having been a problem before causing lots of accumulated old bundles in the build directory.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Webpack 5 has built-in cleaning capabilities. This line replaces the plugin:
image

@jinghua-qa
Copy link
Member

  1. export sample dashboard from homescreen is loading forever. double checked on production, working properly. not sure this is related to this PR, please confirm. also the file i downloaded is in JSON format, should be .zip instead

Screen.Recording.2021-09-16.at.11.15.38.AM.mov

Also saw loading forever issue when export datast
Screen Shot 2021-09-17 at 12 38 29 AM

@villebro
Copy link
Member

/testenv up FEATURE_DASHBOARD_NATIVE_FILTERS=true FEATURE_DASHBOARD_CROSS_FILTERS=true FEATURE_UX_BETA=true FEATURE_ENABLE_EXPLORE_DRAG_AND_DROP=true FEATURE_ENABLE_TEMPLATE_PROCESSING=true FEATURE_SQLLAB_BACKEND_PERSISTENCE=true

@github-actions
Copy link
Contributor

@villebro Ephemeral environment spinning up at http://34.219.36.79:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@villebro
Copy link
Member

/testenv up FEATURE_DASHBOARD_NATIVE_FILTERS=true FEATURE_DASHBOARD_CROSS_FILTERS=true FEATURE_UX_BETA=true FEATURE_ENABLE_EXPLORE_DRAG_AND_DROP=true FEATURE_ENABLE_TEMPLATE_PROCESSING=true FEATURE_SQLLAB_BACKEND_PERSISTENCE=true FEATURE_ENABLE_DND_WITH_CLICK_UX=true

@github-actions
Copy link
Contributor

@villebro Ephemeral environment spinning up at http://34.217.195.114:8080. Credentials are admin/admin. Please allow several minutes for bootstrapping and startup.

@kgabryje
Copy link
Member Author

@etr2460 Tests added. Would be great to improve them later with your real-life examples!
CC @villebro

@villebro villebro mentioned this pull request Sep 20, 2021
9 tasks
@junlincc junlincc removed hold! On hold hold:testing! On hold for testing test_priority:high labels Sep 20, 2021
@villebro villebro merged commit 486e0d4 into apache:master Sep 22, 2021
@github-actions
Copy link
Contributor

Ephemeral environment shutdown and build artifacts deleted.

opus-42 pushed a commit to opus-42/incubator-superset that referenced this pull request Nov 14, 2021
* Upgrade Webpack to v5

* Remove mapbox hack

* Replace url-loaders and file-loaders with asset modules

* Remove 1 rule

* Change --colors to --color

* Remove invalid option (--no-progress)

* Remove url-loader, bump plugin

* Fix AnnotationLayer formula check

* Remove redundant tests

* Bump cypress packages

* Remove old comment

* Fix tests

* Remove checks for number of scripts in markdown test

* Cosmetic changes

* Add tests

* Fix test

* Fix test

* Fixes test warnings

* disable flaky test

Co-authored-by: Ville Brofeldt <ville.v.brofeldt@gmail.com>
Co-authored-by: Michael S. Molina <michael.s.molina@gmail.com>
QAlexBall pushed a commit to QAlexBall/superset that referenced this pull request Dec 28, 2021
* Upgrade Webpack to v5

* Remove mapbox hack

* Replace url-loaders and file-loaders with asset modules

* Remove 1 rule

* Change --colors to --color

* Remove invalid option (--no-progress)

* Remove url-loader, bump plugin

* Fix AnnotationLayer formula check

* Remove redundant tests

* Bump cypress packages

* Remove old comment

* Fix tests

* Remove checks for number of scripts in markdown test

* Cosmetic changes

* Add tests

* Fix test

* Fix test

* Fixes test warnings

* disable flaky test

Co-authored-by: Ville Brofeldt <ville.v.brofeldt@gmail.com>
Co-authored-by: Michael S. Molina <michael.s.molina@gmail.com>
@mistercrunch mistercrunch added 🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels 🚢 1.4.0 labels Mar 13, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🏷️ bot A label used by `supersetbot` to keep track of which PR where auto-tagged with release labels size/L 🚢 1.4.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants