Skip to content
Open
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 @@ -56,7 +56,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 @@ -55,7 +55,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.

8 changes: 4 additions & 4 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.99.0"
},
"activationEvents": [
"onStartupFinished"
Expand Down Expand Up @@ -601,7 +601,7 @@
"publish": "tsx scripts/publish.ts",
"pack": "vsce package --no-dependencies",
"prepare": "tsx scripts/schema.ts",
"build": "tsdown --env.NODE_ENV production --treeshake",
"build": "tsdown --env.NODE_ENV production --treeshake --minify",
"dev": "nr prepare && tsdown --watch ./src --watch ./language-server --env.NODE_ENV development",
"vscode:prepublish": "nr build"
},
Expand All @@ -610,13 +610,13 @@
"@slidev/parser": "workspace:*",
"@slidev/types": "workspace:*",
"@types/node": "catalog:types",
"@types/vscode": "catalog:types",
"@types/vscode": "^1.99.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()
7 changes: 1 addition & 6 deletions packages/vscode/syntaxes/codeblock-patch.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import { readFileSync } from 'node:fs'
import { join } from 'node:path'

const Markdown = JSON.parse(
readFileSync(join(import.meta.dirname, '../node_modules/tm-grammars/grammars/markdown.json'), 'utf8'),
)
import Markdown from 'tm-grammars/grammars/markdown.json' with { type: 'json' }

const base = {
$schema: 'https://raw.githubusercontent.com/martinring/tmlanguage/master/tmlanguage.json',
Expand Down
41 changes: 21 additions & 20 deletions packages/vscode/tsdown.config.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { copyFileSync, existsSync, mkdirSync, writeFileSync } from 'node:fs'
import { existsSync } from 'node:fs'
import { copyFile, mkdir, writeFile } from 'node:fs/promises'
import { join } from 'node:path'
import process from 'node:process'
import { fileURLToPath } from 'node:url'
Expand All @@ -7,51 +8,51 @@ 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')

if (!existsSync(resDir))
mkdirSync(resDir, { recursive: true })
await mkdir(resDir, { recursive: true })

for (const file of ['logo-mono.svg', 'logo-mono-dark.svg', 'logo.png', 'logo.svg'])
copyFileSync(join(assetsDir, file), join(resDir, file))
await copyFile(join(assetsDir, file), join(resDir, file))

writeFileSync(
await writeFile(
join(import.meta.dirname, 'syntaxes/codeblock-patch.json'),
JSON.stringify(generateCodeblockPatch(), null, 2),
)
Expand Down
Loading
Loading