-
-
Notifications
You must be signed in to change notification settings - Fork 80
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: Bundle the extension using esbuild #421
base: master
Are you sure you want to change the base?
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -6,28 +6,29 @@ | |
"type": "extensionHost", | ||
"request": "launch", | ||
"runtimeExecutable": "${execPath}", | ||
"args": ["--extensionDevelopmentPath=${workspaceRoot}"], | ||
"stopOnEntry": false, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. stopOnEntry is reported invalid entry in my vscode, thus removing it. |
||
"args": ["--extensionDevelopmentPath=${workspaceFolder}"], | ||
"sourceMaps": true, | ||
"outFiles": ["${workspaceRoot}/out/src/**/*.js"], | ||
"preLaunchTask": "npm" | ||
"outFiles": ["${workspaceFolder}/dist/**/*.js"], | ||
"preLaunchTask": "npm: compile" | ||
}, | ||
{ | ||
"name": "Launch Debug Server", | ||
"type": "node", | ||
"request": "launch", | ||
"cwd": "${workspaceFolder}", | ||
"program": "${workspaceFolder}/src/debug-adapter/client.ts", | ||
"program": "${workspaceFolder}/dist/debug-adapter-client.js", | ||
"args": ["--server=4711"], | ||
"sourceMaps": true, | ||
"outFiles": ["${workspaceRoot}/out/src/**/*.js"] | ||
"outFiles": ["${workspaceFolder}/dist/**/*.js"] | ||
}, | ||
{ | ||
"name": "Launch Extension Tests", | ||
"type": "extensionHost", | ||
"request": "launch", | ||
"testConfiguration": "${workspaceFolder}/.vscode-test.js", | ||
"args": ["--extensionDevelopmentPath=${workspaceFolder}"] | ||
"args": ["--extensionDevelopmentPath=${workspaceFolder}"], | ||
"sourceMaps": true, | ||
"outFiles": ["${workspaceFolder}/out/**/*.js"] | ||
} | ||
], | ||
"compounds": [ | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -0,0 +1,10 @@ | ||||||
# Ignore all files by default. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I found some examples and practices using |
||||||
**/* | ||||||
|
||||||
!README.md | ||||||
!LICENSE | ||||||
!package.json | ||||||
!dist/**/*.js | ||||||
!icons/**/*.+(svg|license) | ||||||
!media/**/* | ||||||
!syntaxes/**/*.+(json|yaml|license) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yaml file shouldn't be included in the extension, only the form that's been compiled to json.
Suggested change
Do note that it was previously excluded. |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
const esbuild = require("esbuild"); | ||
|
||
const production = process.argv.includes("--production"); | ||
const watch = process.argv.includes("--watch"); | ||
|
||
/** | ||
* @type {import('esbuild').Plugin} | ||
*/ | ||
const esbuildProblemMatcherPlugin = { | ||
name: "esbuild-problem-matcher", | ||
|
||
setup(build) { | ||
build.onStart(() => { | ||
console.log("[watch] build started"); | ||
}); | ||
build.onEnd((result) => { | ||
result.errors.forEach(({ text, location }) => { | ||
console.error(`✘ [ERROR] ${text}`); | ||
console.error( | ||
` ${location.file}:${location.line}:${location.column}:`, | ||
); | ||
}); | ||
console.log("[watch] build finished"); | ||
}); | ||
}, | ||
}; | ||
|
||
async function main() { | ||
const ctx = await esbuild.context({ | ||
entryPoints: ["src/debug-adapter/client.ts"], | ||
bundle: true, | ||
format: "cjs", | ||
minify: production, | ||
sourcemap: !production, | ||
sourcesContent: false, | ||
platform: "node", | ||
outfile: "dist/debug-adapter-client.js", | ||
external: ["vscode"], | ||
logLevel: "silent", | ||
plugins: [ | ||
/* add to the end of plugins array */ | ||
esbuildProblemMatcherPlugin, | ||
], | ||
}); | ||
if (watch) { | ||
await ctx.watch(); | ||
} else { | ||
await ctx.rebuild(); | ||
await ctx.dispose(); | ||
} | ||
} | ||
|
||
main().catch((e) => { | ||
console.error(e); | ||
process.exit(1); | ||
}); |
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.
workspaceRoot is now deprecated