-
-
Notifications
You must be signed in to change notification settings - Fork 415
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
chore(vscode): use unjs/unbuild
for bundling
#4998
Open
KermanX
wants to merge
29
commits into
vuejs:master
Choose a base branch
from
KermanX:chore/use-unbuild
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
4362e9c
chore: use unbuild
KermanX 0f72495
fix
KermanX 6c064d2
chore: remove scripts/build.js
KermanX 575099a
Merge branch 'master' into chore/use-unbuild
KermanX 0d16758
fix: .vscodeignore
KermanX 6f1b173
fix
KermanX cdc604e
chore: update
KermanX 46a38bd
add sonda report
KermanX 13daf63
fix
KermanX 2b9f8c4
chore: update
KermanX e0ab5f9
Merge branch 'master' into chore/use-unbuild
KermanX 9f9a758
chore: update
KermanX fc2416d
fix
KermanX d377ade
chore: rename `vscode.js` to `vscode-dev-shim.js`
KermanX 02af765
chore: update
KermanX 516e1b6
fix: should build vue-typescript-plugin-pack
KermanX 7868ce6
fix: use .ts as entry
KermanX 3a180c7
chore: update sonda
KermanX 5764d83
fix!!!
KermanX 2887372
Merge branch 'master' into chore/use-unbuild
KermanX 0460fbc
Merge branch 'master' into pr/4998
johnsoncodehk af30711
Update pnpm-lock.yaml
johnsoncodehk e64ff70
refactor(language-service): process references data at runtime to red…
KazariEX 9b11d91
Merge branch 'master' into pr/4998
johnsoncodehk b3235c9
use `rollup-plugin-visualizer` instead of `sonda`
KermanX ef6c85d
Merge branch 'master' into pr/4998
johnsoncodehk 866159b
Merge branch 'master' into chore/use-unbuild
KermanX b17e82d
Merge branch 'chore/use-unbuild' of https://github.com/KermanX/vuejs-…
KermanX 6eceeb6
Merge branch 'master' of https://github.com/vuejs/language-tools into…
KermanX File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,11 @@ | ||
out | ||
scripts | ||
src | ||
tests | ||
tsconfig.* | ||
build.config.ts | ||
vscode-dev-shim.js | ||
meta.json | ||
stats.html | ||
dist/**/*.mjs | ||
dist/**/*.d.ts | ||
dist/**/*.map |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,121 @@ | ||
import { mkdirSync, readFileSync, writeFileSync } from 'node:fs'; | ||
import { join } from 'node:path'; | ||
import { fileURLToPath } from 'node:url'; | ||
import { defineBuildConfig } from 'unbuild'; | ||
import { visualizer } from 'rollup-plugin-visualizer'; | ||
|
||
const __dirname = fileURLToPath(new URL('.', import.meta.url)); | ||
const languageServiceDataRE = /\/language-service\/data\/.*\.json$/; | ||
|
||
export default defineBuildConfig([ | ||
{ | ||
entries: [ | ||
{ | ||
builder: 'rollup', | ||
input: 'src/nodeClientMain.ts', | ||
name: 'client', | ||
}, | ||
{ | ||
builder: 'rollup', | ||
input: './node_modules/@vue/language-server/node.ts', | ||
name: 'server', | ||
}, | ||
{ | ||
builder: 'rollup', | ||
input: './node_modules/@vue/typescript-plugin/index.ts', | ||
name: 'plugin', | ||
}, | ||
{ | ||
builder: 'copy', | ||
input: './node_modules/@vue/language-core/schemas', | ||
outDir: './dist/schemas', | ||
}, | ||
], | ||
failOnWarn: false, | ||
outDir: 'dist', | ||
externals: ['vscode'], | ||
replace: { | ||
'globalThis.__VOLAR_DEV_FS__': 'undefined', | ||
'process.env.NODE_ENV': '"production"', | ||
}, | ||
sourcemap: true, | ||
rollup: { | ||
emitCJS: true, | ||
esbuild: { | ||
target: 'ES2021', | ||
}, | ||
commonjs: { | ||
transformMixedEsModules: true, | ||
exclude: [/\.json$/], | ||
}, | ||
json: { | ||
compact: true, | ||
preferConst: true, | ||
exclude: languageServiceDataRE, | ||
}, | ||
inlineDependencies: true, | ||
}, | ||
stubOptions: { | ||
jiti: { | ||
alias: { | ||
vscode: join(__dirname, 'vscode-dev-shim.js'), | ||
}, | ||
sourceMaps: true, | ||
fsCache: false, | ||
}, | ||
}, | ||
hooks: { | ||
'rollup:options'(_ctx, options) { | ||
options.plugins = [ | ||
// Load language-service data as `JSON.parse(serialized)` | ||
// See https://v8.dev/blog/cost-of-javascript-2019#json | ||
{ | ||
name: 'language-service-data', | ||
transform: { | ||
order: 'pre', | ||
handler(code: string, id: string) { | ||
if (languageServiceDataRE.test(id.replaceAll('\\', '/'))) { | ||
const minimal = JSON.stringify(JSON.parse(code)); | ||
const escaped = minimal.replaceAll(/[$`\\]/g, c => `\\${c}`); | ||
return { | ||
code: `export default JSON.parse(\`${escaped}\`)`, | ||
map: { mappings: '' }, | ||
}; | ||
} | ||
} | ||
} | ||
}, | ||
|
||
visualizer(), | ||
|
||
...options.plugins, | ||
]; | ||
|
||
// Only emit CJS | ||
if (!Array.isArray(options.output)) throw new Error('Unreachable'); | ||
options.output = options.output.filter((option) => option.format === 'cjs'); | ||
if (options.output.length !== 1) throw new Error('Unreachable'); | ||
}, | ||
|
||
'build:done'(ctx) { | ||
// Create the entry point for the TypeScript plugin | ||
const typescriptPluginRoot = join(__dirname, 'node_modules/vue-typescript-plugin-pack'); | ||
mkdirSync(typescriptPluginRoot, { recursive: true }); | ||
writeFileSync(join(typescriptPluginRoot, 'index.js'), 'module.exports = require("../../dist/plugin.cjs");'); | ||
|
||
// Patch the stub files | ||
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); | ||
} | ||
}, | ||
}, | ||
}, | ||
]); |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I noticed that you've replaced
sonda
withrollup-plugin-visualizer
. I will not try to convince you to usesonda
, but if this was a technical decision, could you share the reason? I would appreciate your feedback so I can improve it.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@johnsoncodehk uwu
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @filipsobol, first of all thank you for developing sonda. One of the reasons is that we want the PR to keep the most relevant changes so that it has a greater chance of being merged. Another reason is that the output file treemap is paginated in Sonda, and we cannot visually check whether the modules that need to be shared by multiple files have been correctly split.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you, this gives me some interesting ideas 🤔
By visual check, do you mean manual or automated visual check? You should be able to switch between chunks using the dropdown menu in the upper-left corner, but I can imagine that it may require extra work or even problems in automated tests (e.g. if it visually compares two reports).