Skip to content

Commit

Permalink
Merge pull request #14 from launchdarkly/at/ch41522/bundle-extension
Browse files Browse the repository at this point in the history
Bundle extension with webpack
  • Loading branch information
Arnold Trakhtenberg authored Jun 24, 2019
2 parents 23e04c1 + 532b8b4 commit caaa4dd
Show file tree
Hide file tree
Showing 10 changed files with 2,839 additions and 43 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@ out
node_modules
yarn-error.log
.vscode-test
*.vsix
*.vsix
dist
5 changes: 1 addition & 4 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,7 @@
"type": "extensionHost",
"request": "launch",
"runtimeExecutable": "${execPath}",
"args": [
"--extensionDevelopmentPath=${workspaceRoot}",
"--extensionTestsPath=${workspaceRoot}/out/test"
],
"args": ["--extensionDevelopmentPath=${workspaceRoot}", "--extensionTestsPath=${workspaceRoot}/out/test"],
"stopOnEntry": false,
"sourceMaps": true,
"outFiles": ["${workspaceRoot}/out/test/**/*.js"],
Expand Down
16 changes: 9 additions & 7 deletions .vscodeignore
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
.vscode/**
.vscode-test/**
out/test/**
test/**
src/**
**/*.map
.gitignore
.vscode
node_modules
out/
src/
test/
tsconfig.json
webpack.config.js
**/*.ts
*.vsix
CHANGELOG.md
8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,13 @@

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

## [2.1.0] - 2019-02-07
## [2.1.1] - 2019-06-24

### Changed

- The extension is now bundled with webpack to reduce artifact size (5.8mb -> 800kb)

## [2.1.0] - 2019-06-21

### Changed

Expand Down
Binary file removed images/get-feature-flag.gif
Binary file not shown.
19 changes: 12 additions & 7 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "launchdarkly",
"displayName": "LaunchDarkly",
"description": "View LaunchDarkly feature flags in your editor.",
"version": "2.1.0",
"version": "2.1.1",
"publisher": "launchdarkly",
"engines": {
"vscode": "^1.34.0"
Expand All @@ -16,7 +16,7 @@
"activationEvents": [
"*"
],
"main": "./out/src/extension",
"main": "./dist/extension",
"contributes": {
"configuration": {
"type": "object",
Expand Down Expand Up @@ -90,10 +90,12 @@
]
},
"scripts": {
"vscode:prepublish": "tsc -p ./",
"compile": "tsc -watch -p ./",
"vscode:prepublish": "webpack --mode production",
"compile": "webpack --mode none",
"watch": "webpack --mode none --watch",
"test-compile": "tsc -p ./",
"postinstall": "node ./node_modules/vscode/bin/install",
"test": "yarn run prettier:check && node ./node_modules/vscode/bin/test",
"test": "yarn run prettier:check && yarn run test-compile && cp ./package.json ./out/package.json && node ./node_modules/vscode/bin/test",
"prettier:write": "prettier --single-quote true --print-width 120 --use-tabs true --trailing-comma all --write \"{src,tests}/**/*.ts\"",
"prettier:check": "prettier --single-quote true --print-width 120 --use-tabs true --trailing-comma all --list-different \"{src,tests}/**/*.ts\""
},
Expand All @@ -103,9 +105,12 @@
"mocha": "5.2.0",
"prettier": "^1.5.3",
"pretty-error": "^2.1.1",
"ts-loader": "6.0.4",
"typescript": "^2.4.2",
"yarn": "^1.17.0",
"vscode": "^1.1.34"
"vscode": "^1.1.34",
"webpack": "4.35.0",
"webpack-cli": "3.3.5",
"yarn": "^1.17.0"
},
"dependencies": {
"@types/lodash": "4.14.116",
Expand Down
2 changes: 1 addition & 1 deletion src/flags.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as url from 'url';
import opn = require('opn');

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

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

Expand Down
3 changes: 1 addition & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,5 @@
"sourceMap": true,
"rootDir": ".",
"resolveJsonModule": true
},
"exclude": ["node_modules", ".vscode-test", "./out"]
}
}
41 changes: 41 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
//@ts-check

'use strict';

const path = require('path');

/**@type {import('webpack').Configuration}*/
const config = {
target: 'node', // vscode extensions run in a Node.js-context πŸ“– -> https://webpack.js.org/configuration/node/

entry: './src/extension.ts', // the entry point of this extension, πŸ“– -> https://webpack.js.org/configuration/entry-context/
output: {
// the bundle is stored in the 'dist' folder (check package.json), πŸ“– -> https://webpack.js.org/configuration/output/
path: path.resolve(__dirname, 'dist'),
filename: 'extension.js',
libraryTarget: 'commonjs2',
devtoolModuleFilenameTemplate: '../[resource-path]',
},
devtool: 'source-map',
externals: {
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/
},
resolve: {
// support reading TypeScript and JavaScript files, πŸ“– -> https://github.com/TypeStrong/ts-loader
extensions: ['.ts', '.js'],
},
module: {
rules: [
{
test: /\.ts$/,
exclude: /node_modules/,
use: [
{
loader: 'ts-loader',
},
],
},
],
},
};
module.exports = config;
Loading

0 comments on commit caaa4dd

Please sign in to comment.