-
-
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?
Conversation
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.
Thanks for this PR! Properly bundling and minifying the extensions has been on my TODO list for a long time already.
I know that there were discussions on "should we build this extension via Bazel", but afaik they stalled. As such, I would be happy to move on with this PR. We can later still switch to Bazel, in case somebody is willing to put in the effort for this switch
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.
Looks good to me. I am still waiting before merging this, to also give others a chance to review
I did a quick try (still not working) for using Bazel build for building this extension. It is more complicated even for only making a Just saw #340 working on Bazel build, would move the discussion there. |
Icon paths need to be fixed. |
The esbuild.js is copied from VSCode extension generator template (github.com/microsoft/vscode-generator-code/tree/4812b7e/generators/app/templates/ext-command-ts/vscode-esbuild) then format fixed by prettier. This reduces the package size from ~5MB -> ~250KB.
d336fe7
to
d685dbb
Compare
I just made the corresponding changes in launch.json to support the debugging. I only validate that local breakpoint could be set in either "Launch Extension" and "Launch Extension Tests". However I don't think I'm really understand how / why Debug Server works. It seems to be a debugging service for bazel build file instead of the plugin or typescript/javascript stuffs. I just made them into another binary, updating the referencedin |
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
stopOnEntry is reported invalid entry in my vscode, thus removing it.
@@ -6,28 +6,29 @@ | |||
"type": "extensionHost", | |||
"request": "launch", | |||
"runtimeExecutable": "${execPath}", | |||
"args": ["--extensionDevelopmentPath=${workspaceRoot}"], |
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
@@ -0,0 +1,10 @@ | |||
# Ignore all files by default. |
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 found some examples and practices using .vscodeignore
for white listing: so that we can invoke the vsce
without changing the working directory or copying the included resources, and the layout for the resources should be the same no matter we minified or not.
Still looking into the "watch" flow. I also have no idea for how to test these flow automatically to prevent regression. |
@@ -483,6 +488,7 @@ | |||
"eslint-plugin-jsdoc": "^48.2.2", | |||
"js-yaml": "^4.1.0", | |||
"mocha": "^10.4.0", | |||
"npm-run-all": "^4.1.5", | |||
"prettier": "^3.2.5", |
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.
The usage of npm-run-all
is referenced from https://github.com/microsoft/vscode-generator-code/blob/4812b7e/generators/app/templates/ext-command-ts/vscode-esbuild/package.json, but it has 1700+ dependent packages... I can revoke the modification for watch since I found it not really useful for vscode IDE...
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.
That does seem like a lot of extra dependency weight (with the attendant impact on CI times and security alert noise) for something of marginal utility. Developers need to take explicit action to reload the extension anyway.
@@ -483,6 +488,7 @@ | |||
"eslint-plugin-jsdoc": "^48.2.2", | |||
"js-yaml": "^4.1.0", | |||
"mocha": "^10.4.0", | |||
"npm-run-all": "^4.1.5", | |||
"prettier": "^3.2.5", |
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.
That does seem like a lot of extra dependency weight (with the attendant impact on CI times and security alert noise) for something of marginal utility. Developers need to take explicit action to reload the extension anyway.
js-yaml syntaxes/bazelrc.tmLanguage.yaml > syntaxes/bazelrc.tmLanguage.json | ||
|
||
# Compile the rest of the project. | ||
# Compile the rest of the project for development flow like testing. | ||
tsc "$@" -p ./ |
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.
Why do you still need tsc
here? esbuild
handles compilation. Running tsc
remains useful for testing but not so much for build.
!dist/**/*.js | ||
!icons/**/*.+(svg|license) | ||
!media/**/* | ||
!syntaxes/**/*.+(json|yaml|license) |
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.
yaml file shouldn't be included in the extension, only the form that's been compiled to json.
!syntaxes/**/*.+(json|yaml|license) | |
!syntaxes/**/*.+(json|license) |
Do note that it was previously excluded.
This should not affect the existing build and test flow, but adding an additional step right before building vsix package.
The esbuild.js is copied from VSCode extension generator template then format fixed by prettier.
This reduces the package size from ~5MB -> ~250KB.