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(webpack): first pass on better webpack build #7038

Open
wants to merge 30 commits into
base: master
Choose a base branch
from

Conversation

evenstensberg
Copy link
Contributor

@evenstensberg evenstensberg commented Sep 6, 2023

#6964

Describe your changes:

This PR covers the initial work on a better configuration for the openMCT application. It's a restructural change to the existing configurations along with some improvements in the build itself.

All Submissions:

  • Have you followed the guidelines in our Contributing document?
  • Have you checked to ensure there aren't other open Pull Requests for the same update/change?
  • Is this change backwards compatible? For example, developers won't need to change how they are calling the API or how they've extended core plugins such as Tables or Plots.

Author Checklist

  • Changes address original issue?
  • Tests included and/or updated with changes?
  • Command line build passes?
  • Has this been smoke tested?
  • Testing instructions included in associated issue OR is this a dependency/testcase change?

Reviewer Checklist

  • Changes appear to address issue?
  • Reviewer has tested changes by following the provided instructions?
  • Changes appear not to be breaking changes?
  • Appropriate automated tests included?
  • Code style and in-line documentation are appropriate?
  • Has associated issue been labelled unverified? (only applicable if this PR closes the issue)
  • Has associated issue been labelled bug? (only applicable if this PR is for a bug fix)

@evenstensberg
Copy link
Contributor Author

@unlikelyzero test this thoroughly with both production and development builds. Have tested it with devServer but you need to make sure it doesnt break anything on your end.

@deploysentinel
Copy link

deploysentinel bot commented Sep 6, 2023

Current Playwright Test Results Summary

✅ 162 Passing - ⚠️ 2 Flaky

Run may still be in progress, this comment will be updated as current testing workflow or job completes...

(Last updated on 12/09/2023 03:33:10pm UTC)

Run Details

Running Job e2e-stable on CircleCI

Commit: 6b679d7

Started: 12/09/2023 03:27:04pm UTC

⚠️ Flakes

📄   functional/plugins/notebook/restrictedNotebook.e2e.spec.js • 2 Flakes

Top 1 Common Error Messages

null

2 Test Cases Affected

Test Case Results

Test Case Last 7 days Failures Last 7 days Flakes
Restricted Notebook with a page locked and with an embed @addinit Allows embeds to be deleted if page unlocked @addinit
Retry 1Initial Attempt
0% (0) 0 / 39 runs
failed over last 7 days
56.41% (22) 22 / 39 runs
flaked over last 7 days
Restricted Notebook with a page locked and with an embed @addinit Disallows embeds to be deleted if page locked @addinit
Retry 1Initial Attempt
2.56% (1) 1 / 39 run
failed over last 7 days
41.03% (16) 16 / 39 runs
flaked over last 7 days

View Detailed Build Results


@codecov
Copy link

codecov bot commented Sep 6, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 55.98%. Comparing base (28bfc90) to head (6b679d7).
Report is 217 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #7038      +/-   ##
==========================================
- Coverage   56.07%   55.98%   -0.10%     
==========================================
  Files         654      655       +1     
  Lines       26228    26251      +23     
  Branches     2528     2528              
==========================================
- Hits        14707    14696      -11     
- Misses      10825    10852      +27     
- Partials      696      703       +7     
Flag Coverage Δ *Carryforward flag
e2e-full 41.87% <ø> (-0.06%) ⬇️ Carriedforward from 1e9f055
e2e-stable 58.25% <ø> (-0.09%) ⬇️
unit 49.29% <ø> (-0.09%) ⬇️

*This pull request uses carry forward flags. Click here to find out more.

Files with missing lines Coverage Δ
src/utils/testing.js 76.41% <ø> (ø)

... and 13 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

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

@unlikelyzero
Copy link
Collaborator

unlikelyzero commented Sep 6, 2023

@evenstensberg hey this is great! Before we dive into the structure of it, can you spend one or two cycles figuring out why the tests are failing?

@evenstensberg
Copy link
Contributor Author

@unlikelyzero ok now? PTAL

@evenstensberg
Copy link
Contributor Author

@unlikelyzero what do you think of a dev setup with prod + dev builds that runs openmct locally (with unique bundles and chunks), and for customers, you'll have an unique build that only generates one bundle (dependency following your grammar) per entry?

@ozyx
Copy link
Contributor

ozyx commented Sep 11, 2023

@evenstensberg If I run build:dev and do npm start, I get an infinite spinner. Seems only the prod build is functional at this point?

@unlikelyzero unlikelyzero added the source:community Community contribution or request label Sep 11, 2023
Copy link
Contributor

@ozyx ozyx left a comment

Choose a reason for hiding this comment

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

Looking good so far! I've just left a couple questions for you.

BTW, I converted the original issue linked to this PR to a discussion as it seemed to fit better on the discussion board. Could you please create a new issue identifying the enhancements needed for our webpack config and then link it to this PR? Please then update the PR description with details about your implementation.

.webpack/webpack.dev.js Show resolved Hide resolved
.webpack/webpack.dev.js Outdated Show resolved Hide resolved
.webpack/webpack.prod.js Outdated Show resolved Hide resolved
@evenstensberg
Copy link
Contributor Author

