-
Notifications
You must be signed in to change notification settings - Fork 1.8k
editor/code: Allow to apply static analysis for codes opened in webview #15256
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
Closed
tetsuharuohzeki
wants to merge
7
commits into
rust-lang:master
from
tetsuharuohzeki:bundle-webview-code
Closed
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
0db8b0b
editor/code: Sort the indent size
tetsuharuohzeki 6efe9cd
editor/code: Use build script invoking esbuild instead of invoking CLI
tetsuharuohzeki 9f98c33
editor/code: Allow to Type Checking "view memory layout" webview code
tetsuharuohzeki a7d7343
editor/code: Enable ESLint for editors/code/webview/view_memory_layou…
tetsuharuohzeki f32a2ea
fixup! editor/code: Enable ESLint for editors/code/webview/view_memor…
tetsuharuohzeki 47ee06c
editor/code: Remove unnecessary `meta[http-equiv=X-UA-Compatible]
tetsuharuohzeki 80ac389
editor/code: Allow to Type Checking "show crate graph" webview code
tetsuharuohzeki 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 hidden or 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 hidden or 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 hidden or 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 hidden or 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,94 @@ | ||
import * as path from "node:path"; | ||
import { parseArgs } from "node:util"; | ||
import * as esbuild from "esbuild"; | ||
|
||
function parseCliOptions() { | ||
const { values } = parseArgs({ | ||
options: { | ||
minify: { | ||
type: "boolean", | ||
default: false, | ||
}, | ||
sourcemap: { | ||
type: "boolean", | ||
default: false, | ||
}, | ||
watch: { | ||
type: "boolean", | ||
default: false, | ||
}, | ||
}, | ||
strict: true, | ||
}); | ||
return { | ||
shouldMinify: !!values.minify, | ||
shouldEmitSourceMap: !!values.sourcemap, | ||
isWatchMode: !!values.watch, | ||
}; | ||
} | ||
|
||
const { shouldMinify, shouldEmitSourceMap, isWatchMode } = parseCliOptions(); | ||
|
||
const OUT_DIR = "./out"; | ||
const OUT_WEBVIEW_DIR = path.resolve(OUT_DIR, "webview"); | ||
|
||
/** @type {esbuild.BuildOptions} */ | ||
const BASE_OPTIONS = { | ||
minify: shouldMinify, | ||
sourcemap: shouldEmitSourceMap ? "external" : false, | ||
bundle: true, | ||
}; | ||
|
||
function createBuildOption(entryPoints) { | ||
/** @type {esbuild.BuildOptions} */ | ||
const options = { | ||
...BASE_OPTIONS, | ||
entryPoints, | ||
external: ["vscode"], | ||
format: "cjs", | ||
platform: "node", | ||
target: "node16", | ||
outdir: OUT_DIR, | ||
}; | ||
return options; | ||
} | ||
|
||
function createBuildOptionForWebView(entryPoints) { | ||
/** @type {esbuild.BuildOptions} */ | ||
const options = { | ||
...BASE_OPTIONS, | ||
entryPoints, | ||
format: "esm", | ||
platform: "browser", | ||
// VSCode v1.78 (Electron 22) uses Chromium 108. | ||
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. We're back on 1.75 since #15333. 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'll update to: - // VSCode v1.78 (Electron 22) uses Chromium 108.
+ // VSCode v1.75 (Electron 19) uses Chromium 102. |
||
// https://code.visualstudio.com/updates/v1_78 | ||
target: "chrome108", | ||
outdir: OUT_WEBVIEW_DIR, | ||
}; | ||
return options; | ||
} | ||
|
||
async function bundleSource(options) { | ||
if (!isWatchMode) { | ||
return esbuild.build(options); | ||
} | ||
|
||
const ctx = await esbuild.context(options); | ||
return ctx.watch(); | ||
} | ||
|
||
await Promise.all([ | ||
bundleSource(createBuildOption(["src/main.ts"])), | ||
bundleSource( | ||
createBuildOptionForWebView([ | ||
"src/webview/show_crate_graph.ts", | ||
"src/webview/show_crate_graph.css", | ||
]), | ||
), | ||
bundleSource( | ||
createBuildOptionForWebView([ | ||
"src/webview/view_memory_layout.ts", | ||
"src/webview/view_memory_layout.css", | ||
]), | ||
), | ||
]); |
This file contains hidden or 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.
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.
Uh oh!
There was an error while loading. Please reload this page.