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(deps): update update-notifier to 7.0.0 #1544

Merged
merged 1 commit into from
Nov 6, 2023
Merged

Conversation

sjinks
Copy link
Member

@sjinks sjinks commented Nov 6, 2023

Description

This PR updates update-notifier to 7.0.0. Because update-notifier is now an ESM, this required several additional steps.

  1. update-notifier is imported via await import - that's the only way to import ESM from CJS
  2. Because babel tries to replace await import with Promise.resolve().then(() => _interopRequireWildcard(require('update-notifier')), I had to disable the @babel/plugin-proposal-dynamic-import plugin.
  3. This broke proxy-agent tests because jest did not like await import and insisted on the ESM-enabled environment. Luckily, the test works without dynamic imports.
  4. I chose to disable update-notifier when NODE_ENV=test because I did not want to install cross-env and pass NODE_OPTIONS=--experimental-vm-modules to keep Jest happy. However, we may need to do this someday.
  5. One day, we will need to switch to ESM. However, I don't feel adventurous enough to do that now :-)

As a bonus, we have four less medium security vulnerabilities.

Steps to Test

  1. CI should pass - my changes should not break the existing tests
  2. npm run build; ./dist/bin/vip.js should work (it will invoke update-notifier; there should be no errors coming from Node.js). E2E tests will also catch an error here.

@sjinks sjinks requested a review from abdullah-kasim November 6, 2023 08:01
@sjinks sjinks self-assigned this Nov 6, 2023
@sjinks sjinks marked this pull request as ready for review November 6, 2023 08:03
Comment on lines -93 to -97
setEnvironmentVariabeles( envVars );
// We have to dynamically import the module so we can set environment variables above
// All tests must be async to support this dynamic import, otherwise the modified env variables are not picked up
const createProxyAgent = ( await import( '../../../src/lib/http/proxy-agent' ) )
.createProxyAgent;
Copy link
Member Author

Choose a reason for hiding this comment

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

It magically works :-) I found no code in createProxyAgent to cache the old environment variables. And, as far as I understand, multiple await import (= require()) will load the module only once anyway.

Comment on lines +30 to +32
afterAll( () => {
process.env = { ...env };
} );
Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe this is unnecessary, but I prefer restoring things to their original state.

@sjinks sjinks merged commit 43d2230 into trunk Nov 6, 2023
10 checks passed
@sjinks sjinks deleted the update/update-notifier branch November 6, 2023 08:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants