-
Notifications
You must be signed in to change notification settings - Fork 224
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* support esbuild * update * add test * support esbuild in web
- Loading branch information
Showing
33 changed files
with
2,592 additions
and
1,748 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
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
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
13 changes: 13 additions & 0 deletions
13
generators/app/templates/ext-command-ts/vscode-esbuild/.vscodeignore
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,13 @@ | ||
.vscode/** | ||
.vscode-test/** | ||
out/** | ||
node_modules/** | ||
src/** | ||
.gitignore | ||
.yarnrc | ||
esbuild.js | ||
vsc-extension-quickstart.md | ||
**/.eslintrc.json | ||
**/*.map | ||
**/*.ts | ||
**/.vscode-test.* |
56 changes: 56 additions & 0 deletions
56
generators/app/templates/ext-command-ts/vscode-esbuild/esbuild.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
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'); | ||
|
||
/** | ||
* @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'); | ||
}); | ||
}, | ||
}; | ||
|
||
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(); | ||
} | ||
} | ||
|
||
main().catch(e => { | ||
console.error(e); | ||
process.exit(1); | ||
}); |
52 changes: 52 additions & 0 deletions
52
generators/app/templates/ext-command-ts/vscode-esbuild/package.json
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,52 @@ | ||
{ | ||
"name": <%- JSON.stringify(name) %>, | ||
"displayName": <%- JSON.stringify(displayName) %>, | ||
"description": <%- JSON.stringify(description) %>, | ||
"version": "0.0.1", | ||
"engines": { | ||
"vscode": <%- JSON.stringify(vsCodeEngine) %> | ||
}, | ||
"categories": [ | ||
"Other" | ||
], | ||
"activationEvents": [], | ||
"main": "./dist/extension.js",<% if (insiders) { %> | ||
"enabledApiProposals": [],<% } %> | ||
"contributes": { | ||
"commands": [ | ||
{ | ||
"command": <%- JSON.stringify(`${name}.helloWorld`) %>, | ||
"title": "Hello World" | ||
} | ||
] | ||
}, | ||
"scripts": { | ||
"vscode:prepublish": "<%= pkgManager %> run package", | ||
"compile": "<%= pkgManager %> run check-types && <%= pkgManager %> run lint && node esbuild.js", | ||
"watch": "npm-run-all -p watch:*", | ||
"watch:esbuild": "node esbuild.js --watch", | ||
"watch:tsc": "tsc --noEmit --watch --project tsconfig.json", | ||
"package": "<%= pkgManager %> run check-types && <%= pkgManager %> run lint && node esbuild.js --production", | ||
"compile-tests": "tsc -p . --outDir out", | ||
"watch-tests": "tsc -p . -w --outDir out", | ||
"pretest": "<%= pkgManager %> run compile-tests && <%= pkgManager %> run compile && <%= pkgManager %> run lint", | ||
"check-types": "tsc --noEmit", | ||
"lint": "eslint src --ext ts", | ||
"test": "vscode-test"<% if (insiders) { %>, | ||
"update-proposed-api": "vscode-dts dev"<% } %> | ||
}, | ||
"devDependencies": { | ||
<%- dep("@types/vscode") %>, | ||
<%- dep("@types/mocha") %>, | ||
<%- dep("@types/node") %>, | ||
<%- dep("@typescript-eslint/eslint-plugin") %>, | ||
<%- dep("@typescript-eslint/parser") %>, | ||
<%- dep("eslint") %>, | ||
<%- dep("esbuild") %>, | ||
<%- dep("npm-run-all") %>, | ||
<%- dep("typescript") %>, | ||
<%- dep("@vscode/test-cli") %>, | ||
<%- dep("@vscode/test-electron") %><% if (insiders) { %>, | ||
<%- dep("vscode-dts") %><% } %> | ||
} | ||
} |
16 changes: 16 additions & 0 deletions
16
generators/app/templates/ext-command-ts/vscode-esbuild/tsconfig.json
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,16 @@ | ||
{ | ||
"compilerOptions": { | ||
"module": "Node16", | ||
"target": "ES2022", | ||
"lib": [ | ||
"ES2022" | ||
], | ||
"sourceMap": true, | ||
"rootDir": "src", | ||
"strict": true /* enable all strict type-checking options */ | ||
/* Additional Checks */ | ||
// "noImplicitReturns": true, /* Report error when not all code paths in function return a value. */ | ||
// "noFallthroughCasesInSwitch": true, /* Report errors for fallthrough cases in switch statement. */ | ||
// "noUnusedParameters": true, /* Report errors on unused parameters. */ | ||
} | ||
} |
48 changes: 48 additions & 0 deletions
48
generators/app/templates/ext-command-ts/vscode-esbuild/vsc-extension-quickstart.md
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,48 @@ | ||
# Welcome to your VS Code Extension | ||
|
||
## What's in the folder | ||
|
||
* This folder contains all of the files necessary for your extension. | ||
* `package.json` - this is the manifest file in which you declare your extension and command. | ||
* The sample plugin registers a command and defines its title and command name. With this information VS Code can show the command in the command palette. It doesn’t yet need to load the plugin. | ||
* `src/extension.ts` - this is the main file where you will provide the implementation of your command. | ||
* The file exports one function, `activate`, which is called the very first time your extension is activated (in this case by executing the command). Inside the `activate` function we call `registerCommand`. | ||
* We pass the function containing the implementation of the command as the second parameter to `registerCommand`. | ||
|
||
## Setup | ||
|
||
* install the recommended extensions (amodio.tsl-problem-matcher, ms-vscode.extension-test-runner, and dbaeumer.vscode-eslint) | ||
|
||
|
||
## Get up and running straight away | ||
|
||
* Press `F5` to open a new window with your extension loaded. | ||
* Run your command from the command palette by pressing (`Ctrl+Shift+P` or `Cmd+Shift+P` on Mac) and typing `Hello World`. | ||
* Set breakpoints in your code inside `src/extension.ts` to debug your extension. | ||
* Find output from your extension in the debug console. | ||
|
||
## Make changes | ||
|
||
* You can relaunch the extension from the debug toolbar after changing code in `src/extension.ts`. | ||
* You can also reload (`Ctrl+R` or `Cmd+R` on Mac) the VS Code window with your extension to load your changes. | ||
|
||
|
||
## Explore the API | ||
|
||
* You can open the full set of our API when you open the file `node_modules/@types/vscode/index.d.ts`. | ||
|
||
## Run tests | ||
|
||
* Install the [Extension Test Runner](https://marketplace.visualstudio.com/items?itemName=ms-vscode.extension-test-runner) | ||
* Run the "watch" task via the **Tasks: Run Task** command. Make sure this is running, or tests might not be discovered. | ||
* Open the Testing view from the activity bar and click the Run Test" button, or use the hotkey `Ctrl/Cmd + ; A` | ||
* See the output of the test result in the Test Results view. | ||
* Make changes to `src/test/extension.test.ts` or create new test files inside the `test` folder. | ||
* The provided test runner will only consider files matching the name pattern `**.test.ts`. | ||
* You can create folders inside the `test` folder to structure your tests any way you want. | ||
|
||
## Go further | ||
|
||
* Reduce the extension size and improve the startup time by [bundling your extension](https://code.visualstudio.com/api/working-with-extensions/bundling-extension). | ||
* [Publish your extension](https://code.visualstudio.com/api/working-with-extensions/publishing-extension) on the VS Code extension marketplace. | ||
* Automate builds by setting up [Continuous Integration](https://code.visualstudio.com/api/working-with-extensions/continuous-integration). |
5 changes: 5 additions & 0 deletions
5
generators/app/templates/ext-command-ts/vscode-esbuild/vscode/extensions.json
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,5 @@ | ||
{ | ||
// See http://go.microsoft.com/fwlink/?LinkId=827846 | ||
// for the documentation about the extensions.json format | ||
"recommendations": ["dbaeumer.vscode-eslint", "connor4312.esbuild-problem-matchers", "ms-vscode.extension-test-runner"] | ||
} |
Oops, something went wrong.