Skip to content

Commit

Permalink
Merge branch 'main' into meteorlxy-markdown-to-vue
Browse files Browse the repository at this point in the history
  • Loading branch information
meteorlxy authored Oct 10, 2024
2 parents 73ae7fc + e38fc11 commit 2d5e934
Show file tree
Hide file tree
Showing 24 changed files with 762 additions and 668 deletions.
16 changes: 16 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,19 @@
# [2.0.0-rc.18](https://github.com/vuepress/core/compare/v2.0.0-rc.17...v2.0.0-rc.18) (2024-10-10)


### Bug Fixes

* **core:** fix app env flag regression (close [#1612](https://github.com/vuepress/core/issues/1612)) ([e693cdc](https://github.com/vuepress/core/commit/e693cdc6892aa977dc92c37c4869ad86fa5a8d69))


### Features

* **core:** improve user config file loading ([#1615](https://github.com/vuepress/core/issues/1615)) ([01f6ab3](https://github.com/vuepress/core/commit/01f6ab3c24d34c85b090656b1352b38913084809))
* **markdown:** add isExternal option for linksPlugin (close [#1611](https://github.com/vuepress/core/issues/1611)) ([41214eb](https://github.com/vuepress/core/commit/41214eb4060e6b5537cd1ee25e2803bf1f66a7e6))
* **utils:** sync latest sanitizeFileName logic from rollup ([#1614](https://github.com/vuepress/core/issues/1614)) ([aaf3bba](https://github.com/vuepress/core/commit/aaf3bba36134fe31518f559f08fbe9dfd8f98c4a))



# [2.0.0-rc.17](https://github.com/vuepress/core/compare/v2.0.0-rc.16...v2.0.0-rc.17) (2024-09-30)


Expand Down
6 changes: 3 additions & 3 deletions e2e/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vuepress/e2e",
"version": "2.0.0-rc.17",
"version": "2.0.0-rc.18",
"private": true,
"type": "module",
"scripts": {
Expand All @@ -23,11 +23,11 @@
"sass": "^1.79.4",
"sass-embedded": "^1.79.4",
"sass-loader": "^16.0.2",
"vue": "^3.5.10",
"vue": "^3.5.11",
"vuepress": "workspace:*"
},
"devDependencies": {
"@playwright/test": "^1.47.2",
"@playwright/test": "^1.48.0",
"anywhere": "^1.6.0",
"cross-env": "^7.0.3"
}
Expand Down
2 changes: 2 additions & 0 deletions e2e/utils/env.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
import process from 'node:process'

export const BASE = process.env.E2E_BASE ?? '/'
export const BUNDLER = process.env.E2E_BUNDLER ?? 'vite'
export const COMMAND = process.env.E2E_COMMAND ?? 'dev'
Expand Down
18 changes: 9 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vuepress/monorepo",
"version": "2.0.0-rc.17",
"version": "2.0.0-rc.18",
"private": true,
"type": "module",
"scripts": {
Expand Down Expand Up @@ -35,15 +35,15 @@
"@commitlint/cli": "^19.5.0",
"@commitlint/config-conventional": "^19.5.0",
"@commitlint/types": "^19.5.0",
"@types/node": "^22.7.4",
"@types/node": "^22.7.5",
"@types/webpack-env": "^1.18.5",
"@vitest/coverage-istanbul": "^2.1.1",
"bumpp": "^9.6.1",
"@vitest/coverage-istanbul": "^2.1.2",
"bumpp": "^9.7.1",
"conventional-changelog-cli": "^5.0.0",
"eslint": "^9.11.1",
"eslint": "^9.12.0",
"eslint-config-vuepress": "^5.2.0",
"husky": "^9.1.6",
"jiti": "^2.0.0",
"jiti": "^2.3.3",
"lint-staged": "^15.2.10",
"prettier": "^3.3.3",
"prettier-config-vuepress": "^5.0.0",
Expand All @@ -52,10 +52,10 @@
"taze": "^0.17.2",
"tsconfig-vuepress": "^5.2.0",
"tsup": "^8.3.0",
"typescript": "^5.6.2",
"typescript": "^5.6.3",
"vite": "~5.4.8",
"vitest": "^2.1.1",
"vitest": "^2.1.2",
"vue-tsc": "^2.1.6"
},
"packageManager": "pnpm@9.11.0"
"packageManager": "pnpm@9.12.1"
}
6 changes: 3 additions & 3 deletions packages/bundler-vite/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vuepress/bundler-vite",
"version": "2.0.0-rc.17",
"version": "2.0.0-rc.18",
"description": "Bundler vite package of VuePress",
"keywords": [
"vuepress-bundler",
Expand Down Expand Up @@ -45,9 +45,9 @@
"connect-history-api-fallback": "^2.0.0",
"postcss": "^8.4.47",
"postcss-load-config": "^6.0.1",
"rollup": "^4.22.5",
"rollup": "^4.24.0",
"vite": "~5.4.8",
"vue": "^3.5.10",
"vue": "^3.5.11",
"vue-router": "^4.4.5"
},
"devDependencies": {
Expand Down
6 changes: 3 additions & 3 deletions packages/bundler-webpack/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vuepress/bundler-webpack",
"version": "2.0.0-rc.17",
"version": "2.0.0-rc.18",
"description": "Bundler webpack package of VuePress",
"keywords": [
"vuepress-bundler",
Expand Down Expand Up @@ -50,14 +50,14 @@
"css-loader": "^7.1.2",
"css-minimizer-webpack-plugin": "^7.0.0",
"esbuild-loader": "~4.2.2",
"express": "^4.21.0",
"express": "^4.21.1",
"html-webpack-plugin": "^5.6.0",
"lightningcss": "^1.27.0",
"mini-css-extract-plugin": "^2.9.1",
"postcss": "^8.4.47",
"postcss-loader": "^8.1.1",
"style-loader": "^4.0.0",
"vue": "^3.5.10",
"vue": "^3.5.11",
"vue-loader": "^17.4.2",
"vue-router": "^4.4.5",
"webpack": "^5.95.0",
Expand Down
4 changes: 2 additions & 2 deletions packages/bundlerutils/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vuepress/bundlerutils",
"version": "2.0.0-rc.17",
"version": "2.0.0-rc.18",
"description": "Utils package of VuePress bundler",
"keywords": [
"bundler",
Expand Down Expand Up @@ -36,7 +36,7 @@
"@vuepress/core": "workspace:*",
"@vuepress/shared": "workspace:*",
"@vuepress/utils": "workspace:*",
"vue": "^3.5.10",
"vue": "^3.5.11",
"vue-router": "^4.4.5"
},
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/cli/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vuepress/cli",
"version": "2.0.0-rc.17",
"version": "2.0.0-rc.18",
"description": "CLI package of VuePress",
"keywords": [
"vuepress",
Expand Down
11 changes: 7 additions & 4 deletions packages/cli/src/config/loadUserConfig.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import process from 'node:process'
import { pathToFileURL } from 'node:url'
import { fs, hash, importFileDefault, path } from '@vuepress/utils'
import { build } from 'esbuild'
Expand All @@ -18,26 +19,28 @@ export const loadUserConfig = async (
userConfigDependencies: [],
}
}
// following code is forked and modified from vite
// forked and modified from https://github.com/vitejs/vite/blob/889bfc0ada6d6cd356bb7a92efdce96298f82fef/packages/vite/src/node/config.ts#L1531
// TODO: we can migrate to something like `bundler-require`, but its `__dirname` support is not as good as vite
const dirnameVarName = '__vite_injected_original_dirname'
const filenameVarName = '__vite_injected_original_filename'
const importMetaUrlVarName = '__vite_injected_original_import_meta_url'
const result = await build({
absWorkingDir: process.cwd(),
entryPoints: [userConfigPath],
outfile: 'out.js',
write: false,
target: ['node18'],
target: [`node${process.versions.node}`],
platform: 'node',
bundle: true,
format: 'esm',
mainFields: ['main'],
sourcemap: 'inline',
metafile: true,
define: {
'__dirname': dirnameVarName,
'__filename': filenameVarName,
'import.meta.url': importMetaUrlVarName,
'import.meta.dirname': dirnameVarName,
'import.meta.filename': filenameVarName,
},
plugins: [
{
Expand All @@ -58,7 +61,7 @@ export const loadUserConfig = async (
name: 'inject-file-scope-variables',
setup(pluginBuild) {
pluginBuild.onLoad({ filter: /\.[cm]?[jt]s$/ }, async (args) => {
const contents = await fs.readFile(args.path, 'utf8')
const contents = await fs.readFile(args.path, 'utf-8')
const injectValues =
`const ${dirnameVarName} = ${JSON.stringify(
path.dirname(args.path),
Expand Down
4 changes: 2 additions & 2 deletions packages/client/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vuepress/client",
"version": "2.0.0-rc.17",
"version": "2.0.0-rc.18",
"description": "Client package of VuePress",
"keywords": [
"vuepress",
Expand Down Expand Up @@ -39,7 +39,7 @@
"dependencies": {
"@vue/devtools-api": "^7.4.6",
"@vuepress/shared": "workspace:*",
"vue": "^3.5.10",
"vue": "^3.5.11",
"vue-router": "^4.4.5"
},
"publishConfig": {
Expand Down
4 changes: 2 additions & 2 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vuepress/core",
"version": "2.0.0-rc.17",
"version": "2.0.0-rc.18",
"description": "Core package of VuePress",
"keywords": [
"vuepress",
Expand Down Expand Up @@ -35,7 +35,7 @@
"@vuepress/markdown": "workspace:*",
"@vuepress/shared": "workspace:*",
"@vuepress/utils": "workspace:*",
"vue": "^3.5.10"
"vue": "^3.5.11"
},
"publishConfig": {
"access": "public"
Expand Down
6 changes: 0 additions & 6 deletions packages/core/src/app/createBaseApp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import { resolveAppOptions } from './resolveAppOptions.js'
import { resolveAppSiteData } from './resolveAppSiteData.js'
import { resolveAppVersion } from './resolveAppVersion.js'
import { resolveAppWriteTemp } from './resolveAppWriteTemp.js'
import { setupAppThemeAndPlugins } from './setupAppThemeAndPlugins.js'

/**
* Create base vuepress app.
Expand Down Expand Up @@ -49,10 +48,5 @@ export const createBaseApp = (config: AppConfig): App => {
prepare: async () => appPrepare(app),
} satisfies AppPropertiesBase as App

// setup theme and plugins
// notice that we setup theme before plugins,
// so user plugins could override theme plugins
setupAppThemeAndPlugins(app, config)

return app
}
4 changes: 4 additions & 0 deletions packages/core/src/app/createBuildApp.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { AppConfig, BuildApp } from '../types/index.js'
import { createBaseApp } from './createBaseApp.js'
import { setupAppThemeAndPlugins } from './setupAppThemeAndPlugins.js'

/**
* Create vuepress build app.
Expand All @@ -11,5 +12,8 @@ export const createBuildApp = (config: AppConfig): BuildApp => {
app.env.isBuild = true
app.build = async () => app.options.bundler.build(app)

// setup theme and plugins
setupAppThemeAndPlugins(app, config)

return app
}
4 changes: 4 additions & 0 deletions packages/core/src/app/createDevApp.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import type { AppConfig, DevApp } from '../types/index.js'
import { createBaseApp } from './createBaseApp.js'
import { setupAppThemeAndPlugins } from './setupAppThemeAndPlugins.js'

/**
* Create vuepress dev app.
Expand All @@ -11,5 +12,8 @@ export const createDevApp = (config: AppConfig): DevApp => {
app.env.isDev = true
app.dev = async () => app.options.bundler.dev(app)

// setup theme and plugins
setupAppThemeAndPlugins(app, config)

return app
}
29 changes: 29 additions & 0 deletions packages/core/tests/app/createBuildApp.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { expect, it } from 'vitest'
import type { App, BuildApp, Bundler } from '../../src/index.js'
import { createBuildApp } from '../../src/index.js'

it('should create build app correctly', () => {
const checkApp = (app: App): void => {
expect(app.env.isDev).toBe(false)
expect((app as unknown as { dev: never }).dev).toBeUndefined()

expect(app.env.isBuild).toBe(true)
expect(typeof (app as BuildApp).build).toBe('function')
}

const buildApp = createBuildApp({
source: '/foo',
theme: (appInTheme) => {
checkApp(appInTheme)
return { name: 'test-theme' }
},
bundler: {} as Bundler,
plugins: [
(appInPlugin) => {
checkApp(appInPlugin)
return { name: 'test-plugin' }
},
],
})
checkApp(buildApp)
})
29 changes: 29 additions & 0 deletions packages/core/tests/app/createDevApp.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
import { expect, it } from 'vitest'
import type { App, Bundler, DevApp } from '../../src/index.js'
import { createDevApp } from '../../src/index.js'

it('should create dev app correctly', () => {
const checkApp = (app: App): void => {
expect(app.env.isDev).toBe(true)
expect(typeof (app as DevApp).dev).toBe('function')

expect(app.env.isBuild).toBe(false)
expect((app as unknown as { build: never }).build).toBeUndefined()
}

const devApp = createDevApp({
source: '/foo',
theme: (appInTheme) => {
checkApp(appInTheme)
return { name: 'test-theme' }
},
bundler: {} as Bundler,
plugins: [
(appInPlugin) => {
checkApp(appInPlugin)
return { name: 'test-plugin' }
},
],
})
checkApp(devApp)
})
2 changes: 1 addition & 1 deletion packages/markdown/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@vuepress/markdown",
"version": "2.0.0-rc.17",
"version": "2.0.0-rc.18",
"description": "Markdown package of VuePress",
"keywords": [
"vuepress",
Expand Down
Loading

0 comments on commit 2d5e934

Please sign in to comment.