Change product build to use webpack

This commit is contained in:
roblou 2016-11-03 10:54:32 -07:00
Родитель 0d0d4ce647
Коммит bdd66d4a94
9 изменённых файлов: 93 добавлений и 16 удалений

Просмотреть файл

@ -1,8 +1,9 @@
language: node_js
node_js:
- "6.6"
- "7.0"
script:
- npm run build
- npm run build:test
- npm test

13
.vscode/launch.json поставляемый
Просмотреть файл

@ -1,12 +1,13 @@
{
"version": "0.1.0",
// "debugServer": "4712",
"configurations": [
{
"name": "launch as server",
"type": "node2",
"request": "launch",
"cwd": "${workspaceRoot}",
"program": "${workspaceRoot}/out/src/chromeDebug.js",
"program": "${workspaceRoot}/out/bundle.js",
"runtimeArgs": ["--harmony"],
"stopOnEntry": false,
"args": [ "--server=4712" ],
@ -15,12 +16,14 @@
},
{
"name": "test",
"type": "node",
"type": "node2",
"request": "launch",
"cwd": "${workspaceRoot}",
"runtimeExecutable": "npm",
"runtimeArgs": [
"run-script", "test"
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha",
"args": [
"-u", "tdd",
"--colors",
"out/test/**.test.js"
],
"stopOnEntry": false,
"sourceMaps": true,

2
.vscode/tasks.json поставляемый
Просмотреть файл

@ -7,7 +7,7 @@
"tasks": [
{
"taskName": "watch",
"args": ["run", "watch"],
"args": ["run", "build"],
"isBuildCommand": true,
"isWatching": true
}

Просмотреть файл

@ -19,7 +19,6 @@
"categories": [
"Debuggers"
],
"aiKey": "AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217",
"license": "SEE LICENSE IN LICENSE.txt",
"dependencies": {
"vscode-chrome-debug-core": "3.4.1",
@ -32,18 +31,22 @@
"@types/node": "^6.0.41",
"@types/source-map": "^0.1.27",
"chrome-remote-debug-protocol": "^1.2.20161007",
"glob": "^7.1.1",
"gulp": "^3.9.1",
"mocha": "^3.0.2",
"mockery": "^1.7.0",
"ts-loader": "^1.0.0",
"tslint": "^3.15.1",
"typemoq": "^0.3.3",
"typescript": "^2.0.3"
"typescript": "^2.0.3",
"webpack": "^1.13.3",
"webpack-fail-plugin": "^1.0.5"
},
"scripts": {
"build": "webpack -w",
"build:test": "tsc -p test/tsconfig.json -w",
"test": "mocha -u tdd -c 'out/test/**/*.test.js'",
"lint": "tslint -t verbose 'src/**/*.ts' 'test/**/*.ts'",
"build": "tsc",
"watch": "tsc -w",
"vscode:prepublish": "gulp verify-no-linked-modules"
},
"contributes": {
@ -65,8 +68,9 @@
{
"type": "chrome",
"label": "Chrome",
"program": "./out/src/chromeDebug.js",
"program": "./out/bundle.js",
"runtime": "node",
"aiKey": "AIF-d9b70cd4-b9f9-4d70-929b-a071c400b217",
"initialConfigurations": [
{
"name": "Launch Chrome against localhost, with sourcemaps",

Просмотреть файл

@ -23,6 +23,6 @@ ChromeDebugSession.run(ChromeDebugSession.getSession(
sourceMapTransformer: BaseSourceMapTransformer,
}));
/* tslint:disable:no-var-requires */
logger.log(EXTENSION_NAME + ': ' + require('../../package.json').version);
/* tslint:enable:no-var-requires */
// Injected by webpack
declare const VERSION: string;
logger.log(EXTENSION_NAME + ': ' + VERSION);

Просмотреть файл

@ -11,6 +11,7 @@ import Crdp from 'chrome-remote-debug-protocol';
export interface IMockChromeConnectionAPI {
apiObjects: Crdp.CrdpClient;
Console: Mock<Crdp.ConsoleClient>;
Debugger: Mock<Crdp.DebuggerClient>;
Runtime: Mock<Crdp.RuntimeClient>;
Inspector: Mock<Crdp.InspectorClient>;
@ -19,6 +20,13 @@ export interface IMockChromeConnectionAPI {
}
// See https://github.com/florinn/typemoq/issues/20
function getConsoleStubs() {
return {
enable() { },
onMessageAdded() { }
};
}
function getDebuggerStubs(mockEventEmitter) {
return {
setBreakpoint() { },
@ -53,6 +61,12 @@ function getInspectorStubs(mockEventEmitter) {
export function getMockChromeConnectionApi(): IMockChromeConnectionAPI {
const mockEventEmitter = new EventEmitter();
let mockConsole = Mock.ofInstance<Crdp.ConsoleClient>(<any>getConsoleStubs());
mockConsole.callBase = true;
mockConsole
.setup(x => x.enable())
.returns(() => Promise.resolve());
let mockDebugger = Mock.ofInstance<Crdp.DebuggerClient>(<any>getDebuggerStubs(mockEventEmitter));
mockDebugger.callBase = true;
mockDebugger
@ -69,6 +83,7 @@ export function getMockChromeConnectionApi(): IMockChromeConnectionAPI {
mockInspector.callBase = true;
const chromeConnectionAPI: Crdp.CrdpClient = <any>{
Console: mockConsole.object,
Debugger: mockDebugger.object,
Runtime: mockRuntime.object,
Inspector: mockInspector.object
@ -77,6 +92,7 @@ export function getMockChromeConnectionApi(): IMockChromeConnectionAPI {
return {
apiObjects: chromeConnectionAPI,
Console: mockConsole,
Debugger: mockDebugger,
Runtime: mockRuntime,
Inspector: mockInspector,

10
test/tsconfig.json Normal file
Просмотреть файл

@ -0,0 +1,10 @@
{
"compilerOptions": {
"module": "commonjs",
"noImplicitAny": false,
"removeComments": false,
"target": "ES6",
"sourceMap": true,
"outDir": "../out"
}
}

Просмотреть файл

@ -10,6 +10,7 @@
"exclude": [
"node_modules",
"!node_modules/@types",
"testapp/"
"testapp/",
"test/"
]
}

42
webpack.config.js Normal file
Просмотреть файл

@ -0,0 +1,42 @@
const webpack = require('webpack');
const path = require('path');
const fs = require('fs');
const glob = require('glob');
const nodeModules = {};
fs.readdirSync('node_modules')
.filter(f => !f.startsWith('bin'))
.forEach(mod => {
nodeModules[mod] = 'commonjs ' + mod;
});
module.exports = {
entry: {
src: './src/chromeDebug.ts'
},
devtool: 'source-map',
output: {
filename: 'out/bundle.js'
},
resolve: {
// Add '.ts' and '.tsx' as a resolvable extension.
extensions: ['', '.webpack.js', '.web.js', '.ts', '.tsx', '.js']
},
module: {
loaders: [
// all files with a '.ts' or '.tsx' extension will be handled by 'ts-loader'
{ test: /\.tsx?$/, loader: 'ts-loader' }
]
},
externals: nodeModules,
plugins: [
require('webpack-fail-plugin'),
new webpack.DefinePlugin({ VERSION: `"${require('./package.json').version}"` })
],
target: 'node',
node: {
__dirname: true
},
libraryTarget: 'commonjs',
library: 'library'
};