emosheeep / vite-plugin-virtual-mpa

Out-of-box MPA plugin for Vite, generate multiple entries using only one template.
https://stackblitz.com/~/github.com/emosheeep/vite-plugin-virtual-mpa
MIT License
120 stars 15 forks source link

fix: Vite 5 - The CJS build of Vite's Node API is deprecated #62

Closed renataogarcia closed 9 months ago

renataogarcia commented 9 months ago

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

Trace: The CJS build of Vite's Node API is deprecated. See https://vitejs.dev/guide/troubleshooting.html#vite-cjs-node-api-deprecated for more details.
    at warnCjsUsage (<path>/node_modules/vite/index.cjs:32:3)
    at Object.<anonymous> (<path>/node_modules/vite/index.cjs:3:1)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1435:10)
    at Module.load (node:internal/modules/cjs/loader:1207:32)
    at Module._load (node:internal/modules/cjs/loader:1023:12)
    at Module.require (node:internal/modules/cjs/loader:1235:19)
    at require (node:internal/modules/helpers:176:18)
    at Object.<anonymous> (<path>/node_modules/vite-plugin-virtual-mpa/dist/index.js:89:19)
    at Module._compile (node:internal/modules/cjs/loader:1376:14)
emosheeep commented 9 months ago

I just removed these line in v1.10.0, does that cause some problems? How did you get this warn?

renataogarcia commented 9 months ago

I got it with version 1.10.0 and vite 5.1.1

Running:

VITE_CJS_TRACE=true npx vite dev
emosheeep commented 9 months ago

Looks like a little confusing....I tried to add the lines but the warn is not gone, util I change the viteconfig to mts or add "type": "module" to my project. sorry i missed this before.

I guess vite transforms the config file into cjs format and load it using require, and the module filed is used by bundle tool, but not support by node.

renataogarcia commented 9 months ago

Looks like a little confusing....I tried to add the lines but the warn is not gone, util I change the viteconfig to mts or add "type": "module" to my project. sorry i missed this before.

I guess vite transforms the config file into cjs format and load it using require, and the module filed is used by bundle tool, but not support by node.

Yeah, indeed... I have "type":"module": set.