Skip to content

Commit 21f454b

Browse files
authored
Extract fs-extra and tar to node/browser folders so we can alias them in webtarget (#327)
* Alias the node code with browser implementation on webworker target * Revert main * Update package-lock
1 parent 6b7a120 commit 21f454b

File tree

9 files changed

+98
-28
lines changed

9 files changed

+98
-28
lines changed

main.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
1919
const extension = require('./out/src/extension');
2020

2121
async function activate(ctx) {
22-
return await extension.activate(ctx, perfStats);
22+
return await extension.activate(ctx, perfStats, true /*ignoreBundle*/);
2323
}
2424

2525
async function deactivate(ctx) {

package-lock.json

Lines changed: 52 additions & 23 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,7 @@
317317
},
318318
"devDependencies": {
319319
"@microsoft/eslint-config-azuretools": "^0.1.0",
320-
"@microsoft/vscode-azext-dev": "^1.0.3",
320+
"@microsoft/vscode-azext-dev": "^1.0.4",
321321
"@types/fs-extra": "^8.1.1",
322322
"@types/git-url-parse": "^9.0.0",
323323
"@types/gulp": "^4.0.6",
@@ -352,6 +352,7 @@
352352
"@microsoft/vscode-azext-azureutils": "^1.0.1",
353353
"@microsoft/vscode-azext-utils": "^1.1.0",
354354
"@microsoft/vscode-azureresources-api": "^2.0.2",
355+
"buffer": "^6.0.3",
355356
"dayjs": "^1.11.3",
356357
"dotenv": "^16.0.0",
357358
"fs-extra": "^8.1.0",

src/browser/fs-extra.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
/* eslint-disable */
7+
export const fse = {};

src/browser/tar.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
/* eslint-disable */
7+
export const tar = {}

src/commands/imageSource/buildImageInAzure/UploadSourceCodeStep.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@
44
*--------------------------------------------------------------------------------------------*/
55
import { getResourceGroupFromId } from '@microsoft/vscode-azext-azureutils';
66
import { AzExtFsExtra, AzureWizardExecuteStep, nonNullValue } from '@microsoft/vscode-azext-utils';
7-
import * as fse from 'fs-extra';
8-
import * as tar from 'tar';
7+
import { fse } from '../../../node/fs-extra';
8+
import { tar } from '../../../node/tar';
99
import { createContainerRegistryManagementClient } from '../../../utils/azureClients';
1010
import { IBuildImageInAzureContext } from './IBuildImageInAzureContext';
1111

src/node/fs-extra.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
/* eslint-disable */
7+
import * as nodeFse from 'fs-extra';
8+
export const fse = nodeFse;

src/node/tar.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
/*---------------------------------------------------------------------------------------------
2+
* Copyright (c) Microsoft Corporation. All rights reserved.
3+
* Licensed under the MIT License. See License.txt in the project root for license information.
4+
*--------------------------------------------------------------------------------------------*/
5+
6+
/* eslint-disable */
7+
import * as nodeTar from 'tar';
8+
export const tar = nodeTar;

webpack.config.js

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
const process = require('process');
1313
const dev = require("@microsoft/vscode-azext-dev");
1414
const webpack = require('webpack');
15+
const path = require('path');
1516

1617
let DEBUG_WEBPACK = !/^(false|0)?$/i.test(process.env.DEBUG_WEBPACK || '');
1718

@@ -32,6 +33,11 @@ let nodeConfig = dev.getDefaultWebpackConfig({
3233
suppressCleanDistFolder: true
3334
});
3435

36+
const nodeSrcPath = path.resolve(__dirname, 'src/node');
37+
38+
const alias = {};
39+
alias[nodeSrcPath] = path.resolve(__dirname, 'src/browser');
40+
3541
let webConfig = dev.getDefaultWebpackConfig({
3642
projectRoot: __dirname,
3743
verbosity: DEBUG_WEBPACK ? 'debug' : 'normal',
@@ -46,10 +52,14 @@ let webConfig = dev.getDefaultWebpackConfig({
4652
'../build/default/bufferutil': 'commonjs ../build/default/bufferutil',
4753
},
4854
target: 'webworker',
55+
plugins: [new webpack.ProvidePlugin({
56+
Buffer: ['buffer', 'Buffer'],
57+
})],
4958
suppressCleanDistFolder: true,
5059
resolveFallbackAliases: {
5160
'constants': false
52-
}
61+
},
62+
alias
5363
});
5464

5565
if (DEBUG_WEBPACK) {

0 commit comments

Comments
 (0)