chore(build)!: drop cjs api (#2737)

pull/2753/head
Divyansh Singh 11 months ago committed by GitHub
parent 1bed154612
commit 9df8adb53e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -47,6 +47,12 @@ If using PNPM, you will notice a missing peer warning for `@docsearch/js`. This
:::
::: tip NOTE
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.
:::
### Setup Wizard
VitePress ships with a command line setup wizard that will help you scaffold a basic project. After installation, start the wizard by running:

@ -10,7 +10,7 @@ Site config is where you can define the global settings of the site. App config
### Config Resolution
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`.
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`.
It is recommended to use ES modules syntax in config files. The config file should default export an object:

@ -9,8 +9,7 @@
"exports": {
".": {
"types": "./types/index.d.ts",
"import": "./dist/node/index.js",
"require": "./dist/node-cjs/index.cjs"
"default": "./dist/node/index.js"
},
"./dist/*": "./dist/*",
"./package.json": "./package.json",

@ -62,21 +62,6 @@ const esmBuild: RollupOptions = {
}
}
const cjsBuild: RollupOptions = {
input: [r('src/node/index.ts'), r('src/node/cli.ts')],
output: {
format: 'cjs',
dir: r('dist/node-cjs'),
entryFileNames: `[name].cjs`,
chunkFileNames: 'serve-[hash].cjs'
},
external,
plugins,
onwarn(warning, warn) {
if (warning.code !== 'EVAL') warn(warning)
}
}
const nodeTypes: RollupOptions = {
input: r('src/node/index.ts'),
output: {
@ -110,11 +95,6 @@ const clientTypes: RollupOptions = {
const config = defineConfig([])
config.push(esmBuild)
if (PROD) {
config.push(cjsBuild)
}
config.push(nodeTypes)
config.push(clientTypes)

@ -138,7 +138,7 @@ export async function resolveConfig(
return config
}
const supportedConfigExtensions = ['js', 'ts', 'cjs', 'mjs', 'cts', 'mts']
const supportedConfigExtensions = ['js', 'ts', 'mjs', 'mts']
export async function resolveUserConfig(
root: string,

@ -1,2 +1,2 @@
export * from './theme'
export { default } from './theme'
export * from './theme.js'
export { default } from './theme.js'

Loading…
Cancel
Save