@evenstensberg If I run build:dev and do npm start, I get an infinite spinner. Seems only the prod build is functional at this point?

I'll have a look. I enabled progress bar (progressplugin) for dev, so you can see progress. For prod I didn't use it so you save a bit on ci logging $$$

@evenstensberg
Copy link
Contributor Author

@evenstensberg If I run build:dev and do npm start, I get an infinite spinner. Seems only the prod build is functional at this point?

Have reproduced this, and is because we don't generate a css file in dev anymore. I'll check if there's a workaround without using miniextractcss in dev builds.

@evenstensberg
Copy link
Contributor Author

@ozyx Added a temp workaround. Suggestions to your build below (you need to discuss this with the team).

  1. We can have your own configuration file that bundles css, but it doesn't differ when you do this in dev/prod builds
  2. (Optimal) You can use gulp to generate your global css files (themes).

In one of my previous projects, we bundled all global stylesheets with gulp so that the webpack build step is somewhat isolated from generating your global stylesheets or dependencies.

@evenstensberg evenstensberg requested a review from ozyx September 17, 2023 18:36
@ozyx
Copy link
Contributor

ozyx commented Sep 22, 2023

@evenstensberg Sorry for the delay in reviewing this, we've been busy wrapping up a release. I'm going to take a look at this today. Thanks for your patience!

@ozyx
Copy link
Contributor

ozyx commented Sep 26, 2023

  1. (Optimal) You can use gulp to generate your global css files (themes).

Hmm. I rather like the idea of keeping this modular. Let me discuss this with the team.

Copy link
Contributor Author

@evenstensberg evenstensberg left a comment

Choose a reason for hiding this comment

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

@ozyx want me to rebase?

@ozyx
Copy link
Contributor

ozyx commented Oct 15, 2023

@ozyx want me to rebase?

That'd be great!

@evenstensberg
Copy link
Contributor Author

@ozyx PTAL

Copy link
Collaborator

@unlikelyzero unlikelyzero left a comment

Choose a reason for hiding this comment

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

Please remove any detection of the NODE_ENV variable

.webpack/webpack.base.js Outdated Show resolved Hide resolved
.webpack/webpack.base.js Outdated Show resolved Hide resolved
.webpack/webpack.prod.js Outdated Show resolved Hide resolved
Copy link
Contributor

@ozyx ozyx left a comment

Choose a reason for hiding this comment

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

Looking good. Still need to do some cursory testing-- just a couple of changes requested for now

.webpack/webpack.dev.js Outdated Show resolved Hide resolved
.webpack/webpack.dev.js Show resolved Hide resolved
@evenstensberg evenstensberg requested a review from ozyx October 21, 2023 09:37
@evenstensberg
Copy link
Contributor Author

ptal @ozyx

Copy link
Contributor

@ozyx ozyx left a comment

Choose a reason for hiding this comment

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

Please address the test failures

@evenstensberg

This comment was marked as outdated.

@evenstensberg
Copy link
Contributor Author

PTAL @ozyx

@evenstensberg evenstensberg mentioned this pull request Nov 18, 2023
15 tasks
Copy link
Contributor

@ozyx ozyx left a comment

Choose a reason for hiding this comment

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

We're getting closer. I left some comments regarding the minimization options that were chosen here. The goal is to get the bundle size as small as possible with as least aggressive minimization options as possible.

.webpack/webpack.prod.js Outdated Show resolved Hide resolved
.webpack/webpack.prod.js Outdated Show resolved Hide resolved
.webpack/webpack.prod.js Outdated Show resolved Hide resolved
.webpack/webpack.prod.js Outdated Show resolved Hide resolved
src/plugins/URLIndicatorPlugin/URLIndicatorSpec.js Outdated Show resolved Hide resolved
Comment on lines 75 to 86
warnings: false,
parse: {
html5_comments: false
},
mangle: true,
module: false,
toplevel: false,
nameCache: null,
ie8: false,
keep_classnames: false,
keep_fnames: false,
safari10: false
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to be very careful here as we see more e2e test flakes and odd behavior with some of these options.

What's the least aggressive we can be with minimization optimization while also shrinking the bundle size as much as possible? In my experiments I found we should be able to shrink openmct.js from ~35MB to ~5MB. If we can get close to that with mostly default settings, we should opt for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that you'll need to manually test each of these settings, and enable/disable yourself to customize the fine-grained optimizations to your build.

@evenstensberg
Copy link
Contributor Author

@ozyx PTAL. left a comment on the remaining optimization strategies.

Use the default options provided by terser
@evenstensberg
Copy link
Contributor Author

@ozyx I removed the options in the terser plugin. Just use defaults for now. PTAL

},
{
loader: 'sass-loader',
// resolve-url-loader needs all loaders below its decl to have sourcemaps enabled
Copy link
Collaborator

Choose a reason for hiding this comment

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

nice

Copy link
Collaborator

@unlikelyzero unlikelyzero left a comment

Choose a reason for hiding this comment

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

Thanks for the updates. Will defer to @ozyx for remaining scope

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
source:community Community contribution or request type:maintenance tests, chores, or project maintenance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants