-
Notifications
You must be signed in to change notification settings - Fork 50
Build from source some extensions that were previously bundled. #775
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
Open
rgrunber
wants to merge
3
commits into
che-incubator:main
Choose a base branch
from
rgrunber:bundled-artifacts
base: main
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
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| #!/usr/bin/env node | ||
|
|
||
| import fs from 'fs'; | ||
| import path from 'path'; | ||
|
|
||
| const scriptDir = import.meta.dirname; | ||
| const codeDir = path.join(scriptDir, '..'); | ||
|
|
||
| // Map of build script filename -> target extension directory | ||
| const scripts = { | ||
| 'js-debug.esbuild.ts': 'extensions/js-debug', | ||
| 'js-debug-companion.esbuild.ts': 'extensions/js-debug-companion', | ||
| 'js-profile-visualizer.esbuild.ts': 'extensions/js-profile-visualizer', | ||
| 'js-profile-visualizer.webpack.override.js': 'extensions/js-profile-visualizer', | ||
| 'devfile.esbuild.ts': 'extensions/devfile', | ||
| }; | ||
|
|
||
| for (const [scriptFile, extensionDir] of Object.entries(scripts)) { | ||
| const src = path.join(scriptDir, 'extension-build-scripts', scriptFile); | ||
| const destDir = path.join(codeDir, extensionDir); | ||
|
|
||
| // Extract the actual filename (remove the prefix before the first dot) | ||
| let destFile; | ||
| if (scriptFile.includes('.esbuild.ts')) { | ||
| destFile = '.esbuild.ts'; | ||
| } else if (scriptFile.includes('.webpack.override.js')) { | ||
| destFile = 'webpack.override.js'; | ||
| } else { | ||
| destFile = scriptFile; | ||
| } | ||
|
|
||
| const dest = path.join(destDir, destFile); | ||
|
|
||
| if (!fs.existsSync(src)) { | ||
| console.warn(`Warning: ${src} not found, skipping`); | ||
| continue; | ||
| } | ||
|
|
||
| if (!fs.existsSync(destDir)) { | ||
| console.warn(`Warning: ${destDir} not found, skipping`); | ||
| continue; | ||
| } | ||
|
|
||
| fs.copyFileSync(src, dest); | ||
| console.log(`Copied ${scriptFile} -> ${extensionDir}/${destFile}`); | ||
| } | ||
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,20 @@ | ||
| const path = require('path'); | ||
| const esbuild = require('esbuild'); | ||
|
|
||
| const srcDir = path.join(__dirname, 'src'); | ||
| const outDir = path.join(__dirname, 'dist'); | ||
|
|
||
| esbuild.build({ | ||
| platform: 'node', | ||
| bundle: true, | ||
| minify: true, | ||
| treeShaking: true, | ||
| sourcemap: true, | ||
| target: ['es2020'], | ||
| external: ['vscode'], | ||
| format: 'cjs', | ||
| entryPoints: { | ||
| 'devfile-extension': path.join(srcDir, 'devfile-extension.ts'), | ||
| }, | ||
| outdir: outDir, | ||
| }).catch(() => process.exit(1)); |
13 changes: 13 additions & 0 deletions
13
code/build/extension-build-scripts/js-debug-companion.esbuild.ts
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,13 @@ | ||
| const path = require('path'); | ||
| const esbuild = require('esbuild'); | ||
|
|
||
| esbuild.build({ | ||
| entryPoints: [path.join(__dirname, 'src', 'extension.ts')], | ||
| tsconfig: path.join(__dirname, 'tsconfig.json'), | ||
| bundle: true, | ||
| external: ['vscode'], | ||
| minify: true, | ||
| platform: 'node', | ||
| outdir: path.join(__dirname, 'dist'), | ||
| packages: 'bundle', | ||
| }).catch(() => process.exit(1)); |
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,16 @@ | ||
| const cp = require('child_process'); | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
|
|
||
| // Run js-debug's own gulp build which populates dist/ | ||
| cp.execFileSync(process.execPath, [path.join(__dirname, 'node_modules', 'gulp', 'bin', 'gulp.js'), 'compile'], { | ||
| cwd: __dirname, | ||
| stdio: 'inherit', | ||
| }); | ||
|
|
||
| // Rewrite main to point into dist/ so the packaged extension resolves correctly | ||
| const pkgPath = path.join(__dirname, 'package.json'); | ||
| const pkg = JSON.parse(fs.readFileSync(pkgPath, 'utf8')); | ||
| pkg.main = './dist/src/extension.js'; | ||
| pkg.activationEvents = []; | ||
| fs.writeFileSync(pkgPath, JSON.stringify(pkg, null, 2)); |
36 changes: 36 additions & 0 deletions
36
code/build/extension-build-scripts/js-profile-visualizer.esbuild.ts
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,36 @@ | ||
| const cp = require('child_process'); | ||
| const fs = require('fs'); | ||
| const path = require('path'); | ||
|
|
||
| const rootDir = __dirname; | ||
| const coreDir = path.join(rootDir, 'packages', 'vscode-js-profile-core'); | ||
| const tableDir = path.join(rootDir, 'packages', 'vscode-js-profile-table'); | ||
| const tsc = path.join(rootDir, 'node_modules', '.bin', 'tsc'); | ||
| const cpy = path.join(rootDir, 'node_modules', '.bin', 'cpy'); | ||
| const webpack = path.join(rootDir, 'node_modules', '.bin', 'webpack'); | ||
|
|
||
| // Build the core package first (table depends on it) | ||
| // Type errors are non-fatal - tsc still emits output even when it exits with error code | ||
| try { | ||
| cp.execFileSync(tsc, ['-p', 'tsconfig.json'], { cwd: coreDir, stdio: 'inherit' }); | ||
| } catch (e) { | ||
| // Ignore tsc errors - output files are still generated | ||
| } | ||
| try { | ||
| cp.execFileSync(tsc, ['-p', 'tsconfig.browser.json'], { cwd: coreDir, stdio: 'inherit' }); | ||
| } catch (e) { | ||
| // Ignore tsc errors - output files are still generated | ||
| } | ||
|
coderabbitai[bot] marked this conversation as resolved.
|
||
| cp.execFileSync(cpy, ['src/**/*.css', 'out/esm'], { cwd: coreDir, stdio: 'inherit' }); | ||
|
|
||
| // Build the table package with webpack using override config that disables type-checking | ||
| cp.execFileSync(webpack, ['--mode', 'production', '--config', path.join(rootDir, 'webpack.override.js')], { cwd: tableDir, stdio: 'inherit' }); | ||
|
|
||
| // Copy the sub-package's package.json to root so the build system picks up | ||
| // the correct extension manifest (with engines, contributes, main, etc.) | ||
| const tablePkg = JSON.parse(fs.readFileSync(path.join(tableDir, 'package.json'), 'utf8')); | ||
| tablePkg.main = './packages/vscode-js-profile-table/out/extension.js'; | ||
| if (tablePkg.browser) { | ||
| tablePkg.browser = './packages/vscode-js-profile-table/out/extension.web.js'; | ||
| } | ||
| fs.writeFileSync(path.join(rootDir, 'package.json'), JSON.stringify(tablePkg, null, 2)); | ||
20 changes: 20 additions & 0 deletions
20
code/build/extension-build-scripts/js-profile-visualizer.webpack.override.js
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,20 @@ | ||
| // Webpack config override for .esbuild.ts build - disables type-checking to avoid build failures | ||
| const baseConfig = require('./packages/vscode-js-profile-table/webpack.config.js'); | ||
|
|
||
| module.exports = baseConfig.map(config => { | ||
| if (config.module && config.module.rules) { | ||
| config.module.rules = config.module.rules.map(rule => { | ||
| if (rule.loader === 'ts-loader') { | ||
| return { | ||
| ...rule, | ||
| options: { | ||
| ...rule.options, | ||
| transpileOnly: true, // Disable type-checking to avoid build failures | ||
| }, | ||
| }; | ||
| } | ||
| return rule; | ||
| }); | ||
| } | ||
| return config; | ||
| }); |
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,24 @@ | ||
| { | ||
| "root": true, | ||
| "parser": "@typescript-eslint/parser", | ||
| "parserOptions": { | ||
| "ecmaVersion": 6, | ||
| "sourceType": "module" | ||
| }, | ||
| "plugins": [ | ||
| "@typescript-eslint" | ||
| ], | ||
| "rules": { | ||
| "@typescript-eslint/naming-convention": "warn", | ||
| "@typescript-eslint/semi": "warn", | ||
| "curly": "warn", | ||
| "eqeqeq": "warn", | ||
| "no-throw-literal": "warn", | ||
| "semi": "off" | ||
| }, | ||
| "ignorePatterns": [ | ||
| "out", | ||
| "dist", | ||
| "**/*.d.ts" | ||
| ] | ||
| } |
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,17 @@ | ||
| version: 2 | ||
| updates: | ||
| - package-ecosystem: "github-actions" | ||
| directory: "/" | ||
| schedule: | ||
| interval: "weekly" | ||
| day: "sunday" | ||
| time: "16:00" | ||
| groups: | ||
| all-actions: | ||
| patterns: [ "*" ] | ||
| - package-ecosystem: "npm" | ||
| directory: "/" | ||
| schedule: | ||
| interval: "weekly" | ||
| day: "sunday" | ||
| time: "16:00" |
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,21 @@ | ||
| name: pr-verify | ||
|
|
||
| on: [push, pull_request] | ||
|
|
||
| jobs: | ||
| pr-verify-job: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check Out Code | ||
| uses: actions/checkout@v2 | ||
| - name: Set Up NodeJS | ||
| uses: actions/setup-node@v2 | ||
| with: | ||
| node-version: '18' | ||
| - run: npm install -g typescript "vsce" | ||
| - run: npm install | ||
| - run: npm run compile | ||
| - run: npm run vscode:prepublish | ||
| - run: npm run build-vsix | ||
| - run: ls -ll *.vsix | ||
| - run: npm run eslint |
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 @@ | ||
| name: release | ||
|
|
||
| on: | ||
| workflow_dispatch: | ||
| inputs: | ||
| publishToMarketPlace: | ||
| description: "Publish to VS Code Marketplace ?" | ||
| required: true | ||
| type: choice | ||
| options: | ||
| - "true" | ||
| - "false" | ||
| default: "false" | ||
| publishToOVSX: | ||
| description: "Publish to OpenVSX Registry ?" | ||
| required: true | ||
| type: choice | ||
| options: | ||
| - "true" | ||
| - "false" | ||
| default: "false" | ||
| jobs: | ||
| packaging-job: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check Out vscode-devfile | ||
| uses: actions/checkout@v2 | ||
| - name: Set Up NodeJS | ||
| uses: actions/setup-node@v2 | ||
| with: | ||
| node-version: "18" | ||
| - name: Install NodeJS dependencies | ||
| run: npm install -g typescript "@vscode/vsce" "ovsx" | ||
| - name: Build vscode-devfile | ||
| run: | | ||
| npm install | ||
| npm run vscode:prepublish | ||
| npm run compile | ||
| echo "EXT_VERSION=$(cat package.json | jq -r .version)" >> $GITHUB_ENV | ||
| - name: Package vscode-devfile | ||
| run: | | ||
| vsce package -o vscode-devfile-${{ env.EXT_VERSION }}-${GITHUB_RUN_NUMBER}.vsix | ||
| ls -lash *.vsix | ||
| - name: Calculate SHA256 Hash | ||
| run: | | ||
| sha256sum vscode-devfile-${{ env.EXT_VERSION }}-${GITHUB_RUN_NUMBER}.vsix | ||
| - name: Upload VSIX Artifacts | ||
| uses: actions/upload-artifact@v4.6.1 | ||
| with: | ||
| name: vscode-devfile | ||
| path: | | ||
| vscode-devfile-${{ env.EXT_VERSION }}-${{ github.run_number }}.vsix | ||
| if-no-files-found: error | ||
| - name: Publish to GH Release Tab | ||
| if: ${{ inputs.publishToMarketPlace == 'true' && inputs.publishToOVSX == 'true' }} | ||
| uses: "marvinpinto/action-automatic-releases@919008cf3f741b179569b7a6fb4d8860689ab7f0" | ||
| with: | ||
| repo_token: "${{ secrets.RELEASE_GITHUB_TOKEN }}" | ||
| automatic_release_tag: "v${{ env.EXT_VERSION }}" | ||
| title: "${{ env.EXT_VERSION }}" | ||
| draft: true | ||
| files: | | ||
| vscode-devfile-${{ env.EXT_VERSION }}-${{ github.run_number }}.vsix | ||
| release-job: | ||
| environment: ${{ (inputs.publishToMarketPlace == 'true' || inputs.publishToOVSX == 'true') && 'release' || 'pre-release' }} | ||
| runs-on: ubuntu-latest | ||
| needs: packaging-job | ||
| steps: | ||
| - name: Check Out vscode-devfile | ||
| uses: actions/checkout@v2 | ||
| - name: Set Up NodeJS | ||
| uses: actions/setup-node@v2 | ||
| with: | ||
| node-version: "18" | ||
| - name: Install dependencies | ||
| run: | | ||
| npm install -g typescript "@vscode/vsce" "ovsx" | ||
| - name: Download VSIX | ||
| uses: actions/download-artifact@v4.2.0 | ||
| with: | ||
| merge-multiple: true | ||
| path: . | ||
| - name: List downloaded files | ||
| run: ls -ll *.vsix | ||
| - name: Set EXT_VERSION variable | ||
| run: echo "EXT_VERSION=$(cat package.json | jq -r .version)" >> $GITHUB_ENV | ||
| - name: Publish to VS Code Marketplace | ||
| if: ${{ inputs.publishToMarketPlace == 'true' }} | ||
| run: | | ||
| vsce publish -p ${{ secrets.VSCODE_MARKETPLACE_TOKEN }} --packagePath vscode-devfile-${{ env.EXT_VERSION }}-${GITHUB_RUN_NUMBER}.vsix | ||
| - name: Publish to OpenVSX Registry | ||
| if: ${{ inputs.publishToOVSX == 'true' }} | ||
| run: | | ||
| ovsx publish -p ${{ secrets.OVSX_MARKETPLACE_TOKEN }} --packagePath vscode-devfile-${{ env.EXT_VERSION }}-${GITHUB_RUN_NUMBER}.vsix |
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,3 @@ | ||
| out | ||
| node_modules | ||
| *.vsix |
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,11 @@ | ||
| .vscode/** | ||
| .vscode-test/** | ||
| src/** | ||
| .gitignore | ||
| .yarnrc | ||
| vsc-extension-quickstart.md | ||
| **/tsconfig.json | ||
| **/.eslintrc.json | ||
| **/*.map | ||
| **/*.ts | ||
| node_modules |
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,9 @@ | ||
| # Change Log | ||
|
|
||
| All notable changes to the "devfile.vscode-devfile" extension will be documented in this file. | ||
|
|
||
| Check [Keep a Changelog](http://keepachangelog.com/) for recommendations on how to structure this file. | ||
|
|
||
| ## [Unreleased] | ||
|
|
||
| - Initial release |
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.