Skip to content

chore(vscode): use unjs/unbuild for bundling #4998

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

Open
wants to merge 33 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
4362e9c
chore: use unbuild
kermanx Nov 8, 2024
0f72495
fix
kermanx Nov 8, 2024
6c064d2
chore: remove scripts/build.js
kermanx Nov 8, 2024
575099a
Merge branch 'master' into chore/use-unbuild
kermanx Nov 8, 2024
0d16758
fix: .vscodeignore
kermanx Nov 8, 2024
6f1b173
fix
kermanx Nov 8, 2024
cdc604e
chore: update
kermanx Nov 8, 2024
46a38bd
add sonda report
kermanx Nov 9, 2024
13daf63
fix
kermanx Nov 9, 2024
2b9f8c4
chore: update
kermanx Nov 12, 2024
e0ab5f9
Merge branch 'master' into chore/use-unbuild
kermanx Dec 15, 2024
9f9a758
chore: update
kermanx Dec 15, 2024
fc2416d
fix
kermanx Dec 15, 2024
d377ade
chore: rename `vscode.js` to `vscode-dev-shim.js`
kermanx Dec 15, 2024
02af765
chore: update
kermanx Dec 15, 2024
516e1b6
fix: should build vue-typescript-plugin-pack
kermanx Dec 15, 2024
7868ce6
fix: use .ts as entry
kermanx Dec 15, 2024
3a180c7
chore: update sonda
kermanx Dec 15, 2024
5764d83
fix!!!
kermanx Dec 17, 2024
2887372
Merge branch 'master' into chore/use-unbuild
kermanx Dec 17, 2024
0460fbc
Merge branch 'master' into pr/4998
johnsoncodehk Dec 18, 2024
af30711
Update pnpm-lock.yaml
johnsoncodehk Dec 18, 2024
e64ff70
refactor(language-service): process references data at runtime to red…
KazariEX Dec 18, 2024
9b11d91
Merge branch 'master' into pr/4998
johnsoncodehk Dec 18, 2024
b3235c9
use `rollup-plugin-visualizer` instead of `sonda`
kermanx Dec 18, 2024
ef6c85d
Merge branch 'master' into pr/4998
johnsoncodehk Dec 18, 2024
866159b
Merge branch 'master' into chore/use-unbuild
kermanx Dec 18, 2024
b17e82d
Merge branch 'chore/use-unbuild' of https://github.com/KermanX/vuejs-…
kermanx Dec 18, 2024
6eceeb6
Merge branch 'master' of https://github.com/vuejs/language-tools into…
kermanx Dec 19, 2024
8c6719e
Merge branch 'master' of https://github.com/vuejs/language-tools into…
KazariEX Apr 17, 2025
770c0f4
chore: bump unbuild version
KazariEX Apr 17, 2025
2b2922a
fix: initialize class members of `VueVirtualCode` correctly
KazariEX Apr 17, 2025
8eaeb65
chore: revert prebuild script
KazariEX Apr 17, 2025
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
Prev Previous commit
Next Next commit
fix
  • Loading branch information
kermanx committed Nov 8, 2024
commit 0f72495c8a484ee6727eb4b12274ce67c5cc5303
8 changes: 0 additions & 8 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
"outFiles": [
"${workspaceRoot}/**/*.js"
],
"preLaunchTask": {
"type": "npm",
"script": "watch"
}
},
{
"name": "Launch Web Client",
Expand All @@ -33,10 +29,6 @@
"outFiles": [
"${workspaceRoot}/**/*.js"
],
"preLaunchTask": {
"type": "npm",
"script": "watch"
}
},
{
"name": "Attach to Language Server",
Expand Down
16 changes: 0 additions & 16 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,22 +12,6 @@
"problemMatcher": [
"$tsc"
]
},
{
"type": "npm",
"script": "watch",
"isBackground": true,
"group": {
"kind": "build",
"isDefault": true
},
"presentation": {
"panel": "dedicated",
"reveal": "never"
},
"problemMatcher": [
"$tsc-watch"
]
}
]
}
106 changes: 56 additions & 50 deletions extensions/vscode/build.config.ts
Original file line number Diff line number Diff line change
@@ -1,56 +1,21 @@
import { defineBuildConfig } from "unbuild";
import { fileURLToPath } from "url";
import { join } from "path";
import { readFileSync, writeFileSync } from "fs";

const __dirname = fileURLToPath(new URL(".", import.meta.url));

