Skip to content

Commit 9df8adb

Browse files
authored
chore(build)!: drop cjs api (vuejs#2737)
1 parent 1bed154 commit 9df8adb

File tree

6 files changed

+11
-26
lines changed

6 files changed

+11
-26
lines changed

docs/guide/getting-started.md

+6
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,12 @@ If using PNPM, you will notice a missing peer warning for `@docsearch/js`. This
4747

4848
:::
4949

50+
::: tip NOTE
51+
52+
VitePress is an ESM-only package. Don't use `require()` to import it, and make sure your nearest `package.json` contains `"type": "module"`, or change the file extension of your relevant files like `.vitepress/config.js` to `.mjs`/`.mts`. Refer [Vite's troubleshooting guide](http://vitejs.dev/guide/troubleshooting.html#this-package-is-esm-only) for more details. Also, inside async CJS contexts, you can use `await import('vitepress')` instead.
53+
54+
:::
55+
5056
### Setup Wizard
5157

5258
VitePress ships with a command line setup wizard that will help you scaffold a basic project. After installation, start the wizard by running:

docs/reference/site-config.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ Site config is where you can define the global settings of the site. App config
1010

1111
### Config Resolution
1212

13-
The config file is always resolved from `<root>/.vitepress/config.[ext]`, where `<root>` is your VitePress [project root](../guide/routing#root-and-source-directory), and `[ext]` is one of the supported file extensions. TypeScript is supported out of the box. Supported extensions include `.js`, `.ts`, `.cjs`, `.mjs`, `.cts`, and `.mts`.
13+
The config file is always resolved from `<root>/.vitepress/config.[ext]`, where `<root>` is your VitePress [project root](../guide/routing#root-and-source-directory), and `[ext]` is one of the supported file extensions. TypeScript is supported out of the box. Supported extensions include `.js`, `.ts`, `.mjs`, and `.mts`.
1414

1515
It is recommended to use ES modules syntax in config files. The config file should default export an object:
1616

package.json

+1-2
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,7 @@
99
"exports": {
1010
".": {
1111
"types": "./types/index.d.ts",
12-
"import": "./dist/node/index.js",
13-
"require": "./dist/node-cjs/index.cjs"
12+
"default": "./dist/node/index.js"
1413
},
1514
"./dist/*": "./dist/*",
1615
"./package.json": "./package.json",

rollup.config.ts

-20
Original file line numberDiff line numberDiff line change
@@ -62,21 +62,6 @@ const esmBuild: RollupOptions = {
6262
}
6363
}
6464

65-
const cjsBuild: RollupOptions = {
66-
input: [r('src/node/index.ts'), r('src/node/cli.ts')],
67-
output: {
68-
format: 'cjs',
69-
dir: r('dist/node-cjs'),
70-
entryFileNames: `[name].cjs`,
71-
chunkFileNames: 'serve-[hash].cjs'
72-
},
73-
external,
74-
plugins,
75-
onwarn(warning, warn) {
76-
if (warning.code !== 'EVAL') warn(warning)
77-
}
78-
}
79-
8065
const nodeTypes: RollupOptions = {
8166
input: r('src/node/index.ts'),
8267
output: {
@@ -110,11 +95,6 @@ const clientTypes: RollupOptions = {
11095
const config = defineConfig([])
11196

11297
config.push(esmBuild)
113-
114-
if (PROD) {
115-
config.push(cjsBuild)
116-
}
117-
11898
config.push(nodeTypes)
11999
config.push(clientTypes)
120100

src/node/config.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ export async function resolveConfig(
138138
return config
139139
}
140140

141-
const supportedConfigExtensions = ['js', 'ts', 'cjs', 'mjs', 'cts', 'mts']
141+
const supportedConfigExtensions = ['js', 'ts', 'mjs', 'mts']
142142

143143
export async function resolveUserConfig(
144144
root: string,

theme-without-fonts.d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export * from './theme'
2-
export { default } from './theme'
1+
export * from './theme.js'
2+
export { default } from './theme.js'

0 commit comments

Comments
 (0)