Skip to content
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

release: bundle files and reduce size of VSIX. #10

Merged
merged 1 commit into from
Oct 29, 2024
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
2 changes: 1 addition & 1 deletion .vscode-test.mjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { defineConfig } from "@vscode/test-cli";

export default defineConfig({
files: "out/test/**/*.test.js",
files: "dist/test/**/*.test.js",
});
2 changes: 1 addition & 1 deletion .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"type": "extensionHost",
"request": "launch",
"args": ["--extensionDevelopmentPath=${workspaceFolder}"],
"outFiles": ["${workspaceFolder}/out/**/*.js"],
"outFiles": ["${workspaceFolder}/dist/**/*.js"],
"preLaunchTask": "${defaultBuildTask}"
}
]
Expand Down
20 changes: 11 additions & 9 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
.vscode/**
.vscode-test/**
src/**
.github
.vscode
node_modules
src
.eslintrc.json
.gitignore
.vscode-test.mjs
.vscodeignore
.yarnrc
vsc-extension-quickstart.md
**/tsconfig.json
**/.eslintrc.json
**/*.map
**/*.ts
**/.vscode-test.*
esbuild.js
tsconfig.json
tsconfig.prod.json
yarn.lock
56 changes: 56 additions & 0 deletions esbuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
const esbuild = require("esbuild");

const production = process.argv.includes("--production");
const watch = process.argv.includes("--watch");

async function main() {
const ctx = await esbuild.context({
entryPoints: ["src/extension.ts"],
bundle: true,
format: "cjs",
minify: production,
sourcemap: !production,
sourcesContent: false,
platform: "node",
outfile: "dist/extension.js",
external: ["vscode"],
logLevel: "silent",
plugins: [
/* add to the end of plugins array */
esbuildProblemMatcherPlugin,
],
});
if (watch) {
await ctx.watch();
} else {
await ctx.rebuild();
await ctx.dispose();
}
}

/**
* @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");
});
},
};

main().catch((e) => {
console.error(e);
process.exit(1);
});
16 changes: 9 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
"Bioinformatics"
],
"preview": true,
"main": "./out/extension.js",
"main": "./dist/extension.js",
"activationEvents": [],
"contributes": {
"languages": [
Expand Down Expand Up @@ -99,12 +99,13 @@
]
},
"scripts": {
"vscode:prepublish": "yarn run compile",
"compile": "tsc -p tsconfig.prod.json",
"watch": "tsc -watch -p tsconfig.json",
"pretest": "tsc -p tsconfig.json && yarn run lint",
"lint": "eslint src --ext ts",
"test": "vscode-test"
"compile": "yarn run check-types && node esbuild.js",
"check-types": "tsc --noEmit",
"watch": "npm-run-all -p watch:*",
"watch:esbuild": "node esbuild.js --watch",
"watch:tsc": "tsc --noEmit --watch --project tsconfig.json",
"vscode:prepublish": "yarn run package",
"package": "yarn run check-types && node esbuild.js --production"
},
"extensionDependencies": [
"mindaro-dev.file-downloader"
Expand All @@ -125,6 +126,7 @@
"@typescript-eslint/parser": "^7.11.0",
"@vscode/test-cli": "^0.0.9",
"@vscode/test-electron": "^2.4.0",
"esbuild": "^0.24.0",
"eslint": "^8.57.0",
"eslint-config-prettier": "^9.1.0",
"typescript": "^5.4.5"
Expand Down
Loading