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

Warning is shown: The CJS build of Vite's Node API is deprecated #209

Closed
4 tasks done
aimad-majdou opened this issue Apr 19, 2024 · 3 comments · Fixed by #212
Closed
4 tasks done

Warning is shown: The CJS build of Vite's Node API is deprecated #209

aimad-majdou opened this issue Apr 19, 2024 · 3 comments · Fixed by #212
Labels

Comments

@aimad-majdou
Copy link

Describe the bug

Upon migrating to Vite version 5, it has been discovered that the vite-plugin-istanbul package is generating a warning due to its usage of the deprecated CJS Node API. The warning originates from the node_modules/vite-plugin-istanbul/dist/index.cjs file:

image

Proposed Solution:
Update the import statement in vite-plugin-istanbul to use dynamic imports, as recommended in the Vite documentation here.

For additional infos please check this issue: storybookjs/storybook#26291

Reproduction

https://stackblitz.com/edit/github-wgldvd-tuuoti

Steps to reproduce

Open the reproduction url, and observe the warning message related to the deprecated CJS Node API usage, in the console after the project starts.

If you remove the '@storybook/addon-coverage' from main.ts the error will disappear.

System Info

System:
    OS: Windows 10 10.0.19045
    CPU: (8) x64 Intel(R) Core(TM) i7-8565U CPU @ 1.80GHz
    Memory: 3.78 GB / 15.86 GB
  Binaries:
    Node: 21.3.0 - C:\Program Files\nodejs\node.EXE
    npm: 10.2.4 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: Chromium (123.0.2420.81)
  npmPackages:
    @vitejs/plugin-react-swc: 3.6.0 => 3.6.0
    vite: 5.2.9 => 5.2.9

Used Package Manager

npm

Logs

No response

Validations

@aimad-majdou aimad-majdou added the bug Something isn't working label Apr 19, 2024
@aimad-majdou aimad-majdou changed the title Issue with Deprecated CJS Node API Usage Warning is shown: The CJS build of Vite's Node API is deprecated Apr 19, 2024
@iFaxity
Copy link
Owner

iFaxity commented Apr 19, 2024

Hi @aimad-majdou, thanks for the issue.

Absolutely, will look into this and upload a new major version to export using ES modules instead.

iFaxity added a commit that referenced this issue May 4, 2024
iFaxity added a commit that referenced this issue May 4, 2024
* fix: moved to esm modules for vite 5

Fixes #209.

* build: updated to node v20.12.2

* build: switched to pnpm v9

* chore(deps): update dependencies
Copy link
Contributor

github-actions bot commented May 4, 2024

🎉 This issue has been resolved in version 6.0.1-rc.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

Copy link
Contributor

github-actions bot commented May 5, 2024

🎉 This issue has been resolved in version 6.0.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Successfully merging a pull request may close this issue.

2 participants