Skip to content
Permalink
Browse files
always webpack and keep vsix small
  • Loading branch information
weinand committed Sep 10, 2020
1 parent 4ae67d9 commit 78ba9cd3e18c5959f8b9aef9bfd3c1f630af8dff
Showing 6 changed files with 95 additions and 28 deletions.
@@ -10,7 +10,7 @@
"${workspaceFolder}/sampleworkspace"
],
"outFiles": [
"${workspaceFolder}/out/**/*.js"
"${workspaceFolder}/dist/ext/**/*.js"
],
"preLaunchTask": "npm: watch"
},
@@ -56,14 +56,8 @@
"outFiles": [
"${workspaceFolder}/out/**/*.js"
],
"internalConsoleOptions": "openOnSessionStart"
},
{
"name": "Mock Sample",
"type": "mock",
"request": "launch",
"program": "${workspaceFolder}/${command:AskForProgramName}",
"stopOnEntry": true
"internalConsoleOptions": "openOnSessionStart",
"preLaunchTask": "npm: compile"
}
],
"compounds": [
@@ -1,18 +1,21 @@
{
"version": "2.0.0",
"tasks": [
{
"type": "npm",
"script": "compile",
"isBackground": false,
"problemMatcher": "$tsc-watch"
},
{
"type": "npm",
"script": "watch",
"problemMatcher": "$tsc-watch",
"group": "build",
"isBackground": true,
"presentation": {
"reveal": "never"
},
"group": {
"kind": "build",
"isDefault": true
}
"problemMatcher": [
"$ts-webpack-watch",
"$tslint-webpack-watch"
]
},
{
"type": "npm",
@@ -5,3 +5,8 @@ appveyor.yml
src/**/*
out/tests/**/*
**/*.js.map
build
sampleworkspace
node_modules
tsconfig.json
out
@@ -0,0 +1,54 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/

//@ts-check
'use strict';

//@ts-check
/** @typedef {import('webpack').Configuration} WebpackConfig **/

const path = require('path');

module.exports = /** @type WebpackConfig */ {
context: path.dirname(__dirname),
mode: 'none', // this leaves the source code as close as possible to the original (when packaging we set this to 'production')
target: 'node', // vscode extensions run in a Node.js-context
entry: {
extension: './src/extension.ts'
},
resolve: { // support reading TypeScript and JavaScript files
extensions: ['.ts', '.js']
},
node: {
__dirname: false, // leave the __dirname-behaviour intact
},
module: {
rules: [{
test: /\.ts$/,
exclude: /node_modules/,
use: [{
// configure TypeScript loader:
// * enable sources maps for end-to-end source maps
loader: 'ts-loader',
options: {
compilerOptions: {
'sourceMap': true,
'declaration': false
}
}
}]
}]
},
externals: {
vscode: "commonjs vscode" // the vscode-module is created on-the-fly and must be excluded. Add other modules that cannot be webpack'ed
},
output: {
filename: 'extension.js',
path: path.resolve(__dirname, '../dist/ext'),
libraryTarget: 'commonjs2',
devtoolModuleFilenameTemplate: "../[resource-path]",
},
devtool: 'source-map'
}
@@ -1,7 +1,7 @@
{
"name": "mock-debug",
"displayName": "Mock Debug",
"version": "0.43.0",
"version": "0.43.6",
"publisher": "andreweinand",
"description": "Starter extension for developing debug adapters for VS Code.",
"author": {
@@ -28,17 +28,21 @@
"url": "https://github.com/Microsoft/vscode-mock-debug/issues"
},
"scripts": {
"vscode:prepublish": "yarn run compile",
"vscode:prepublish": "yarn run package-ext && yarn run package-web",
"compile": "tsc -p ./",
"lint": "eslint src --ext ts",
"watch": "tsc -watch -p ./",
"watch": "webpack --watch --devtool nosources-source-map --info-verbosity verbose --config ./build/extension.webpack.config.js",
"watch2": "tsc -watch -p ./",
"pretest": "yarn run compile && yarn run lint",
"test": "node ./out/test/runTest.js",
"package": "vsce package",
"publish": "vsce publish",

"package-ext": "webpack --mode production --config ./build/extension.webpack.config.js",

"compile-web": "webpack --devtool nosources-source-map --config ./build/web-extension.webpack.config.js",
"watch-web": "webpack --watch --devtool nosources-source-map --info-verbosity verbose --config ./build/web-extension.webpack.config.js",
"package-web": "webpack --mode production --watch --config ./build/web-extension.webpack.config.js"
"package-web": "webpack --mode production --config ./build/web-extension.webpack.config.js"
},
"dependencies": {
"await-notify": "1.0.1",
@@ -61,7 +65,7 @@
"webpack": "^4.44.1",
"webpack-cli": "^3.3.12"
},
"main": "./out/extension",
"main": "./dist/ext/extension.js",
"browser": "./dist/web/extension.js",
"activationEvents": [
"onDebug",
@@ -17,8 +17,10 @@ export function activateMockDebug(context: vscode.ExtensionContext, factory?: vs
type: 'mock',
name: 'Run Editor Contents',
request: 'launch',
program: resource.fsPath
program: resource.toString(),
noDebug: true
}, {
//needs VS Code 1.49
//noDebug: true
});
}),
@@ -27,7 +29,8 @@ export function activateMockDebug(context: vscode.ExtensionContext, factory?: vs
type: 'mock',
name: 'Debug Editor Contents',
request: 'launch',
program: resource.fsPath
program: resource.toString(),
"stopOnEntry": true
});
}),
vscode.commands.registerCommand('extension.mock-debug.showAsHex', (variable) => {
@@ -123,10 +126,14 @@ class MockConfigurationProvider implements vscode.DebugConfigurationProvider {

export const workspaceFileAccessor: FileAccessor = {
async readFile(path: string) {
const uri = vscode.Uri.parse(path);
const bytes = await vscode.workspace.fs.readFile(uri);
const contents = Buffer.from(bytes).toString('utf8');
return contents;
try {
const uri = vscode.Uri.parse(path);
const bytes = await vscode.workspace.fs.readFile(uri);
const contents = Buffer.from(bytes).toString('utf8');
return contents;
} catch(e) {
return `cannot read '${path}'`;
}
}
};

0 comments on commit 78ba9cd

Please sign in to comment.