sentry-javascript-bundler-plugins icon indicating copy to clipboard operation
sentry-javascript-bundler-plugins copied to clipboard

Vite: The CJS build of Vite's Node API is deprecated

Open AleG94 opened this issue 9 months ago • 4 comments

Environment

vite: 5.4.21 @sentry/vite-plugin: 4.9.1

Steps to Reproduce

  1. Run vite or vite build

Expected Result

Vite should complete the build without activating CJS mode. The issue was introduced in d3236bdbc1a7bea26c7f375ffd47c8d5f2213fa7

Actual Result

The CJS build of Vite's Node API is deprecated. See https://vite.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details. at warnCjsUsage (/Users/<USER>/<WORK>/<PROJECT>/node_modules/vite/index.cjs:50:11) at Object.<anonymous> (/Users/<USER>/<WORK>/<PROJECT>/node_modules/vite/index.cjs:1:1) at getViteMajorVersion (file:///Users/<USER>/<WORK>/<PROJECT>/node_modules/@sentry/vite-plugin/dist/esm/index.mjs:40:16) at file:///Users/<USER>/<WORK>/<PROJECT>/node_modules/@sentry/bundler-plugin-core/dist/esm/index.mjs:9879:110 at Object.<anonymous> (file:///Users/<USER>/<WORK>/<PROJECT>/node_modules/unplugin/dist/index.mjs:1201:32) at sentryVitePlugin (file:///Users/<USER>/<WORK>/<PROJECT>/node_modules/@sentry/vite-plugin/dist/esm/index.mjs:55:31) at file:///Users/<USER>/<WORK>/<PROJECT>/vite.config.ts.timestamp-XXXXXXXXXXXX.mjs:13:5 at async loadConfigFromBundledFile (file:///Users/<USER>/<WORK>/<PROJECT>/node_modules/vite/dist/node/chunks/dep-XXXX.js:66975:15) at async loadConfigFromFile (file:///Users/<USER>/<WORK>/<PROJECT>/node_modules/vite/dist/node/chunks/dep-XXXX.js:66816:24) at async resolveConfig (file:///Users/<USER>/<WORK>/<PROJECT>/node_modules/vite/dist/node/chunks/dep-XXXX.js:66416:24) at async _createServer (file:///Users/<USER>/<WORK>/<PROJECT>/node_modules/vite/dist/node/chunks/dep-XXXX.js:63015:18) at async CAC.<anonymous> (file:///Users/<USER>/<WORK>/<PROJECT>/node_modules/vite/dist/node/cli.js:736:20)

AleG94 avatar Feb 14 '26 14:02 AleG94

BUNDLER-110

linear[bot] avatar Feb 14 '26 14:02 linear[bot]

Hey @AleG94, thanks for reporting! @timfish could you take a look at this please, thanks!

Lms24 avatar Feb 16 '26 12:02 Lms24

Looks like this is caused by the fact that we use createRequire to lazily fetch the Vite version because we needed to keep it synchronous!

timfish avatar Feb 16 '26 21:02 timfish

This warning doesn't exist in any of the recent Vite majors.

We can get the Vite version via async import but then the async will propagate through and make the plugin initialization async and I don't think this is worth doing to suppress a warning in v5.

timfish avatar Apr 06 '26 13:04 timfish