Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,13 +134,16 @@ jobs:
echo "publishPreReleaseFlag=--pre-release" >> $GITHUB_ENV
- name: Package vscode-java
run: |
# Compile JavaScript once for the universal VSIX (webpack is platform-independent)
vsce package ${{ env.publishPreReleaseFlag }} -o vscode-java-${{ env.EXT_VERSION }}-${GITHUB_RUN_NUMBER}.vsix

# Package for each platform (only downloads JDK and creates VSIX, no recompilation)
platforms=("win32-x64" "win32-arm64" "linux-x64" "linux-arm64" "darwin-x64" "darwin-arm64")
for platform in ${platforms[@]}; do
npm run download-jre -- --target ${platform} --javaVersion 21
vsce package ${{ env.publishPreReleaseFlag }} --target ${platform} -o java-${platform}-${{ env.EXT_VERSION }}-${GITHUB_RUN_NUMBER}.vsix
SKIP_WEBPACK=true vsce package ${{ env.publishPreReleaseFlag }} --target ${platform} -o java-${platform}-${{ env.EXT_VERSION }}-${GITHUB_RUN_NUMBER}.vsix
done
rm -rf jre/
vsce package ${{ env.publishPreReleaseFlag }} -o vscode-java-${{ env.EXT_VERSION }}-${GITHUB_RUN_NUMBER}.vsix

ls -lash *.vsix
- name: Upload VSIX Artifacts
uses: actions/upload-artifact@v5
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2020,7 +2020,7 @@
}
},
"scripts": {
"vscode:prepublish": "webpack --mode production",
"vscode:prepublish": "node scripts/prepublish.mjs",
"compile": "tsc -p ./&webpack --mode development",
"watch": "webpack --mode development --watch",
"pretest": "npm run compile",
Expand Down
35 changes: 35 additions & 0 deletions scripts/prepublish.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#!/usr/bin/env node

// Skip webpack if SKIP_WEBPACK environment variable is set to 'true'
if (process.env.SKIP_WEBPACK === 'true') {
console.log('Skipping webpack compilation (SKIP_WEBPACK=true)');
process.exit(0);
}

// Otherwise, run webpack using the local webpack-cli installation
const { spawn } = await import('child_process');
const { fileURLToPath } = await import('url');
const { dirname, resolve, join } = await import('path');

const scriptFilename = fileURLToPath(import.meta.url);
const scriptDirname = dirname(scriptFilename);
const projectRoot = resolve(scriptDirname, '..');

// Use webpack-cli from local node_modules (cross-platform)
const webpackCliPath = join(projectRoot, 'node_modules', '.bin', 'webpack');
const isWindows = process.platform === 'win32';
const webpackCommand = isWindows ? `${webpackCliPath}.cmd` : webpackCliPath;

const webpack = spawn(webpackCommand, ['--mode', 'production'], {
stdio: 'inherit',
cwd: projectRoot
});

webpack.on('close', (code) => {
process.exit(code || 0);
});

webpack.on('error', (error) => {
console.error('Error running webpack:', error);
process.exit(1);
});