Skip to content

Commit caaa4dd

Browse files
author
Arnold Trakhtenberg
authored
Merge pull request #14 from launchdarkly/at/ch41522/bundle-extension
Bundle extension with webpack
2 parents 23e04c1 + 532b8b4 commit caaa4dd

10 files changed

Lines changed: 2839 additions & 43 deletions

File tree

β€Ž.gitignoreβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@ out
22
node_modules
33
yarn-error.log
44
.vscode-test
5-
*.vsix
5+
*.vsix
6+
dist

β€Ž.vscode/launch.jsonβ€Ž

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,7 @@
1717
"type": "extensionHost",
1818
"request": "launch",
1919
"runtimeExecutable": "${execPath}",
20-
"args": [
21-
"--extensionDevelopmentPath=${workspaceRoot}",
22-
"--extensionTestsPath=${workspaceRoot}/out/test"
23-
],
20+
"args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/out/test"],
2421
"stopOnEntry": false,
2522
"sourceMaps": true,
2623
"outFiles": ["${workspaceRoot}/out/test/**/*.js"],

β€Ž.vscodeignoreβ€Ž

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
1-
.vscode/**
2-
.vscode-test/**
3-
out/test/**
4-
test/**
5-
src/**
6-
**/*.map
7-
.gitignore
1+
.vscode
2+
node_modules
3+
out/
4+
src/
5+
test/
86
tsconfig.json
7+
webpack.config.js
8+
**/*.ts
9+
*.vsix
10+
CHANGELOG.md

β€ŽCHANGELOG.mdβ€Ž

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,13 @@
22

33
All notable changes to the "launchdarkly" extension will be documented in this file.
44

5-
## [2.1.0] - 2019-02-07
5+
## [2.1.1] - 2019-06-24
6+
7+
### Changed
8+
9+
- The extension is now bundled with webpack to reduce artifact size (5.8mb -> 800kb)
10+
11+
## [2.1.0] - 2019-06-21
612

713
### Changed
814

β€Žimages/get-feature-flag.gifβ€Ž

-2.11 MB
Binary file not shown.

β€Žpackage.jsonβ€Ž

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "launchdarkly",
33
"displayName": "LaunchDarkly",
44
"description": "View LaunchDarkly feature flags in your editor.",
5-
"version": "2.1.0",
5+
"version": "2.1.1",
66
"publisher": "launchdarkly",
77
"engines": {
88
"vscode": "^1.34.0"
@@ -16,7 +16,7 @@
1616
"activationEvents": [
1717
"*"
1818
],
19-
"main": "./out/src/extension",
19+
"main": "./dist/extension",
2020
"contributes": {
2121
"configuration": {
2222
"type": "object",
@@ -90,10 +90,12 @@
9090
]
9191
},
9292
"scripts": {
93-
"vscode:prepublish": "tsc -p ./",
94-
"compile": "tsc -watch -p ./",
93+
"vscode:prepublish": "webpack --mode production",
94+
"compile": "webpack --mode none",
95+
"watch": "webpack --mode none --watch",
96+
"test-compile": "tsc -p ./",
9597
"postinstall": "node ./node_modules/vscode/bin/install",
96-
"test": "yarn run prettier:check && node ./node_modules/vscode/bin/test",
98+
"test": "yarn run prettier:check && yarn run test-compile && cp ./package.json ./out/package.json && node ./node_modules/vscode/bin/test",
9799
"prettier:write": "prettier --single-quote true --print-width 120 --use-tabs true --trailing-comma all --write \"{src,tests}/**/*.ts\"",
98100
"prettier:check": "prettier --single-quote true --print-width 120 --use-tabs true --trailing-comma all --list-different \"{src,tests}/**/*.ts\""
99101
},
@@ -103,9 +105,12 @@
103105
"mocha": "5.2.0",
104106
"prettier": "^1.5.3",
105107
"pretty-error": "^2.1.1",
108+
"ts-loader": "6.0.4",
106109
"typescript": "^2.4.2",
107-
"yarn": "^1.17.0",
108-
"vscode": "^1.1.34"
110+
"vscode": "^1.1.34",
111+
"webpack": "4.35.0",
112+
"webpack-cli": "3.3.5",
113+
"yarn": "^1.17.0"
109114
},
110115
"dependencies": {
111116
"@types/lodash": "4.14.116",

β€Žsrc/flags.tsβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import * as url from 'url';
99
import opn = require('opn');
1010

1111
import { IConfiguration, DEFAULT_BASE_URI, DEFAULT_STREAM_URI } from './configuration';
12-
import package_json = require('../package.json');
12+
const package_json = require('../package.json');
1313

1414
const FLAG_KEY_REGEX = /[A-Za-z0-9][\.A-Za-z_\-0-9]*/;
1515

β€Žtsconfig.jsonβ€Ž

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,5 @@
77
"sourceMap": true,
88
"rootDir": ".",
99
"resolveJsonModule": true
10-
},
11-
"exclude": ["node_modules", ".vscode-test", "./out"]
10+
}
1211
}

β€Žwebpack.config.jsβ€Ž

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
//@ts-check
2+
3+
'use strict';
4+
5+
const path = require('path');
6+
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, 'dist'),
15+
filename: 'extension.js',
16+
libraryTarget: 'commonjs2',
17+
devtoolModuleFilenameTemplate: '../[resource-path]',
18+
},
19+
devtool: 'source-map',
20+
externals: {
21+
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/
22+
},
23+
resolve: {
24+
// support reading TypeScript and JavaScript files, πŸ“– -> https://github.com/TypeStrong/ts-loader
25+
extensions: ['.ts', '.js'],
26+
},
27+
module: {
28+
rules: [
29+
{
30+
test: /\.ts$/,
31+
exclude: /node_modules/,
32+
use: [
33+
{
34+
loader: 'ts-loader',
35+
},
36+
],
37+
},
38+
],
39+
},
40+
};
41+
module.exports = config;

0 commit comments

Comments
Β (0)