Skip to content

chore(vscode): use rolldown for bundling #5337

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

Merged
merged 15 commits into from
Apr 26, 2025
Merged
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
6 changes: 1 addition & 5 deletions .github/workflows/extension-release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ jobs:

- run: pnpm install -g ovsx
- run: pnpm install --frozen-lockfile
- run: pnpm run build:minify && pnpm ovsx publish
- run: pnpm run build:prod && pnpm ovsx publish
working-directory: extensions/vscode
env:
OVSX_PAT: ${{ secrets.OVSX_PAT }}
# - run: pnpm ovsx publish
# working-directory: extensions/vscode-typescript-plugin
# env:
# OVSX_PAT: ${{ secrets.OVSX_PAT }}
13 changes: 10 additions & 3 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,16 @@
"panel": "dedicated",
"reveal": "never"
},
"problemMatcher": [
"$tsc-watch"
]
"problemMatcher": {
"pattern": {
"regexp": "__________"
},
"background": {
"activeOnStart": true,
"beginsPattern": " ",
"endsPattern": "Waiting for changes..."
}
}
}
]
}
5 changes: 0 additions & 5 deletions extensions/vscode/client.js

This file was deleted.

20 changes: 8 additions & 12 deletions extensions/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
"onLanguage:markdown",
"onLanguage:html"
],
"main": "./client.js",
"main": "./dist/client.js",
"browser": "./web.js",
"capabilities": {
"virtualWorkspaces": {
Expand Down Expand Up @@ -485,28 +485,24 @@
]
},
"scripts": {
"prebuild": "pnpm run postinstall && pnpm -C ../.. run build",
"build": "node scripts/build",
"build:minify": "pnpm run build -- --minify",
"watch": "pnpm run build -- --watch",
"pack": "pnpm run build:minify && vsce package",
"pack:next": "pnpm run build && vsce package",
"release": "pnpm run build:minify && vsce publish",
"release:next": "pnpm run build && vsce publish --pre-release",
"size": "pnpm run build:minify -- --metafile && esbuild-visualizer --metadata ./meta.json && open ./stats.html",
"build:dev": "rolldown --config",
"build:prod": "rolldown --minify --config",
"watch": "rolldown --watch --config",
"pack": "pnpm run build:prod && vsce package",
"release": "pnpm run build:prod && vsce publish",
"postinstall": "vscode-ext-gen --scope vue"
},
"devDependencies": {
"@types/node": "^22.10.4",
"@types/semver": "^7.5.3",
"@types/vscode": "^1.82.0",
"@volar/vscode": "~2.4.13",
"@vscode/vsce": "^3.2.1",
"@vue/language-core": "3.0.0-alpha.4",
"@vue/language-server": "3.0.0-alpha.4",
"@vue/typescript-plugin": "3.0.0-alpha.4",
"esbuild": "^0.25.0",
"esbuild-visualizer": "^0.7.0",
"reactive-vscode": "^0.2.9",
"rolldown": "1.0.0-beta.8",
"semver": "^7.5.4",
"vscode-ext-gen": "^0.5.0",
"vscode-tmlanguage-snapshot": "^0.1.3"
Expand Down
61 changes: 61 additions & 0 deletions extensions/vscode/rolldown.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
import * as fs from 'node:fs';
import * as path from 'node:path';
import { defineConfig } from 'rolldown';

const resolve = (...paths: string[]) => path.resolve(__dirname, ...paths);

export default defineConfig({
input: {
'client': './src/nodeClientMain.ts',
'server': './node_modules/@vue/language-server/node.ts',
'plugin': './node_modules/@vue/typescript-plugin/index.ts',
},
output: {
format: 'cjs',
sourcemap: !process.argv.includes('--minify'),
},
define: {
'process.env.NODE_ENV': '"production"',
},
external: ['vscode'],
plugins: [
{
name: 'umd2esm',
resolveId: {
filter: {
id: /^(vscode-.*-languageservice|vscode-languageserver-types|jsonc-parser)$/,
},
handler(source, importer) {
const pathUmdMay = require.resolve(source, { paths: [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 };
},
},
},
{
name: 'clean',
buildStart() {
fs.rmSync(resolve('./dist'), { recursive: true, force: true });
},
},
{
name: 'schemas',
buildEnd() {
fs.cpSync(
resolve('./node_modules/@vue/language-core/schemas/vue-tsconfig.schema.json'),
resolve('./dist/schemas/vue-tsconfig.schema.json'),
{ recursive: true }
);
},
},
{
name: 'typescript-plugin',
buildEnd() {
const dir = './node_modules/vue-typescript-plugin-pack';
fs.mkdirSync(resolve(dir), { recursive: true });
fs.writeFileSync(resolve(dir, 'index.js'), `module.exports = require('../../dist/plugin.js');`);
},
},
],
});
106 changes: 0 additions & 106 deletions extensions/vscode/scripts/build.js

This file was deleted.

5 changes: 0 additions & 5 deletions extensions/vscode/server.js

This file was deleted.

6 changes: 2 additions & 4 deletions extensions/vscode/src/nodeClientMain.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import { createLabsInfo } from '@volar/vscode';
import * as lsp from '@volar/vscode/node';
import * as protocol from '@vue/language-server/protocol';
import * as fs from 'node:fs';
import { defineExtension, executeCommand, extensionContext, onDeactivate } from 'reactive-vscode';
import * as vscode from 'vscode';
import { config } from './config';
Expand Down Expand Up @@ -50,7 +49,7 @@ export const { activate, deactivate } = defineExtension(async () => {
}
}

let serverModule = vscode.Uri.joinPath(context.extensionUri, 'server.js');
let serverModule = vscode.Uri.joinPath(context.extensionUri, 'dist', 'server.js');

const serverOptions: lsp.ServerOptions = {
run: {
Expand Down Expand Up @@ -134,6 +133,7 @@ function updateProviders(client: lsp.LanguageClient) {
}

try {
const fs = require('node:fs');
const tsExtension = vscode.extensions.getExtension('vscode.typescript-language-features')!;
const readFileSync = fs.readFileSync;
const extensionJsPath = require.resolve('./dist/extension.js', {
Expand All @@ -143,7 +143,6 @@ try {
// @ts-expect-error
fs.readFileSync = (...args) => {
if (args[0] === extensionJsPath) {
// @ts-expect-error
let text = readFileSync(...args) as string;

// patch readPlugins
Expand Down Expand Up @@ -196,7 +195,6 @@ try {

return text;
}
// @ts-expect-error
return readFileSync(...args);
};

Expand Down
9 changes: 2 additions & 7 deletions extensions/vscode/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,14 +1,9 @@
{
"extends": "../../tsconfig.base.json",
"compilerOptions": {
"outDir": "out",
"rootDir": "src",
"noEmit": true,
"module": "CommonJS",
"moduleResolution": "Node"
},
"include": [ "src" ],
"references": [
{ "path": "../../packages/language-server/tsconfig.json" },
{ "path": "../../packages/typescript-plugin/tsconfig.json" },
],
"include": [ "src", "rolldown.config.ts" ]
}
7 changes: 3 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,7 @@
"packageManager": "[email protected]",
"scripts": {
"build": "tsc -b",
"watch": "pnpm run build && pnpm run \"/^watch:.*/\"",
"watch:base": "tsc -b -w",
"watch:vue": "cd ./extensions/vscode && pnpm run watch",
"watch": "cd ./extensions/vscode && pnpm run watch",
"prerelease": "pnpm run build && pnpm run test",
"release": "pnpm run release:base && pnpm run release:vue",
"release:base": "lerna publish --exact --force-publish --yes --sync-workspace-lock --no-git-tag-version",
Expand Down Expand Up @@ -34,7 +32,8 @@
"@tsslint/core",
"@vscode/vsce-sign",
"esbuild",
"keytar"
"keytar",
"rolldown"
]
}
}
2 changes: 1 addition & 1 deletion packages/language-server/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
"include": [ "*", "lib/**/*" ],
"exclude": [ "tests" ],
"references": [
{ "path": "../component-meta/tsconfig.json" },
{ "path": "../language-core/tsconfig.json" },
{ "path": "../language-service/tsconfig.json" },
{ "path": "../component-meta/tsconfig.json" },
],
}
Loading