Conversation
➜ ls -l *.tgz
-rw-r--r-- 1 antfu staff 1036930 May 15 09:11 vite-3.0.0-alpha.0-cjs.tgz
-rw-r--r-- 1 antfu staff 1077340 May 15 08:32 vite-3.0.0-alpha.0-esm.tgz
➜ ls -lh *.tgz
-rw-r--r-- 1 antfu staff 1.0M May 15 09:11 vite-3.0.0-alpha.0-cjs.tgz
-rw-r--r-- 1 antfu staff 1.0M May 15 08:32 vite-3.0.0-alpha.0-esm.tgzBundle size diff is not significant. |
|
This is a great move since it effectively gets rid of the ESM-only error for Vite users. (This is the We can say whatever we want about Node.js's ESM-only strategy and the folks like |
bluwy
left a comment
There was a problem hiding this comment.
After building, it looks like the raw individual .d.ts file are still left in dist/node/*. Using api-extractor I think these are bundled and can be removed. I'm not sure what's causing it though.
|
Tested in VitePress and it works! |
| "require": "./index.cjs" | ||
| }, | ||
| "./client": { | ||
| "types": "./client.d.ts" |
There was a problem hiding this comment.
This ./client export is needed when using the new nodenext module resolution in the upcoming TypeScript 4.7 release.
As it stands now, using Vite 2.9.9 with typescript 4.7.1-rc + module: "nodenext" does not work because the compiler cannot access client.d.ts as it is not explicitly exported.
/// <reference types="vite/client" />
Looking forward to this getting into the 3.0.0 release.
|
Let's merge it to try in the next alpha! |
| "main": "./dist/node/index.js", | ||
| "module": "./dist/node/index.js", |
There was a problem hiding this comment.
I think we could remove these 2 fields since Vite 3 supports Node 14+, Node 12+ supports exports field and exports takes priority than main and module so Node.js will never reach these 2 fields.
| "types": "./client.d.ts" | ||
| }, | ||
| "./terser": { | ||
| "require": "./dist/node-cjs/terser.cjs" |
There was a problem hiding this comment.
TS complains here as missing declaration file.
There was a problem hiding this comment.
What version of TS and what “module” and/or “moduleResolution” settings are you using in your tsconfig.json file?
There was a problem hiding this comment.
Tried with TS 4.6 (node) and 4.7-rc1 (nodenext) with "module" being "esnext"
There was a problem hiding this comment.
If you mean "./terser", it is being removed here https://github.com/vitejs/vite/pull/8049/files#diff-949e137b027a941e9a8dabb980971ab5b7147f895fc06ab2ff0bb0923d981606L23
close #5839
Breaking changes
vitenow hastype: module.jsunderdist/are now ESMindex.cjsis created for CJS compactiblity, which proxies ESM APIs without a full CJS build.formatPostcssSourceMapis now asyncresolvePackageEntryresolvePackageData