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

Bundle extension using esbuild #335

Open
wants to merge 11 commits into
base: master
Choose a base branch
from
59 changes: 40 additions & 19 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,29 @@
"presentation": {
"group": "watch",
"echo": true,
"reveal": "silent",
"reveal": "always",
"focus": false,
"panel": "shared"
},
"isBackground": true,
"problemMatcher": "$tsc-watch"
}, {
"problemMatcher": [
{
"pattern": {
"regexp": ""
},
"background": {
"activeOnStart": true,
"beginsPattern": {
"regexp": "\\[watch\\] build started"
},
"endsPattern": {
"regexp": "\\[watch\\] build finished"
}
}
}
]
},
{
"label": "svelte-watch",
"type": "shell",
"command": "npm",
Expand All @@ -31,25 +47,30 @@
"presentation": {
"group": "watch",
"echo": true,
"reveal": "silent",
"reveal": "always",
"focus": false,
"panel": "shared"
},
"isBackground": true,
"problemMatcher": [{
"pattern": {
"regexp": "^\\[!\\]"
},
"severity": "error"
}, {
"base": "$tsc-watch",
"background": {
"activeOnStart": true,
"beginsPattern": "^\\s*\\[\\d{1,2}:\\d{1,2}:\\d{1,2}(?: AM| PM)?\\] Validating project",
"endsPattern": "waiting for changes..."
"problemMatcher": [
{
"pattern": {
"regexp": "^\\[!\\]"
},
"severity": "error"
},
}],
"dependsOn": ["watch"]
{
"base": "$tsc-watch",
"background": {
"activeOnStart": true,
"beginsPattern": "^\\s*\\[\\d{1,2}:\\d{1,2}:\\d{1,2}(?: AM| PM)?\\] Validating project",
"endsPattern": "waiting for changes..."
},
}
],
"dependsOn": [
"watch"
]
},
{
"label": "test",
Expand Down Expand Up @@ -85,7 +106,7 @@
"type": "npm",
"label": "build",
"script": "build",
"dependsOn": "clean",
// "dependsOn": "clean",
"problemMatcher": [],
"group": {
"kind": "build",
Expand All @@ -105,4 +126,4 @@
"problemMatcher": []
}
]
}
}
42 changes: 42 additions & 0 deletions esbuild.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
const esbuild = require('esbuild')
const fsExtra = require('fs-extra');

class Plugin {
constructor() {
this.name = 'empty-loader'
}
setup(build) {
build.onResolve({ filter: /^chokidar$/ }, args => ({
path: args.path,
namespace: 'empty-loader',
}))
build.onLoad({ filter: /.*/, namespace: 'empty-loader' }, () => ({
contents: '/*chokidar is not necessary for the language server so we replaced it with an empty object to fix esbuild issues*/\nmodule.exports = {}',
}))
}
}

esbuild.build({
entryPoints: {
'extension': './src/extension.ts',
'extension-web': './src/extension-web.ts',
'LanguageServerRunner': './src/LanguageServerRunner.ts',
'brighterscript': './node_modules/brighterscript/dist/index.js'
},
bundle: true,
sourcemap: true,
splitting: false, //enable this once esbuild supports commonjs code splitting
treeShaking: true,
watch: process.argv.includes('--watch'),
minify: true, //process.argv.includes('--minify'),
mainFields: ['module', 'main'],
entryNames: '[name]',
outdir: 'dist',
external: [
'vscode'
],
format: 'cjs',
platform: 'node',
logLevel: 'info',
plugins: [new Plugin()]
}).catch((e) => console.error(e));
Loading