jest-preview icon indicating copy to clipboard operation
jest-preview copied to clipboard

Use update-notifier lib with dynamic import

Open danieljung-seon opened this issue 1 year ago • 4 comments

Summary/ Motivation (TLDR;)

Potential solution for the open #276 🐛

When trying to use the latest prerelease version that has update-notifier@6 installed I get the following error:

/jest-preview/dist/cli/index.js:5
var updateNotifier = require('update-notifier');
                     ^

Error [ERR_REQUIRE_ESM]: require() of ES Module ...

Inspiration comes from the Please read this section's choice num. 2 of the [email protected] release.

  1. If the package is used in an async context, you could use await import(…) from CommonJS instead of require(…).

Fixes

  • [x] Might fix version 0.3.2-alpha.1 that has a problem with update-notifier@6 being used with require. (commonjs context)

Quick test I did:

  • Faked an older version: Screenshot 2023-05-31 at 9 43 14

  • Created dist files by running pnpm run build

  • Ran node dist/cli/index.js twice and got the following message: Screenshot 2023-05-31 at 9 43 09

PS:

  • Would be nice to create a new prerelease and another round of testing to see if the change indeed works.
  • Let me know if this is the right track or not, or if there's anything I could change.

danieljung-seon avatar May 31 '23 08:05 danieljung-seon

Deploy Preview for jest-preview-library canceled.

Name Link
Latest commit 24cbe846893427c5b4985733e5888e1aa5f30c69
Latest deploy log https://app.netlify.com/sites/jest-preview-library/deploys/6476ff51be96e50008d1015f

netlify[bot] avatar May 31 '23 08:05 netlify[bot]

Deploy Preview for jest-preview-chinese canceled.

Name Link
Latest commit 24cbe846893427c5b4985733e5888e1aa5f30c69
Latest deploy log https://app.netlify.com/sites/jest-preview-chinese/deploys/6476ff5142bdc10008a26d10

netlify[bot] avatar May 31 '23 08:05 netlify[bot]

@nvh95 do you think this is worthy?

danieljung-seon avatar Jun 05 '23 16:06 danieljung-seon

Any chance we can have this change merged so we can update "update-notifier" to v6?

snout-o avatar Jan 23 '24 23:01 snout-o