Skip to content

Commit d283ffe

Browse files
authored
feat: migrate to pure ESM (#1030)
- feat(cli): support .mjs config file - feat(bundler-vite): support vite 3 - test: migrate from jest to vitest - build: split ecosystem packages BREAKING CHANGE: VuePress is now published as pure ESM packages BREAKING CHANGE: CommonJS config file is not supported anymore
1 parent 884e8fc commit d283ffe

File tree

843 files changed

+4403
-6280
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

843 files changed

+4403
-6280
lines changed

.commitlintrc.js renamed to .commitlintrc.cjs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
const fs = require('fs')
22
const path = require('path')
33

4-
const packages = fs.readdirSync(path.resolve(__dirname, 'packages/@vuepress'))
4+
const corePackages = fs.readdirSync(path.resolve(__dirname, 'packages'))
5+
const ecosystemPackages = fs.readdirSync(path.resolve(__dirname, 'ecosystem'))
56

67
module.exports = {
78
extends: ['@commitlint/config-conventional'],
89
rules: {
910
'scope-enum': [
1011
2,
1112
'always',
12-
['vuepress', 'vuepress-vite', 'vuepress-webpack', ...packages],
13+
[...corePackages, ...ecosystemPackages],
1314
],
1415
'footer-max-line-length': [0],
1516
},

.eslintrc.js renamed to .eslintrc.cjs

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,16 +11,14 @@ module.exports = {
1111
},
1212
overrides: [
1313
{
14-
files: ['*.ts', '*.vue'],
14+
files: ['*.ts', '*.vue', '*.cts'],
1515
extends: 'vuepress-typescript',
1616
parserOptions: {
1717
project: ['tsconfig.json'],
1818
},
1919
rules: {
20-
'@typescript-eslint/ban-ts-comment': 'off',
2120
'@typescript-eslint/no-explicit-any': 'off',
2221
'@typescript-eslint/no-non-null-assertion': 'off',
23-
'@typescript-eslint/no-var-requires': 'off',
2422
'vue/multi-word-component-names': 'off',
2523
},
2624
},
@@ -31,12 +29,10 @@ module.exports = {
3129
},
3230
},
3331
{
34-
files: ['**/__tests__/**/*.ts'],
35-
env: {
36-
jest: true,
37-
},
32+
files: ['**/tests/**/*.ts', 'tsup.config.ts'],
3833
rules: {
3934
'@typescript-eslint/explicit-function-return-type': 'off',
35+
'import/no-extraneous-dependencies': 'off',
4036
'vue/one-component-per-file': 'off',
4137
},
4238
},

.github/workflows/check.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,11 @@ jobs:
3737
- name: Install dependencies
3838
run: pnpm install --frozen-lockfile
3939

40-
- name: Lint
41-
run: pnpm lint
42-
4340
- name: Build
4441
run: pnpm build
4542

43+
- name: Lint
44+
run: pnpm lint
45+
4646
- name: Test
4747
run: pnpm test

.github/workflows/coverage.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ jobs:
3838
run: pnpm build
3939

4040
- name: Test coverage
41-
run: pnpm run test --coverage
41+
run: pnpm test:cov
4242

4343
- name: Coveralls
4444
uses: coverallsapp/github-action@master

docs/.vuepress/config.ts

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import process from 'node:process'
12
import { viteBundler } from '@vuepress/bundler-vite'
23
import { webpackBundler } from '@vuepress/bundler-webpack'
34
import { defineUserConfig } from '@vuepress/cli'
@@ -6,9 +7,16 @@ import { googleAnalyticsPlugin } from '@vuepress/plugin-google-analytics'
67
import { registerComponentsPlugin } from '@vuepress/plugin-register-components'
78
import { shikiPlugin } from '@vuepress/plugin-shiki'
89
import { defaultTheme } from '@vuepress/theme-default'
9-
import { path } from '@vuepress/utils'
10-
import { head, navbarEn, navbarZh, sidebarEn, sidebarZh } from './configs'
10+
import { getDirname, path } from '@vuepress/utils'
11+
import {
12+
head,
13+
navbarEn,
14+
navbarZh,
15+
sidebarEn,
16+
sidebarZh,
17+
} from './configs/index.js'
1118

19+
const __dirname = getDirname(import.meta.url)
1220
const isProd = process.env.NODE_ENV === 'production'
1321

1422
export default defineUserConfig({
@@ -105,10 +113,7 @@ export default defineUserConfig({
105113
markdown: {
106114
importCode: {
107115
handleImportPath: (str) =>
108-
str.replace(
109-
/^@vuepress/,
110-
path.resolve(__dirname, '../../packages/@vuepress')
111-
),
116+
str.replace(/^@vuepress/, path.resolve(__dirname, '../../ecosystem')),
112117
},
113118
},
114119

docs/.vuepress/configs/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
1-
export * from './head'
2-
export * from './navbar'
3-
export * from './sidebar'
1+
export * from './head.js'
2+
export * from './navbar/index.js'
3+
export * from './sidebar/index.js'

docs/.vuepress/configs/meta.ts

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,8 @@
1-
export const { version } = require('@vuepress/core/package.json')
1+
import { createRequire } from 'node:module'
2+
import { fs } from '@vuepress/utils'
3+
4+
const require = createRequire(import.meta.url)
5+
6+
export const version = fs.readJSONSync(
7+
require.resolve('@vuepress/core/package.json')
8+
).version

docs/.vuepress/configs/navbar/en.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { NavbarConfig } from '@vuepress/theme-default'
2-
import { version } from '../meta'
2+
import { version } from '../meta.js'
33

44
export const navbarEn: NavbarConfig = [
55
{
Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
export * from './en'
2-
export * from './zh'
1+
export * from './en.js'
2+
export * from './zh.js'

docs/.vuepress/configs/navbar/zh.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import type { NavbarConfig } from '@vuepress/theme-default'
2-
import { version } from '../meta'
2+
import { version } from '../meta.js'
33

44
export const navbarZh: NavbarConfig = [
55
{

0 commit comments

Comments
 (0)