-
Notifications
You must be signed in to change notification settings - Fork 57
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
feat: Add web extension support for syntax highlighting #2323
Merged
slavek-kucera
merged 27 commits into
eclipse-che4z:development
from
mm-broadcom:web-extension-support
Jun 14, 2024
Merged
Changes from 14 commits
Commits
Show all changes
27 commits
Select commit
Hold shift + click to select a range
5a5abc0
Add web extension support for syntax highlighting
mm-broadcom 6027c31
Limit commands in web context
mm-broadcom f606e48
Update web extension output directory
mm-broadcom 97bdfbb
Update Build.sh to build web extension
mm-broadcom 035a21b
Change Web build command to "browser" as platform
mm-broadcom 878ef80
Update packaage.json to change "when" clauses
mm-broadcom b5ffdca
Add package command for web extension
mm-broadcom 5a56dd0
Replace webpack with esbuild
mm-broadcom 97c39a4
Add web build to build.yml
mm-broadcom c20d318
Remove unused Webpack-related packages
mm-broadcom 5d2ef40
Add package:web step to Github workflow
mm-broadcom 53df542
Update package-lock.json
mm-broadcom 0b1a714
Revert "Update package-lock.json"
mm-broadcom 65dda45
Updated package-lock.json
mm-broadcom bb38cc0
Fix assert build issues
mm-broadcom b1581d0
Remove Node Polyfill
mm-broadcom b0754fe
Make buildWeb a separate job step for CI
mm-broadcom 65e4e80
Ran Prettier
mm-broadcom 202ec87
Add upload step to buildWeb job
mm-broadcom 8130852
Update .github/workflows/build.yml
mm-broadcom c39993b
TDD fixes for web extension
mm-broadcom 78062a4
Merge branch 'web-extension-support' of https://github.com/mm-broadco…
mm-broadcom 270363f
Rename esbuild.js
mm-broadcom 9831f12
Update .vscodeignore
mm-broadcom 3801e9a
Fix web build and package
mm-broadcom 3c8898b
Add production flag to web build in prepackage
mm-broadcom 440ddd9
Update .vscodeignore
mm-broadcom 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -131,6 +131,7 @@ local.properties | |
out | ||
*.vsix | ||
.vscode-test | ||
.vscode-test-web | ||
node_modules | ||
tools | ||
logs/app.log | ||
|
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 |
---|---|---|
@@ -0,0 +1,100 @@ | ||
const esbuild = require('esbuild'); | ||
const glob = require('glob'); | ||
const path = require('path'); | ||
const polyfill = require('@esbuild-plugins/node-globals-polyfill'); | ||
|
||
const production = process.argv.includes('--production'); | ||
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 don't think that the argument is actually provided in the build scripts. |
||
const watch = process.argv.includes('--watch'); | ||
|
||
/** | ||
* This plugin hooks into the build process to print errors in a format that the problem matcher in | ||
* Visual Studio Code can understand. | ||
* @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'); | ||
}); | ||
}, | ||
}; | ||
|
||
|
||
/** | ||
* For web extension, all tests, including the test runner, need to be bundled into | ||
* a single module that has a exported `run` function . | ||
* This plugin bundles implements a virtual file extensionTests.ts that bundles all these together. | ||
* @type {import('esbuild').Plugin} | ||
*/ | ||
const testBundlePlugin = { | ||
name: 'testBundlePlugin', | ||
setup(build) { | ||
build.onResolve({ filter: /[\/\\]extensionTests\.ts$/ }, args => { | ||
if (args.kind === 'entry-point') { | ||
return { path: path.resolve(args.path) }; | ||
} | ||
}); | ||
build.onLoad({ filter: /[\/\\]extensionTests\.ts$/ }, async args => { | ||
const testsRoot = path.join(__dirname, 'src/web/test/suite'); | ||
const files = await glob.glob('*.test.{ts,tsx}', { cwd: testsRoot, posix: true }); | ||
return { | ||
contents: | ||
`export { run } from './mochaTestRunner.ts';` + | ||
files.map(f => `import('./${f}');`).join(''), | ||
watchDirs: files.map(f => path.dirname(path.resolve(testsRoot, f))), | ||
watchFiles: files.map(f => path.resolve(testsRoot, f)) | ||
}; | ||
}); | ||
} | ||
}; | ||
|
||
async function main() { | ||
const ctx = await esbuild.context({ | ||
entryPoints: [ | ||
'src/web/extension.ts', | ||
'src/web/test/suite/extensionTests.ts' | ||
], | ||
bundle: true, | ||
format: 'cjs', | ||
minify: production, | ||
sourcemap: !production, | ||
sourcesContent: false, | ||
platform: 'browser', | ||
outdir: 'dist/web', | ||
external: ['vscode'], | ||
logLevel: 'silent', | ||
// Node.js global to browser globalThis | ||
define: { | ||
global: 'globalThis', | ||
}, | ||
|
||
plugins: [ | ||
mm-broadcom marked this conversation as resolved.
Show resolved
Hide resolved
|
||
polyfill.NodeGlobalsPolyfillPlugin({ | ||
process: true, | ||
buffer: true, | ||
}), | ||
mm-broadcom marked this conversation as resolved.
Show resolved
Hide resolved
|
||
testBundlePlugin, | ||
esbuildProblemMatcherPlugin, /* add to the end of plugins array */ | ||
], | ||
}); | ||
if (watch) { | ||
await ctx.watch(); | ||
} else { | ||
await ctx.rebuild(); | ||
await ctx.dispose(); | ||
} | ||
} | ||
|
||
main().catch(e => { | ||
console.error(e); | ||
process.exit(1); | ||
}); |
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.
This will run 6x (once in each native configuration) and possibly overwrite the "desktop" VSIX package.
I suggest creating a separate job (e.g. buildWeb) in this file that will just do
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.
It makes a separate vsix file with the name
cobol-language-support-web-[version]
whereversion
is the latest numbered version. (2.1.2 as of this writing.)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.
Made a separate job for building the web extension. Will need some help with the upload as there isn't an existing one to handle the artifact.
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.
che-che4z-lsp-for-cobol/.github/workflows/build.yml
Lines 344 to 348 in 2c0b20f