mirror of
https://github.com/microsoft/vscode.git
synced 2026-04-17 07:13:45 +01:00
Merge pull request #298808 from mjbvz/dev/mjbvz/occasional-chipmunk
Port github-authentication extension to use esbuild
This commit is contained in:
@@ -3,7 +3,7 @@ src/**
|
||||
!src/common/config.json
|
||||
out/**
|
||||
build/**
|
||||
extension.webpack.config.js
|
||||
extension-browser.webpack.config.js
|
||||
esbuild.mts
|
||||
esbuild.browser.mts
|
||||
tsconfig*.json
|
||||
package-lock.json
|
||||
|
||||
40
extensions/github-authentication/esbuild.browser.mts
Normal file
40
extensions/github-authentication/esbuild.browser.mts
Normal file
@@ -0,0 +1,40 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
import * as path from 'node:path';
|
||||
import type { Plugin } from 'esbuild';
|
||||
import { run } from '../esbuild-extension-common.mts';
|
||||
|
||||
const srcDir = path.join(import.meta.dirname, 'src');
|
||||
const outDir = path.join(import.meta.dirname, 'dist', 'browser');
|
||||
|
||||
/**
|
||||
* Plugin that rewrites `./node/*` imports to `./browser/*` for the web build,
|
||||
* replacing the platform-specific implementations with their browser equivalents.
|
||||
*/
|
||||
const platformModulesPlugin: Plugin = {
|
||||
name: 'platform-modules',
|
||||
setup(build) {
|
||||
build.onResolve({ filter: /\/node\// }, args => {
|
||||
if (args.kind !== 'import-statement' || !args.resolveDir) {
|
||||
return;
|
||||
}
|
||||
const remapped = args.path.replace('/node/', '/browser/');
|
||||
return build.resolve(remapped, { resolveDir: args.resolveDir, kind: args.kind });
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
run({
|
||||
platform: 'browser',
|
||||
entryPoints: {
|
||||
'extension': path.join(srcDir, 'extension.ts'),
|
||||
},
|
||||
srcDir,
|
||||
outdir: outDir,
|
||||
additionalOptions: {
|
||||
plugins: [platformModulesPlugin],
|
||||
tsconfig: path.join(import.meta.dirname, 'tsconfig.browser.json'),
|
||||
},
|
||||
}, process.argv);
|
||||
@@ -2,12 +2,17 @@
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
// @ts-check
|
||||
import withDefaults from '../shared.webpack.config.mjs';
|
||||
import * as path from 'node:path';
|
||||
import { run } from '../esbuild-extension-common.mts';
|
||||
|
||||
export default withDefaults({
|
||||
context: import.meta.dirname,
|
||||
entry: {
|
||||
extension: './src/extension.ts',
|
||||
const srcDir = path.join(import.meta.dirname, 'src');
|
||||
const outDir = path.join(import.meta.dirname, 'dist');
|
||||
|
||||
run({
|
||||
platform: 'node',
|
||||
entryPoints: {
|
||||
'extension': path.join(srcDir, 'extension.ts'),
|
||||
},
|
||||
});
|
||||
srcDir,
|
||||
outdir: outDir,
|
||||
}, process.argv);
|
||||
@@ -1,24 +0,0 @@
|
||||
/*---------------------------------------------------------------------------------------------
|
||||
* Copyright (c) Microsoft Corporation. All rights reserved.
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
// @ts-check
|
||||
import path from 'path';
|
||||
import { browser as withBrowserDefaults } from '../shared.webpack.config.mjs';
|
||||
|
||||
export default withBrowserDefaults({
|
||||
context: import.meta.dirname,
|
||||
node: false,
|
||||
entry: {
|
||||
extension: './src/extension.ts',
|
||||
},
|
||||
resolve: {
|
||||
alias: {
|
||||
'uuid': path.resolve(import.meta.dirname, 'node_modules/uuid/dist/esm-browser/index.js'),
|
||||
'./node/authServer': path.resolve(import.meta.dirname, 'src/browser/authServer'),
|
||||
'./node/crypto': path.resolve(import.meta.dirname, 'src/browser/crypto'),
|
||||
'./node/fetch': path.resolve(import.meta.dirname, 'src/browser/fetch'),
|
||||
'./node/buffer': path.resolve(import.meta.dirname, 'src/browser/buffer'),
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -79,9 +79,9 @@
|
||||
"browser": "./dist/browser/extension.js",
|
||||
"scripts": {
|
||||
"compile": "gulp compile-extension:github-authentication",
|
||||
"compile-web": "npx webpack-cli --config extension-browser.webpack.config --mode none",
|
||||
"compile-web": "node esbuild.browser.mts",
|
||||
"watch": "gulp watch-extension:github-authentication",
|
||||
"watch-web": "npx webpack-cli --config extension-browser.webpack.config --mode none --watch --info-verbosity verbose",
|
||||
"watch-web": "node esbuild.browser.mts --watch",
|
||||
"vscode:prepublish": "npm run compile"
|
||||
},
|
||||
"dependencies": {
|
||||
|
||||
@@ -10,3 +10,9 @@ export function startServer(_: any): any {
|
||||
export function createServer(_: any): any {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
|
||||
export class LoopbackAuthServer {
|
||||
constructor(..._args: any[]) {
|
||||
throw new Error('Not implemented');
|
||||
}
|
||||
}
|
||||
|
||||
8
extensions/github-authentication/tsconfig.browser.json
Normal file
8
extensions/github-authentication/tsconfig.browser.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {},
|
||||
"exclude": [
|
||||
"./src/node/**",
|
||||
"./src/test/**"
|
||||
]
|
||||
}
|
||||
Reference in New Issue
Block a user