Skip to content

Commit f387371

Browse files
authored
chore(vscode): use rolldown for bundling (#5337)
1 parent 48c4578 commit f387371

File tree

13 files changed

+300
-203
lines changed

13 files changed

+300
-203
lines changed

.github/workflows/extension-release.yml

+1-5
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,7 @@ jobs:
2121

2222
- run: pnpm install -g ovsx
2323
- run: pnpm install --frozen-lockfile
24-
- run: pnpm run build:minify && pnpm ovsx publish
24+
- run: pnpm run build:prod && pnpm ovsx publish
2525
working-directory: extensions/vscode
2626
env:
2727
OVSX_PAT: ${{ secrets.OVSX_PAT }}
28-
# - run: pnpm ovsx publish
29-
# working-directory: extensions/vscode-typescript-plugin
30-
# env:
31-
# OVSX_PAT: ${{ secrets.OVSX_PAT }}

.vscode/tasks.json

+10-3
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,16 @@
2525
"panel": "dedicated",
2626
"reveal": "never"
2727
},
28-
"problemMatcher": [
29-
"$tsc-watch"
30-
]
28+
"problemMatcher": {
29+
"pattern": {
30+
"regexp": "__________"
31+
},
32+
"background": {
33+
"activeOnStart": true,
34+
"beginsPattern": " ",
35+
"endsPattern": "Waiting for changes..."
36+
}
37+
}
3138
}
3239
]
3340
}

extensions/vscode/client.js

-5
This file was deleted.

extensions/vscode/package.json

