From 1ee4f14ec145ca1befcd635c003beb1f9666b45b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Simon=20Z=C3=BCnd?= Date: Mon, 17 Jun 2019 15:48:47 +0200 Subject: [PATCH] Use webpack to bundle the extension --- .gitignore | 1 + .vscode/extensions.json | 7 ++++++ .vscode/settings.json | 3 --- .vscode/tasks.json | 2 +- .vscodeignore | 3 +++ package.json | 15 ++++++----- webpack.config.js | 56 +++++++++++++++++++++++++++++++++++++++++ 7 files changed, 77 insertions(+), 10 deletions(-) create mode 100644 .vscode/extensions.json delete mode 100644 .vscode/settings.json create mode 100644 webpack.config.js diff --git a/.gitignore b/.gitignore index 72aae85..7f8d5a9 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ +dist/ node_modules/ out/ diff --git a/.vscode/extensions.json b/.vscode/extensions.json new file mode 100644 index 0000000..11c64dd --- /dev/null +++ b/.vscode/extensions.json @@ -0,0 +1,7 @@ +{ + // See https://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "eamodio.tsl-problem-matcher" + ] +} diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index f5d622f..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,3 +0,0 @@ -{ - "cquery.cacheDirectory": "${workspaceFolder}/.vscode/cquery_cached_index/" -} \ No newline at end of file diff --git a/.vscode/tasks.json b/.vscode/tasks.json index 7e1c518..8f05b14 100644 --- a/.vscode/tasks.json +++ b/.vscode/tasks.json @@ -12,7 +12,7 @@ }, "isBackground": true, "problemMatcher": [ - "$tsc-watch" + "$ts-webpack" ] } ] diff --git a/.vscodeignore b/.vscodeignore index 766d9b9..9b76adc 100644 --- a/.vscodeignore +++ b/.vscodeignore @@ -1,5 +1,8 @@ .gitignore .vscode +node_modules/ +out/ src/ tsconfig.json tslint.json +webpack.config.js diff --git a/package.json b/package.json index 623d8bc..2fdcace 100644 --- a/package.json +++ b/package.json @@ -20,7 +20,7 @@ "onLanguage:torque", "workspaceContains:**/*.tq" ], - "main": "out/extension.js", + "main": "dist/extension.js", "contributes": { "configuration": { "type": "object", @@ -82,15 +82,18 @@ }, "devDependencies": { "@types/node": "^8.0.0", - "vscode": "^1.1.21", + "ts-loader": "^6.0.2", "tslint": "^5.11.0", - "typescript": "^3.1.3" + "typescript": "^3.1.3", + "vscode": "^1.1.21", + "webpack": "^4.34.0", + "webpack-cli": "^3.3.4" }, "scripts": { "update-vscode": "vscode-install", "postinstall": "vscode-install", - "vscode:prepublish": "npm run update-vscode && npm run compile", - "compile": "tsc -b", - "watch": "tsc -b -w" + "vscode:prepublish": "npm run update-vscode && webpack --mode production", + "compile": "webpack --mode none", + "watch": "webpack --mode none --watch" } } diff --git a/webpack.config.js b/webpack.config.js new file mode 100644 index 0000000..c876091 --- /dev/null +++ b/webpack.config.js @@ -0,0 +1,56 @@ +// Copyright 2019 The VSCode V8 Torque Authors. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// https://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +//@ts-check + +'use strict'; + +const path = require('path'); + +/**@type {import('webpack').Configuration}*/ +const config = { + target: 'node', + entry: './src/extension.ts', + output: { + // the bundle is stored in the 'dist' folder (check package.json). + path: path.resolve(__dirname, 'dist'), + filename: 'extension.js', + libraryTarget: 'commonjs2', + devtoolModuleFilenameTemplate: '../[resource-path]' + }, + devtool: 'source-map', + externals: { + // the vscode-module is created on-the-fly and must be excluded. + // Add other modules that cannot be webpack'ed. + vscode: 'commonjs vscode' + }, + resolve: { + // support reading TypeScript and JavaScript files. + extensions: ['.ts', '.js'] + }, + module: { + rules: [ + { + test: /\.ts$/, + exclude: /node_modules/, + use: [ + { + loader: 'ts-loader' + } + ] + } + ] + } +}; +module.exports = config;