From 0b7d30a78c403db13617634cb4015ff9f8d72ee1 Mon Sep 17 00:00:00 2001 From: Guillaume Briday <8252238+guillaumebriday@users.noreply.github.com> Date: Sat, 17 Dec 2022 01:05:06 +0100 Subject: [PATCH 1/2] Updating extensions generated in library mode --- docs/guide/build.md | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/docs/guide/build.md b/docs/guide/build.md index 3ed66361803fc1..d895395ce8f310 100644 --- a/docs/guide/build.md +++ b/docs/guide/build.md @@ -193,23 +193,23 @@ Or, if exposing multiple entry points: "name": "my-lib", "type": "module", "files": ["dist"], - "main": "./dist/my-lib.cjs", - "module": "./dist/my-lib.mjs", + "main": "./dist/my-lib.umd.cjs", + "module": "./dist/my-lib.js", "exports": { ".": { - "import": "./dist/my-lib.mjs", - "require": "./dist/my-lib.cjs" + "import": "./dist/my-lib.js", + "require": "./dist/my-lib.umd.cjs" }, "./secondary": { - "import": "./dist/secondary.mjs", - "require": "./dist/secondary.cjs" + "import": "./dist/secondary.js", + "require": "./dist/secondary.umd.cjs" } } } ``` ::: tip Note -If the `package.json` does not contain `"type": "module"`, Vite will generate different file extensions for Node.js compatibility. `.js` will become `.mjs` and `.cjs` will become `.js`. +If the `package.json` does not contain `"type": "module"`, Vite will generate different file extensions for Node.js compatibility. `.js` will become `.mjs` and `.umd.cjs` will become `.umd.js`. ::: ::: tip Environment Variables From 65e974379901c29cb53339d419e785eb1c4ab384 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=BF=A0=20/=20green?= Date: Sat, 17 Dec 2022 16:01:56 +0900 Subject: [PATCH 2/2] chore: remove umd --- docs/guide/build.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/docs/guide/build.md b/docs/guide/build.md index d895395ce8f310..0068fd04ca6d9f 100644 --- a/docs/guide/build.md +++ b/docs/guide/build.md @@ -193,23 +193,23 @@ Or, if exposing multiple entry points: "name": "my-lib", "type": "module", "files": ["dist"], - "main": "./dist/my-lib.umd.cjs", + "main": "./dist/my-lib.cjs", "module": "./dist/my-lib.js", "exports": { ".": { "import": "./dist/my-lib.js", - "require": "./dist/my-lib.umd.cjs" + "require": "./dist/my-lib.cjs" }, "./secondary": { "import": "./dist/secondary.js", - "require": "./dist/secondary.umd.cjs" + "require": "./dist/secondary.cjs" } } } ``` ::: tip Note -If the `package.json` does not contain `"type": "module"`, Vite will generate different file extensions for Node.js compatibility. `.js` will become `.mjs` and `.umd.cjs` will become `.umd.js`. +If the `package.json` does not contain `"type": "module"`, Vite will generate different file extensions for Node.js compatibility. `.js` will become `.mjs` and `.cjs` will become `.js`. ::: ::: tip Environment Variables