Skip to content

fix(vscode): fix build and publish, reduce extension size #2207

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

Draft
wants to merge 8 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
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
3 changes: 3 additions & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,13 @@ export default antfu({
'vue/no-v-text-v-html-on-component',
'vue/component-name-in-template-casing',
'jsonc/sort-array-values',
'pnpm/yaml-no-duplicate-catalog-item',
)
.override('antfu/pnpm/package-json', {
ignores: [
'packages/create-theme/template/package.json',
'packages/create-app/template/package.json',
// VSCE and OVSX do not support pnpm catalog when reading `@types/vscode`'s version.
'packages/vscode/package.json',
],
})
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@
"lint-staged": "catalog:dev",
"mermaid": "catalog:frontend",
"playwright-chromium": "catalog:dev",
"prettier": "catalog:frontend",
"prettier": "catalog:dev",
"prettier-plugin-slidev": "catalog:dev",
"rimraf": "catalog:dev",
"shiki": "catalog:frontend",
Expand Down
1 change: 0 additions & 1 deletion packages/client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,6 @@
"monaco-editor": "catalog:monaco",
"nanotar": "catalog:frontend",
"pptxgenjs": "catalog:prod",
"prettier": "catalog:frontend",
"recordrtc": "catalog:frontend",
"shiki": "catalog:frontend",
"shiki-magic-move": "catalog:frontend",
Expand Down
1 change: 0 additions & 1 deletion packages/slidev/node/vite/extendConfig.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ const INCLUDE_GLOBAL = [
'@typescript/ata',
'file-saver',
'lz-string',
'prettier',
'recordrtc',
'typescript',
'yaml',
Expand Down
6 changes: 5 additions & 1 deletion packages/vscode/.vscodeignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,8 @@ language-server/**
scripts/**
src/**
tsdown.config.ts
*.map
**/*.map
syntaxes/codeblock-patch.ts
syntaxes/slidev.example.md
syntaxes/tsconfig.json
syntaxes/.vscode
2 changes: 0 additions & 2 deletions packages/vscode/language-server/import-meta-url.ts

This file was deleted.

6 changes: 3 additions & 3 deletions packages/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"main": "./dist/index.cjs",
"icon": "dist/res/logo.png",
"engines": {
"vscode": "^1.89.0"
"vscode": "^1.101.0"
},
"activationEvents": [
"onStartupFinished"
Expand Down Expand Up @@ -449,13 +449,13 @@
"@slidev/parser": "workspace:*",
"@slidev/types": "workspace:*",
"@types/node": "catalog:types",
"@types/vscode": "catalog:types",
"@types/vscode": "^1.101.0",
"@volar/language-server": "catalog:vscode",
"@volar/vscode": "catalog:vscode",
"get-port-please": "catalog:prod",
"mlly": "catalog:prod",
"ovsx": "catalog:dev",
"prettier": "catalog:frontend",
"prettier": "catalog:vscode",
"reactive-vscode": "catalog:vscode",
"tm-grammars": "catalog:frontend",
"ts-json-schema-generator": "catalog:vscode",
Expand Down
15 changes: 12 additions & 3 deletions packages/vscode/scripts/publish.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import type { Options } from 'tinyexec'
import fs from 'node:fs/promises'
import process from 'node:process'
import { x } from 'tinyexec'
Expand All @@ -23,11 +24,19 @@ async function publish() {

console.log('Publishing VS Code extension...')

await x('npm', ['run', 'build'], { nodeOptions: { cwd: root, stdio: 'inherit' } })
const options: Partial<Options> = {
nodeOptions: {
cwd: root,
stdio: 'inherit',
},
throwOnError: true,
}

await x('npm', ['run', 'build'], options)
console.log('\nPublish to VSCE...\n')
await x('npx', ['@vscode/vsce', 'publish', '--no-dependencies', '-p', process.env.VSCE_TOKEN!], { nodeOptions: { cwd: root, stdio: 'inherit' } })
await x('npx', ['@vscode/vsce', 'publish', '--no-dependencies', '-p', process.env.VSCE_TOKEN!], options)
console.log('\nPublish to OVSE...\n')
await x('npx', ['ovsx', 'publish', '--no-dependencies', '-p', process.env.OVSX_TOKEN!], { nodeOptions: { cwd: root, stdio: 'inherit' } })
await x('npx', ['ovsx', 'publish', '--no-dependencies', '-p', process.env.OVSX_TOKEN!], options)
}

publish()
32 changes: 16 additions & 16 deletions packages/vscode/tsdown.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,40 +7,40 @@ import { defineConfig } from 'tsdown'
import { generateCodeblockPatch } from './syntaxes/codeblock-patch.ts'

export default defineConfig({
// @ts-expect-error `entry` is valid option
entry: {
'index': 'src/index.ts',
'language-server': 'language-server/bin.ts',
},
format: 'cjs',
target: 'node18',
target: 'node20',
clean: true,
minify: process.env.NODE_ENV === 'production',
sourcemap: true,
external: [
'vscode',
],
shims: ['./language-server/import-meta-url.ts'],
define: {
'import.meta.url': 'import_meta_url',
},
alias: {
'@slidev/parser/fs': fileURLToPath(new URL('../parser/src/fs.ts', import.meta.url)),
'@slidev/parser/core': fileURLToPath(new URL('../parser/src/core.ts', import.meta.url)),
'@slidev/parser/types': fileURLToPath(new URL('../parser/src/types.ts', import.meta.url)),
'@slidev/parser': fileURLToPath(new URL('../parser/src/index.ts', import.meta.url)),
},
plugins: [{
name: 'umd2esm',
setup(build: any) {
build.onResolve({ filter: /^(vscode-.*-languageservice|jsonc-parser)/ }, async (args: any) => {
const pathUmdMay = await resolvePath(args.path, { url: args.resolveDir })
// Call twice the replace is to solve the problem of the path in Windows
const pathEsm = pathUmdMay.replace('/umd/', '/esm/').replace('\\umd\\', '\\esm\\')
return { path: pathEsm }
})
plugins: [
{
name: 'umd2esm',
resolveId: {
filter: {
id: /^(vscode-.*-languageservice|vscode-languageserver-types|jsonc-parser)$/,
},
async handler(source, importer) {
const pathUmdMay = await resolvePath(source, { url: importer })
// Call twice the replace is to solve the problem of the path in Windows
const pathEsm = pathUmdMay.replace('/umd/', '/esm/').replace('\\umd\\', '\\esm\\')
return { id: pathEsm }
},
},
},
}],
],
async onSuccess() {
const assetsDir = join(import.meta.dirname, '../../assets')
const resDir = join(import.meta.dirname, './dist/res')
Expand Down
54 changes: 25 additions & 29 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions pnpm-workspace.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ catalogs:
ovsx: ^0.10.4
playwright-chromium: ^1.53.1
postcss-nested: ^7.0.2
prettier: ^3.5.3
prettier-plugin-slidev: ^1.0.5
rimraf: ^6.0.1
simple-git-hooks: ^2.13.0
Expand Down Expand Up @@ -55,7 +56,6 @@ catalogs:
mermaid: ^11.7.0
nanotar: ^0.2.0
plantuml-encoder: ^1.4.0
prettier: ^3.6.2
recordrtc: ^5.6.2
shiki: ^3.7.0
shiki-magic-move: ^1.1.0
Expand Down Expand Up @@ -147,11 +147,11 @@ catalogs:
'@types/recordrtc': ^5.6.14
'@types/resolve': ^1.20.6
'@types/semver': ^7.7.0
'@types/vscode': ^1.89.0
'@types/yargs': ^17.0.33
vscode:
'@volar/language-server': ~2.4.15
'@volar/vscode': ^2.4.15
'@volar/language-server': ~2.4.14
'@volar/vscode': ^2.4.14
prettier: ^2.8.7
reactive-vscode: ^0.3.0
ts-json-schema-generator: ^2.4.0
volar-service-prettier: ^0.0.64
Expand Down
2 changes: 2 additions & 0 deletions taze.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,5 +6,7 @@ export default defineConfig({
'typeit': 'ignore',
// `engines.vscode` must be updated when bumping `@types/vscode` version
'@types/vscode': 'ignore',
// Prevent multiple versions. `volar-service-yaml` is using v2.
'prettier': 'patch',
},
})