export default defineBuildConfig([
// {
// entries: [
// {
// builder: "rollup",
// input: "src/nodeClientMain.ts",
// name: "client",
// },
// ],

// outDir: "dist",

// externals: ["vscode"],

// rollup: {
// emitCJS: true,
// },

// stubOptions: {
// jiti: {
// nativeModules: ["typescript", "vscode"],
// alias: {
// vscode: join(__dirname, "vscode.js"),
// },
// },
// },

// hooks: {
// "build:done"(ctx) {
// if (ctx.options.stub) {
// // Patch the stub file
// const stubFilePath = join(__dirname, "dist/client.cjs");
// const originalStub = readFileSync(stubFilePath, "utf-8");
// const newStub = [
// `globalThis.__VOLAR_DEV_VSCODE__ = require('vscode');`,
// `globalThis.__VOLAR_DEV_FS__ = require('node:fs');`,
// originalStub,
// ].join("\n");
// writeFileSync(stubFilePath, newStub);
// }
// },
// },
// },
{
entries: [
{
builder: "rollup",
input: "./node_modules/@vue/language-server/node.ts",
input: "src/nodeClientMain.ts",
name: "client",
},
{
builder: "rollup",
input: "./node_modules/@vue/language-server/bin/vue-language-server.js",
name: "server",
},
{
Expand All @@ -60,20 +25,61 @@ export default defineBuildConfig([
}
],

failOnWarn: false,

alias: {
// https://github.com/microsoft/vscode-emmet-helper/issues/79
"@vscode/emmet-helper": "@vscode/emmet-helper/lib/cjs/emmetHelper.js"
},

rollup: {
emitCJS: true,
esbuild: {
minify: true,
target: 'ES2021'
},
commonjs: {
transformMixedEsModules: true,
exclude: [/\.json$/],
},
json: {
compact: true,
preferConst: true,
},
inlineDependencies: true,
},

outDir: "dist",

externals: [],
externals: ["vscode"],

stubOptions: {
jiti: {
alias: {
vscode: join(__dirname, "vscode.js"),
},
sourceMaps: true,
},
},

hooks: {
"build:done"(ctx) {
if (ctx.options.stub) {
// Patch the stub file
const stubFilePath = join(__dirname, "dist/client.cjs");
const originalStub = readFileSync(stubFilePath, "utf-8");
const newStub = [
`globalThis.__VOLAR_DEV_VSCODE__ = require('vscode');`,
`globalThis.__VOLAR_DEV_FS__ = require('node:fs');`,
originalStub,
].join("\n");
writeFileSync(stubFilePath, newStub);
}
},
},

// hooks: {
// 'rollup:options'(ctx,options) {
// console.log(options.treeshake)
// }
// }
replace: {
"globalThis.__VOLAR_DEV_FS__": "undefined",
"process.env.NODE_ENV": "'production'"
}
}
]);
3 changes: 2 additions & 1 deletion extensions/vscode/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -545,7 +545,7 @@
"scripts": {
"__prebuild": "pnpm run postinstall && pnpm -C ../.. run build",
"build": "unbuild",
"build:minify": "pnpm run build -- --minify",
"build:minify": "pnpm run build --minify",
"dev": "unbuild --stub",
"pack": "pnpm run build:minify && vsce package",
"pack:next": "pnpm run build && vsce package",
Expand All @@ -555,6 +555,7 @@
"postinstall": "vscode-ext-gen --scope vue"
},
"devDependencies": {
"@types/node": "latest",
"@types/semver": "^7.5.3",
"@types/vscode": "^1.82.0",
"@volar/vscode": "~2.4.8",
Expand Down
7 changes: 3 additions & 4 deletions extensions/vscode/src/nodeClientMain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ 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 * as path from 'node:path';
import { defineExtension, executeCommand, extensionContext, onDeactivate } from 'reactive-vscode';
import * as vscode from 'vscode';
import { config } from './config';
Expand Down Expand Up @@ -137,12 +138,10 @@ try {
'vscode.typescript-language-features'
)!;
const readFileSync = fs.readFileSync;
const extensionJsPath = require.resolve('./dist/extension.js', {
paths: [tsExtension.extensionPath],
});
const extensionJsPath = path.join(tsExtension.extensionPath, './dist/extension.js');

// @ts-expect-error
(globalThis.__VOLAR_DEV_FS__ || fs).readFileSync = (...args) => {
(globalThis.__VOLAR_DEV_FS__ || require('fs')).readFileSync = (...args) => {
if (args[0] === extensionJsPath) {
// @ts-expect-error
let text = readFileSync(...args) as string;
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
"packageManager": "pnpm@9.4.0",
"scripts": {
"build": "tsc -b",
"dev:vue": "pnpm -C ./extensions/vscode dev",
"watch": "pnpm run build && pnpm run \"/^watch:.*/\"",
"watch:base": "tsc -b -w",
"watch:vue": "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
3 changes: 3 additions & 0 deletions pnpm-lock.yaml

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