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
6 changes: 6 additions & 0 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -228,5 +228,11 @@ module.exports = {
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-var-requires': 'off'
}
}, {
files: ['esbuild.js'],
rules: {
'@typescript-eslint/no-require-imports': 'off',
'@typescript-eslint/no-var-requires': 'off'
}
}]
};
2 changes: 1 addition & 1 deletion .github/workflows/create-vsix.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ on:
required: true
jobs:
create-vsix:
runs-on: ubuntu-18.04
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@master
Expand Down
23 changes: 19 additions & 4 deletions .vscode/tasks.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,27 @@
"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": "watch-webviews",
Expand All @@ -28,7 +43,7 @@
"presentation": {
"group": "watch",
"echo": true,
"reveal": "silent",
"reveal": "always",
"focus": false,
"panel": "shared"
},
Expand Down Expand Up @@ -88,4 +103,4 @@
}
}
]
}
}
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