+8-12
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
"onLanguage:markdown",
2727
"onLanguage:html"
2828
],
29-
"main": "./client.js",
29+
"main": "./dist/client.js",
3030
"browser": "./web.js",
3131
"capabilities": {
3232
"virtualWorkspaces": {
@@ -485,28 +485,24 @@
485485
]
486486
},
487487
"scripts": {
488-
"prebuild": "pnpm run postinstall && pnpm -C ../.. run build",
489-
"build": "node scripts/build",
490-
"build:minify": "pnpm run build -- --minify",
491-
"watch": "pnpm run build -- --watch",
492-
"pack": "pnpm run build:minify && vsce package",
493-
"pack:next": "pnpm run build && vsce package",
494-
"release": "pnpm run build:minify && vsce publish",
495-
"release:next": "pnpm run build && vsce publish --pre-release",
496-
"size": "pnpm run build:minify -- --metafile && esbuild-visualizer --metadata ./meta.json && open ./stats.html",
488+
"build:dev": "rolldown --config",
489+
"build:prod": "rolldown --minify --config",
490+
"watch": "rolldown --watch --config",
491+
"pack": "pnpm run build:prod && vsce package",
492+
"release": "pnpm run build:prod && vsce publish",
497493
"postinstall": "vscode-ext-gen --scope vue"
498494
},
499495
"devDependencies": {
496+
"@types/node": "^22.10.4",
500497
"@types/semver": "^7.5.3",
501498
"@types/vscode": "^1.82.0",
502499
"@volar/vscode": "~2.4.13",
503500
"@vscode/vsce": "^3.2.1",
504501
"@vue/language-core": "3.0.0-alpha.4",
505502
"@vue/language-server": "3.0.0-alpha.4",
506503
"@vue/typescript-plugin": "3.0.0-alpha.4",
507-
"esbuild": "^0.25.0",
508-
"esbuild-visualizer": "^0.7.0",
509504
"reactive-vscode": "^0.2.9",
505+
"rolldown": "1.0.0-beta.8",
510506
"semver": "^7.5.4",
511507
"vscode-ext-gen": "^0.5.0",
512508
"vscode-tmlanguage-snapshot": "^0.1.3"

extensions/vscode/rolldown.config.ts

+61
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
import * as fs from 'node:fs';
2+
import * as path from 'node:path';
3+
import { defineConfig } from 'rolldown';
4+
5+
const resolve = (...paths: string[]) => path.resolve(__dirname, ...paths);
6+
7+
export default defineConfig({
8+
input: {
9+
'client': './src/nodeClientMain.ts',
10+
'server': './node_modules/@vue/language-server/node.ts',
11+
'plugin': './node_modules/@vue/typescript-plugin/index.ts',
12+
},
13+
output: {
14+
format: 'cjs',
15+
sourcemap: !process.argv.includes('--minify'),
16+
},
17+
define: {
18+
'process.env.NODE_ENV': '"production"',
19+
},
20+
external: ['vscode'],
21+
plugins: [
22+
{
23+
name: 'umd2esm',
24+
resolveId: {
25+
filter: {
26+
id: /^(vscode-.*-languageservice|vscode-languageserver-types|jsonc-parser)$/,
27+
},
28+
handler(source, importer) {
29+
const pathUmdMay = require.resolve(source, { paths: [importer!] });
30+
// Call twice the replace is to solve the problem of the path in Windows
31+
const pathEsm = pathUmdMay.replace('/umd/', '/esm/').replace('\\umd\\', '\\esm\\');
32+
return { id: pathEsm };
33+
},
34+
},
35+
},
36+
{
37+
name: 'clean',
38+
buildStart() {
39+
fs.rmSync(resolve('./dist'), { recursive: true, force: true });
40+
},
41+
},
42+
{
43+
name: 'schemas',
44+
buildEnd() {
45+
fs.cpSync(
46+
resolve('./node_modules/@vue/language-core/schemas/vue-tsconfig.schema.json'),
47+
resolve('./dist/schemas/vue-tsconfig.schema.json'),
48+
{ recursive: true }
49+
);
50+
},
51+
},
52+
{
53+
name: 'typescript-plugin',
54+
buildEnd() {
55+
const dir = './node_modules/vue-typescript-plugin-pack';
56+
fs.mkdirSync(resolve(dir), { recursive: true });
57+
fs.writeFileSync(resolve(dir, 'index.js'), `module.exports = require('../../dist/plugin.js');`);
58+
},
59+
},
60+
],
61+
});

extensions/vscode/scripts/build.js

-106
This file was deleted.

extensions/vscode/server.js

-5
This file was deleted.

extensions/vscode/src/nodeClientMain.ts

+2-4
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { createLabsInfo } from '@volar/vscode';
22
import * as lsp from '@volar/vscode/node';
33
import * as protocol from '@vue/language-server/protocol';
4-
import * as fs from 'node:fs';
54
import { defineExtension, executeCommand, extensionContext, onDeactivate } from 'reactive-vscode';
65
import * as vscode from 'vscode';
76
import { config } from './config';
@@ -50,7 +49,7 @@ export const { activate, deactivate } = defineExtension(async () => {
5049
}
5150
}
5251

53-
let serverModule = vscode.Uri.joinPath(context.extensionUri, 'server.js');
52+
let serverModule = vscode.Uri.joinPath(context.extensionUri, 'dist', 'server.js');
5453

5554
const serverOptions: lsp.ServerOptions = {
5655
run: {
@@ -134,6 +133,7 @@ function updateProviders(client: lsp.LanguageClient) {
134133
}
135134

136135
try {
136+
const fs = require('node:fs');
137137
const tsExtension = vscode.extensions.getExtension('vscode.typescript-language-features')!;
138138
const readFileSync = fs.readFileSync;
139139
const extensionJsPath = require.resolve('./dist/extension.js', {
@@ -143,7 +143,6 @@ try {
143143
// @ts-expect-error
144144
fs.readFileSync = (...args) => {
145145
if (args[0] === extensionJsPath) {
146-
// @ts-expect-error
147146
let text = readFileSync(...args) as string;
148147

149148
// patch readPlugins
@@ -196,7 +195,6 @@ try {
196195

197196
return text;
198197
}
199-
// @ts-expect-error
200198
return readFileSync(...args);
201199
};
202200

extensions/vscode/tsconfig.json

+2-7
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,9 @@
11
{
22
"extends": "../../tsconfig.base.json",
33
"compilerOptions": {
4-
"outDir": "out",
5-
"rootDir": "src",
4+
"noEmit": true,
65
"module": "CommonJS",
76
"moduleResolution": "Node"
87
},
9-
"include": [ "src" ],
10-
"references": [
11-
{ "path": "../../packages/language-server/tsconfig.json" },
12-
{ "path": "../../packages/typescript-plugin/tsconfig.json" },
13-
],
8+
"include": [ "src", "rolldown.config.ts" ]
149
}

package.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,7 @@
33
"packageManager": "pnpm@10.4.1",
44
"scripts": {
55
"build": "tsc -b",
6-
"watch": "pnpm run build && pnpm run \"/^watch:.*/\"",
7-
"watch:base": "tsc -b -w",
8-
"watch:vue": "cd ./extensions/vscode && pnpm run watch",
6+
"watch": "cd ./extensions/vscode && pnpm run watch",
97
"prerelease": "pnpm run build && pnpm run test",
108
"release": "pnpm run release:base && pnpm run release:vue",
119
"release:base": "lerna publish --exact --force-publish --yes --sync-workspace-lock --no-git-tag-version",
@@ -34,7 +32,8 @@
3432
"@tsslint/core",
3533
"@vscode/vsce-sign",
3634
"esbuild",
37-
"keytar"
35+
"keytar",
36+
"rolldown"
3837
]
3938
}
4039
}

packages/language-server/tsconfig.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"include": [ "*", "lib/**/*" ],
44
"exclude": [ "tests" ],
55
"references": [
6+
{ "path": "../component-meta/tsconfig.json" },
67
{ "path": "../language-core/tsconfig.json" },
78
{ "path": "../language-service/tsconfig.json" },
8-
{ "path": "../component-meta/tsconfig.json" },
99
],
1010
}

0 commit comments

Comments
 (0)