jest-preview
jest-preview copied to clipboard
Use update-notifier lib with dynamic import
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.
- 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:
-
Created dist files by running
pnpm run build
-
Ran
node dist/cli/index.js
twice and got the following message:
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.
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 |
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 |
@nvh95 do you think this is worthy?
Any chance we can have this change merged so we can update "update-notifier" to v6?