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

build(deps): remove babel-plugin-transform-es2015-modules-commonjs #7114

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

Conversation

eatyourgreens
Copy link
Contributor

@eatyourgreens eatyourgreens commented May 31, 2024

Remove babel-plugin-transform-es2015-modules-commonjs, which is 6 years out-of-date and no longer supported. It generates security warnings in the console, because of outdated dependencies on babel-traverse (also 6 years out-of-date and not supported in Babel 7.)

You can test this locally a couple of ways:

  • npm start: development React build with hot module reloading and React debugging errors in the console.
  • npm run serve-static: build the production bundle with Webpack, and serve it on http://localhost:3735 or http://local.zooniverse.org:3735. This method reproduces a production deploy, but without the nginx reverse proxy.

npm audit and npm ci should show 0 problems, with the changes here.

Screenshot of the install log, from a build, showing 0 vulnerabilities.

Required Manual Testing

  • Does the non-logged in home page render correctly?
  • Does the logged in home page render correctly?
  • Does the projects page render correctly?
  • Can you load project home pages?
  • Can you load the classification page?
  • Can you submit a classification?
  • Does talk load correctly?
  • Can you post a talk comment?

Review Checklist

  • Does it work in all major browsers: Firefox, Chrome, Edge, Safari?
  • Does it work on mobile?
  • Can you npm ci and app works as expected?
  • If the component is in coffeescript, is it converted to ES6? Is it free of eslint errors? Is the conversion its own commit?
  • Are the tests passing locally and on GitHub Actions?

Optional

@coveralls
Copy link

coveralls commented May 31, 2024

Coverage Status

coverage: 56.954% (+0.3%) from 56.684%
when pulling 9ceeeb3 on eatyourgreens:remove-babel-cjs-plugin
into 8ad3b19 on zooniverse:master.

@@ -125,7 +124,7 @@
"start": "export NODE_ENV=development; check-engines && check-dependencies && webpack-dashboard -p 3736 -- webpack-dev-server --config ./webpack.dev.js",
"_build": "export HEAD_COMMIT=$(git rev-parse --short HEAD); check-engines && check-dependencies && rimraf dist; webpack --config ./webpack.build.js --progress --color",
"build-production": "export NODE_ENV=production; npm run _build",
"serve-static": "export NODE_ENV=staging; check-engines && check-dependencies && npm run _build && node ./static-server.js",
"serve-static": "npm ci; export NODE_ENV=production; check-engines && check-dependencies && npm run _build && node ./static-server.js",
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Noting here that staging is an invalid value for NODE_ENV in modern Webpack builds. See https://webpack.js.org/configuration/mode/.

@@ -1,6 +1,7 @@
module.exports = function (api) {
api.cache(true);
return {
sourceType: 'module',
Copy link
Contributor Author

@eatyourgreens eatyourgreens May 31, 2024

Choose a reason for hiding this comment

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

See https://babeljs.io/docs/options#sourcetype. ESM is the default for Babel 7.

<Route path=':locale'>
{SLUGS.map(slug => <MonorepoRoute path={slug} />)}
{SLUGS.map(slug => <MonorepoRoute key={slug} path={slug} />)}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not really related to the other changes here, but the missing key warnings made real React errors harder to spot while I was chasing down a couple of bugs in this PR. So this makes the console a little bit less noisy.

Copy link
Contributor Author

@eatyourgreens eatyourgreens May 31, 2024

Choose a reason for hiding this comment

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

#7116 also got in the way of debugging React errors on this branch, so I might fix that here too.

@eatyourgreens eatyourgreens force-pushed the remove-babel-cjs-plugin branch 2 times, most recently from 69e5fef to 7d711bd Compare June 1, 2024 18:16
@eatyourgreens eatyourgreens force-pushed the remove-babel-cjs-plugin branch 3 times, most recently from 6e99494 to 354fd0f Compare June 22, 2024 08:30
Remove `babel-plugin-transform-es2015-modules-commonjs`, which is 6 years out-of-date and no longer supported. It generates security warnings in the console, because of outdated dependencies on `babel-traverse` (also 6 years out-of-date and unsupported.)

- transpile `.coffee` and `.cjsx` files from CJS to ESM with Babel.
- fix broken `module.exports` in a couple of places.
- `npm audit fix`.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
2 participants