diff --git a/.vscode/launch.json b/.vscode/launch.json index 6cd4fbd..5976b05 100644 --- a/.vscode/launch.json +++ b/.vscode/launch.json @@ -17,7 +17,6 @@ ], "preLaunchTask": "npm: compile", "env": { - "AZCODE_VIRTUALMACHINES_IGNORE_BUNDLE": "1", "DEBUGTELEMETRY": "1", "NODE_DEBUG": "" } @@ -58,7 +57,6 @@ ], "preLaunchTask": "npm: compile", "env": { - "AZCODE_VIRTUALMACHINES_IGNORE_BUNDLE": "1", "MOCHA_grep": "", // RegExp of tests to run (empty for all) "MOCHA_enableTimeouts": "0", // Disable time-outs "DEBUGTELEMETRY": "1", diff --git a/gulpfile.ts b/gulpfile.ts index edb020e..df8ee41 100644 --- a/gulpfile.ts +++ b/gulpfile.ts @@ -11,10 +11,20 @@ // tslint:disable:no-unsafe-any import * as cp from 'child_process'; +import * as fse from 'fs-extra'; import * as gulp from 'gulp'; import * as path from 'path'; import { gulp_installAzureAccount, gulp_webpack } from 'vscode-azureextensiondev'; +async function prepareForWebpack(): Promise { + const mainJsPath: string = path.join(__dirname, 'main.js'); + let contents: string = (await fse.readFile(mainJsPath)).toString(); + contents = contents + .replace('out/src/extension', 'dist/extension.bundle') + .replace(', true /* ignoreBundle */', ''); + await fse.writeFile(mainJsPath, contents); +} + function test() { const env = process.env; env.DEBUGTELEMETRY = '1'; @@ -24,6 +34,6 @@ function test() { return cp.spawn('node', ['./node_modules/vscode/bin/test'], { stdio: 'inherit', env }); } -exports['webpack-dev'] = () => gulp_webpack('development'); -exports['webpack-prod'] = () => gulp_webpack('production'); +exports['webpack-dev'] = gulp.series(prepareForWebpack, () => gulp_webpack('development')); +exports['webpack-prod'] = gulp.series(prepareForWebpack, () => gulp_webpack('production')); exports.test = gulp.series(gulp_installAzureAccount, test); diff --git a/main.js b/main.js index 102263a..0171723 100644 --- a/main.js +++ b/main.js @@ -16,12 +16,10 @@ let perfStats = { Object.defineProperty(exports, "__esModule", { value: true }); -const ignoreBundle = !/^(false|0)?$/i.test(process.env.AZCODE_VIRTUALMACHINES_IGNORE_BUNDLE || ''); -const extensionPath = ignoreBundle ? "./out/src/extension" : "./dist/extension.bundle"; -const extension = require(extensionPath); +const extension = require('./out/src/extension'); async function activate(ctx) { - return await extension.activateInternal(ctx, perfStats); + return await extension.activateInternal(ctx, perfStats, true /* ignoreBundle */); } async function deactivate(ctx) { diff --git a/src/extension.ts b/src/extension.ts index a2ad1ad..e8529ad 100644 --- a/src/extension.ts +++ b/src/extension.ts @@ -21,8 +21,9 @@ import { AzureAccountTreeItem } from './tree/AzureAccountTreeItem'; import { SubscriptionTreeItem } from './tree/SubscriptionTreeItem'; import { VirtualMachineTreeItem } from './tree/VirtualMachineTreeItem'; -export async function activateInternal(context: vscode.ExtensionContext, perfStats: { loadStartTime: number; loadEndTime: number }): Promise { +export async function activateInternal(context: vscode.ExtensionContext, perfStats: { loadStartTime: number; loadEndTime: number }, ignoreBundle?: boolean): Promise { ext.context = context; + ext.ignoreBundle = ignoreBundle; ext.reporter = createTelemetryReporter(context); ext.outputChannel = createAzExtOutputChannel('Azure Virtual Machines', ext.prefix); context.subscriptions.push(ext.outputChannel); diff --git a/src/extensionVariables.ts b/src/extensionVariables.ts index 310ba50..c9b70ad 100644 --- a/src/extensionVariables.ts +++ b/src/extensionVariables.ts @@ -19,7 +19,6 @@ export namespace ext { export let tree: AzExtTreeDataProvider; export let treeView: TreeView; export let azureAccountTreeItem: AzureAccountTreeItem; - // tslint:disable-next-line: strict-boolean-expressions - export let ignoreBundle: boolean = !/^(false|0)?$/i.test(process.env.AZCODE_VIRTUALMACHINES_IGNORE_BUNDLE || ''); + export let ignoreBundle: boolean | undefined; export const prefix: string = 'azureVirtualMachines'; }