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@5 to fix CI builds #6509

Closed
wants to merge 1 commit into from

Conversation

adunkman
Copy link

@adunkman adunkman commented Jul 6, 2022

Summary

Upgrades Webpack to version 5 to fix #6502, which is preventing successful builds due to an interaction between Webpack 4 and Node versions 17 and above.

Test plan

Tests ran locally and had one failure with yarn test:all. Unfortunately, it appears tests are also not functioning in CI, as Cypress is timing out waiting for the test server to boot on 18F’s fork.

1 test failure in editorial_workflow_migration_spec_github_backend_rest.js
  Running:  editorial_workflow_migration_spec_github_backend_rest.js                       (1 of 43)
Browserslist: caniuse-lite is outdated. Please run:
npx browserslist@latest --update-db

Why you should do it regularly:
https://github.com/browserslist/browserslist#browsers-data-updating


  Github Backend Editorial Workflow Migration - REST API
Preparing environment for backend github
Running tests in "playback" mode - local data with be used
Setting up single test 'migrate from 2.9.7 to latest' for backend github
Seeding repository for backend github
Switching CMS to version '2.9.7'
[2022-07-05T14:21:05.333Z]  "GET /" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/103.0.5060.53 Safari/537.36"
[2022-07-05T14:21:10.504Z]  "GET /config.yml" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/103.0.5060.53 Safari/537.36"
    (Attempt 1 of 3) migrate from 2.9.7 to latest
Tearing down single test 'migrate from 2.9.7 to latest' for backend github
Setting up single test 'migrate from 2.9.7 to latest' for backend github
Seeding repository for backend github
Switching CMS to version '2.9.7'
[2022-07-05T14:21:19.099Z]  "GET /" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/103.0.5060.53 Safari/537.36"
[2022-07-05T14:21:19.344Z]  "GET /config.yml" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/103.0.5060.53 Safari/537.36"
[2022-07-05T14:21:19.379Z]  "GET /" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/103.0.5060.53 Safari/537.36"
[2022-07-05T14:21:19.441Z]  "GET /config.yml" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/103.0.5060.53 Safari/537.36"
    (Attempt 2 of 3) migrate from 2.9.7 to latest
Tearing down single test 'migrate from 2.9.7 to latest' for backend github
Setting up single test 'migrate from 2.9.7 to latest' for backend github
Seeding repository for backend github
Switching CMS to version '2.9.7'
[2022-07-05T14:21:27.968Z]  "GET /" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/103.0.5060.53 Safari/537.36"
[2022-07-05T14:21:28.073Z]  "GET /" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/103.0.5060.53 Safari/537.36"
[2022-07-05T14:21:28.139Z]  "GET /config.yml" "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) HeadlessChrome/103.0.5060.53 Safari/537.36"
    1) migrate from 2.9.7 to latest

  0 passing (31s)
  1 failing

  1) Github Backend Editorial Workflow Migration - REST API
       migrate from 2.9.7 to latest:
     AssertionError: Timed out retrying after 5000ms: Expected to find content: 'Entry saved' but never did.
      at Context.eval (http://localhost:8080/__cypress/tests?p=cypress/integration/editorial_workflow_migration_spec_github_backend_rest.js:765:8)



Tearing down single test 'migrate from 2.9.7 to latest' for backend github

  (Results)

  ┌────────────────────────────────────────────────────────────────────────────────────────────────┐
  │ Tests:        2                                                                                │
  │ Passing:      0                                                                                │
  │ Failing:      1                                                                                │
  │ Pending:      0                                                                                │
  │ Skipped:      1                                                                                │
  │ Screenshots:  3                                                                                │
  │ Video:        true                                                                             │
  │ Duration:     31 seconds                                                                       │
  │ Spec Ran:     editorial_workflow_migration_spec_github_backend_rest.js                         │
  └────────────────────────────────────────────────────────────────────────────────────────────────┘
editorial_workflow_migration_spec_github_backend_rest.js.mp4

What I’ve been able to gather:

  • At this stage of the test, v2.9.7 of netlify-cms is loaded from unpkg.com.
  • The test is failing during the setup phase, when it is creating a mocked entry.
  • Given that this pull request does not modify code from unpkg.com, does not modify mocked entries, and does not modify mocked responses, it does not seem likely that this pull request introduces this failure.

I’d appreciate assistance if a contributor understands why this test may be failing. ❤️


Checklist

Please add a x inside each checkbox:

  • I have read the contribution guidelines.
  • Code is formatted via running yarn format.
  • Tests are passing via running yarn test.
  • The status checks are successful (continuous integration). Those can be seen below. (awaiting PR, but likely failing due to above mentioned issue with Cypress).

Fresh photo of Toulouse, for y’all! 🙂 More on #6498.

Photo of a Russian Blue and Domestic Shorthair cat mix, laying scrunched up on a windowsill in the sun. He is looking backwards over his left shoulder, wondering why he was interrupted from watching birds in the tree outside the window. He is wearing a rainbow collar.

@adunkman adunkman requested a review from a team July 6, 2022 23:24
@@ -1,7 +1,7 @@
const path = require('path');
require('dotenv').config({ path: path.join(__dirname, '..', '..', '.env') });
const webpack = require('webpack');
const FriendlyErrorsWebpackPlugin = require('friendly-errors-webpack-plugin');
const FriendlyErrorsWebpackPlugin = require('@soda/friendly-errors-webpack-plugin');
Copy link
Author

@adunkman adunkman Jul 6, 2022

Choose a reason for hiding this comment

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

  • friendly-errors-webpack-plugin does not support webpack@5 and is archived on GitHub.
  • @soda/friendly-errors-webpack-plugin is a fork which supports webpack@5.

new webpack.IgnorePlugin({
resourceRegExp: /^\.\/locale$/,
contextRegExp: /moment$/,
}),
Copy link
Author

Choose a reason for hiding this comment

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

The syntax for IgnorePlugin changed (new documentation):

If you are using IgnorePlugin with a regular expression as argument, it takes an options object now: new IgnorePlugin({ resourceRegExp: /regExp/ }).

new webpack.ProvidePlugin({
Buffer: ['buffer', 'Buffer'],
process: 'process',
}),
Copy link
Author

Choose a reason for hiding this comment

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

Webpack 5 no longer includes automatic polyfills for Node.js:

In the early days, webpack's aim was to allow running most Node.js modules in the browser, but the module landscape changed and many module uses are now written mainly for frontend purposes. Webpack <= 4 ships with polyfills for many of the Node.js core modules, which are automatically applied once a module uses any of the core modules (i.e. the crypto module).

While this makes using modules written for Node.js easier, it adds these huge polyfills to the bundle. In many cases these polyfills are unnecessary.

Webpack 5 stops automatically polyfilling these core modules and focus on frontend-compatible modules. Our goal is to improve compatibility with the web platform, where Node.js core modules are not available.

It's possible to manually add a polyfill for a Node.js core module. An error message will give a hint on how to achieve that.

This (and the below fallback configuration lines) follow those hints.

@stale
Copy link

stale bot commented Apr 26, 2023

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the status: stale label Apr 26, 2023
@martinjagodic
Copy link
Member

Dependencies are a mess right now, so they will be updated as part of a PR by maintainers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

CI builds are failing due to ERR_OSSL_EVP_UNSUPPORTED.
2 participants