Skip to content

Commit 2a36ffe

Browse files
authored
fix: Extension is now bundled with webpack (#1020)
1 parent db2a527 commit 2a36ffe

File tree

5 files changed

+1870
-71
lines changed

5 files changed

+1870
-71
lines changed

.github/workflows/main.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ jobs:
3333
run: 'yarn install --frozen-lockfile || yarn install --frozen-lockfile'
3434
shell: bash
3535

36-
- name: Compile sources
37-
run: yarn run build
36+
- name: Compile sources for tests
37+
run: yarn run test-compile
3838

3939
- name: Cache VSCode binary
4040
id: cache-vscode

.vscodeignore

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,9 @@ tslint.json
2222
vsc-extension-quickstart.md
2323
.dependabot/**
2424
images/docs/**
25+
bin
26+
node_modules
27+
webpack.config.js
28+
29+
out/**
30+
!out/extension.js*

package.json

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535
"scripts": {
3636
"build": "yarn run build:ts && yarn run build:css",
3737
"build:css": "yarn node-sass scss/ -o css/ --output-style compressed",
38-
"build:ts": "yarn tsc -p ./",
39-
"compile": "yarn tsc -watch -p ./",
38+
"build:ts": "webpack --mode production",
39+
"compile": "webpack --mode development --watch",
4040
"lint": "eslint \"src/**/*.ts\"",
4141
"lint:fix": "yarn run lint --fix",
4242
"organize": "node ./out/tools/organize.js",
@@ -46,7 +46,8 @@
4646
"test": "node ./out/test/runTest.js",
4747
"tools:genReadme": "node ./out/tools/generateConfigSectionForReadme.js",
4848
"vscode:prepublish": "yarn run lint && yarn run build",
49-
"watch:css": "yarn run build:css -w"
49+
"watch:css": "yarn run build:css -w",
50+
"test-compile": "tsc -p ./"
5051
},
5152
"dependencies": {
5253
"chardet": "^1.2.1",
@@ -82,8 +83,11 @@
8283
"prettylint": "^1.0.0",
8384
"semantic-release": "^17.1.1",
8485
"semantic-release-vsce": "^3.0.1",
86+
"ts-loader": "^8.0.1",
8587
"typescript": "^3.9.7",
86-
"vscode-test": "^1.4.0"
88+
"vscode-test": "^1.4.0",
89+
"webpack": "^4.44.1",
90+
"webpack-cli": "^3.3.12"
8791
},
8892
"config": {
8993
"commitizen": {

webpack.config.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
//@ts-check
2+
3+
'use strict';
4+
5+
const path = require('path');
6+
const IGNORED = ['jschardet', 'iconv-lite', 'iconv-lite-umd', './vscodeModules'];
7+
/**@type {import('webpack').Configuration}*/
8+
const config = {
9+
target: 'node', // vscode extensions run in a Node.js-context 📖 -> https://webpack.js.org/configuration/node/
10+
11+
entry: './src/extension.ts', // the entry point of this extension, 📖 -> https://webpack.js.org/configuration/entry-context/
12+
output: {
13+
// the bundle is stored in the 'dist' folder (check package.json), 📖 -> https://webpack.js.org/configuration/output/
14+
path: path.resolve(__dirname, 'out'),
15+
filename: 'extension.js',
16+
libraryTarget: 'commonjs2',
17+
devtoolModuleFilenameTemplate: '../[resource-path]'
18+
},
19+
devtool: 'source-map',
20+
externals: [
21+
{
22+
vscode: 'commonjs vscode' // the vscode-module is created on-the-fly and must be excluded. Add other modules that cannot be webpack'ed, 📖 -> https://webpack.js.org/configuration/externals/
23+
}
24+
],
25+
resolve: {
26+
// support reading TypeScript and JavaScript files, 📖 -> https://github.com/TypeStrong/ts-loader
27+
extensions: ['.ts', '.js']
28+
},
29+
module: {
30+
noParse: /vscodeModules/,
31+
rules: [
32+
{
33+
test: /\.ts$/,
34+
exclude: /node_modules/,
35+
use: [
36+
{
37+
loader: 'ts-loader'
38+
}
39+
]
40+
}
41+
]
42+
}
43+
};
44+
module.exports = config;

0 commit comments

Comments
 (0)