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

docs: update extensions generated in library mode #11401

Merged
merged 2 commits into from
Dec 17, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions docs/guide/build.md
Original file line number Diff line number Diff line change
Expand Up @@ -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",
sapphi-red marked this conversation as resolved.
Show resolved Hide resolved
"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"
sapphi-red marked this conversation as resolved.
Show resolved Hide resolved
},
"./secondary": {
"import": "./dist/secondary.mjs",
"require": "./dist/secondary.cjs"
"import": "./dist/secondary.js",
"require": "./dist/secondary.umd.cjs"
sapphi-red marked this conversation as resolved.
Show resolved Hide resolved
}
}
}
```

::: 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`.
sapphi-red marked this conversation as resolved.
Show resolved Hide resolved
:::

::: tip Environment Variables
Expand Down