-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
release: bundle files and reduce size of VSIX. (#10)
This commit uses esbuild to bundle the extension into a single JavaScript file. It also ensures only what's needed is put into the package.
- Loading branch information
1 parent
63bda6a
commit f769dc6
Showing
6 changed files
with
501 additions
and
291 deletions.
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
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", | ||
}); |
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 |
---|---|---|
@@ -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 |
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,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); | ||
}); |
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
Oops, something went wrong.