remove swc

pull/230238/head
Johannes 2024-10-04 11:23:51 +02:00
parent 4a5fdb2ff1
commit 6e4221f0ec
No known key found for this signature in database
GPG Key ID: 6DEF802A22264FCA
10 changed files with 14 additions and 417 deletions

View File

@ -161,7 +161,7 @@ steps:
displayName: Build server (web)
- ${{ else }}:
- script: npm run gulp transpile-client-swc transpile-extensions
- script: npm run gulp transpile-client-esbuild transpile-extensions
env:
GITHUB_TOKEN: "$(github-distro-mixin-password)"
displayName: Transpile

View File

@ -275,7 +275,7 @@ steps:
displayName: Check GLIBC and GLIBCXX dependencies in server archive
- ${{ else }}:
- script: npm run gulp "transpile-client-swc" "transpile-extensions"
- script: npm run gulp "transpile-client-esbuild" "transpile-extensions"
env:
GITHUB_TOKEN: "$(github-distro-mixin-password)"
displayName: Transpile client and extensions

View File

@ -129,7 +129,7 @@ steps:
retryCountOnTaskFailure: 3
- ${{ if eq(parameters.VSCODE_QUALITY, 'oss') }}:
- powershell: npm run gulp "transpile-client-swc" "transpile-extensions"
- powershell: npm run gulp "transpile-client-esbuild" "transpile-extensions"
env:
GITHUB_TOKEN: "$(github-distro-mixin-password)"
displayName: Transpile client and extensions

View File

@ -20,7 +20,7 @@ gulp.task(compileApiProposalNamesTask);
gulp.task(watchApiProposalNamesTask);
// SWC Client Transpile
const transpileClientSWCTask = task.define('transpile-client-swc', task.series(util.rimraf('out'), transpileTask('src', 'out', true)));
const transpileClientSWCTask = task.define('transpile-client-esbuild', task.series(util.rimraf('out'), transpileTask('src', 'out', true)));
gulp.task(transpileClientSWCTask);
// Transpile only

View File

@ -19,11 +19,11 @@ const util = require("./util");
const fancyLog = require("fancy-log");
const ansiColors = require("ansi-colors");
const os = require("os");
const ts = require("typescript");
const File = require("vinyl");
const task = require("./task");
const index_1 = require("./mangle/index");
const postcss_1 = require("./postcss");
const ts = require("typescript");
const watch = require('./watch');
// --- gulp-tsb: compile and transpile --------------------------------
const reporter = (0, reporter_1.createReporter)();
@ -52,7 +52,7 @@ function createCompile(src, { build, emitError, transpileOnly, preserveEnglish }
const compilation = tsb.create(projectPath, overrideOptions, {
verbose: false,
transpileOnly: Boolean(transpileOnly),
transpileWithSwc: typeof transpileOnly !== 'boolean' && transpileOnly.swc
transpileWithSwc: typeof transpileOnly !== 'boolean' && transpileOnly.esbuild
}, err => reporter(err));
function pipeline(token) {
const bom = require('gulp-bom');
@ -88,9 +88,9 @@ function createCompile(src, { build, emitError, transpileOnly, preserveEnglish }
pipeline.projectPath = projectPath;
return pipeline;
}
function transpileTask(src, out, swc) {
function transpileTask(src, out, esbuild) {
const task = () => {
const transpile = createCompile(src, { build: false, emitError: true, transpileOnly: { swc }, preserveEnglish: false });
const transpile = createCompile(src, { build: false, emitError: true, transpileOnly: { esbuild }, preserveEnglish: false });
const srcPipe = gulp.src(`${src}/**`, { base: `${src}` });
return srcPipe
.pipe(transpile())

View File

@ -14,12 +14,12 @@ import * as util from './util';
import * as fancyLog from 'fancy-log';
import * as ansiColors from 'ansi-colors';
import * as os from 'os';
import ts = require('typescript');
import * as File from 'vinyl';
import * as task from './task';
import { Mangler } from './mangle/index';
import { RawSourceMap } from 'source-map';
import { gulpPostcss } from './postcss';
import ts = require('typescript');
const watch = require('./watch');
@ -45,7 +45,7 @@ function getTypeScriptCompilerOptions(src: string): ts.CompilerOptions {
interface ICompileTaskOptions {
readonly build: boolean;
readonly emitError: boolean;
readonly transpileOnly: boolean | { swc: boolean };
readonly transpileOnly: boolean | { esbuild: boolean };
readonly preserveEnglish: boolean;
}
@ -63,7 +63,7 @@ function createCompile(src: string, { build, emitError, transpileOnly, preserveE
const compilation = tsb.create(projectPath, overrideOptions, {
verbose: false,
transpileOnly: Boolean(transpileOnly),
transpileWithSwc: typeof transpileOnly !== 'boolean' && transpileOnly.swc
transpileWithSwc: typeof transpileOnly !== 'boolean' && transpileOnly.esbuild
}, err => reporter(err));
function pipeline(token?: util.ICancellationToken) {
@ -105,11 +105,11 @@ function createCompile(src: string, { build, emitError, transpileOnly, preserveE
return pipeline;
}
export function transpileTask(src: string, out: string, swc: boolean): task.StreamTask {
export function transpileTask(src: string, out: string, esbuild: boolean): task.StreamTask {
const task = () => {
const transpile = createCompile(src, { build: false, emitError: true, transpileOnly: { swc }, preserveEnglish: false });
const transpile = createCompile(src, { build: false, emitError: true, transpileOnly: { esbuild }, preserveEnglish: false });
const srcPipe = gulp.src(`${src}/**`, { base: `${src}` });
return srcPipe

View File

@ -4,8 +4,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
Object.defineProperty(exports, "__esModule", { value: true });
exports.SwcTranspiler = exports.ESBuildTranspiler = exports.TscTranspiler = void 0;
const swc = require("@swc/core");
exports.ESBuildTranspiler = exports.TscTranspiler = void 0;
const esbuild = require("esbuild");
const ts = require("typescript");
const threads = require("node:worker_threads");
@ -301,98 +300,4 @@ function _isDefaultEmpty(src) {
.replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm, '$1')
.trim().length === 0;
}
class SwcTranspiler {
_logFn;
_onError;
_cmdLine;
onOutfile;
_outputFileNames;
_jobs = [];
constructor(_logFn, _onError, configFilePath, _cmdLine) {
this._logFn = _logFn;
this._onError = _onError;
this._cmdLine = _cmdLine;
_logFn('Transpile', `will use SWC to transpile source files`);
this._outputFileNames = new OutputFileNameOracle(_cmdLine, configFilePath);
}
async join() {
const jobs = this._jobs.slice();
this._jobs.length = 0;
await Promise.allSettled(jobs);
}
transpile(file) {
if (this._cmdLine.options.noEmit) {
// not doing ANYTHING here
return;
}
const tsSrc = String(file.contents);
const t1 = Date.now();
let options = SwcTranspiler._swcrcEsm;
if (this._cmdLine.options.module === ts.ModuleKind.AMD) {
const isAmd = /\n(import|export)/m.test(tsSrc);
if (isAmd) {
options = SwcTranspiler._swcrcAmd;
}
}
else if (this._cmdLine.options.module === ts.ModuleKind.CommonJS || this._cmdLine.options.module === ts.ModuleKind.Node16) {
options = SwcTranspiler._swcrcCommonJS;
}
this._jobs.push(swc.transform(tsSrc, options).then(output => {
// check if output of a DTS-files isn't just "empty" and iff so
// skip this file
if (file.path.endsWith('.d.ts') && _isDefaultEmpty(output.code)) {
return;
}
const outBase = this._cmdLine.options.outDir ?? file.base;
const outPath = this._outputFileNames.getOutputFileName(file.path);
this.onOutfile(new Vinyl({
path: outPath,
base: outBase,
contents: Buffer.from(output.code),
}));
this._logFn('Transpile', `swc took ${Date.now() - t1}ms for ${file.path}`);
}).catch(err => {
this._onError(err);
}));
}
// --- .swcrc
static _swcrcAmd = {
exclude: '\.js$',
jsc: {
parser: {
syntax: 'typescript',
tsx: false,
decorators: true
},
target: 'es2022',
loose: false,
minify: {
compress: false,
mangle: false
},
transform: {
useDefineForClassFields: false,
},
},
module: {
type: 'amd',
noInterop: false
},
minify: false,
};
static _swcrcCommonJS = {
...this._swcrcAmd,
module: {
type: 'commonjs',
importInterop: 'swc'
}
};
static _swcrcEsm = {
...this._swcrcAmd,
module: {
type: 'es6'
}
};
}
exports.SwcTranspiler = SwcTranspiler;
//# sourceMappingURL=transpiler.js.map

View File

@ -3,7 +3,6 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import * as swc from '@swc/core';
import * as esbuild from 'esbuild';
import * as ts from 'typescript';
import * as threads from 'node:worker_threads';
@ -380,114 +379,3 @@ function _isDefaultEmpty(src: string): boolean {
.replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm, '$1')
.trim().length === 0;
}
export class SwcTranspiler implements ITranspiler {
onOutfile?: ((file: Vinyl) => void) | undefined;
private readonly _outputFileNames: OutputFileNameOracle;
private _jobs: Promise<any>[] = [];
constructor(
private readonly _logFn: (topic: string, message: string) => void,
private readonly _onError: (err: any) => void,
configFilePath: string,
private readonly _cmdLine: ts.ParsedCommandLine
) {
_logFn('Transpile', `will use SWC to transpile source files`);
this._outputFileNames = new OutputFileNameOracle(_cmdLine, configFilePath);
}
async join(): Promise<void> {
const jobs = this._jobs.slice();
this._jobs.length = 0;
await Promise.allSettled(jobs);
}
transpile(file: Vinyl): void {
if (this._cmdLine.options.noEmit) {
// not doing ANYTHING here
return;
}
const tsSrc = String(file.contents);
const t1 = Date.now();
let options: swc.Options = SwcTranspiler._swcrcEsm;
if (this._cmdLine.options.module === ts.ModuleKind.AMD) {
const isAmd = /\n(import|export)/m.test(tsSrc);
if (isAmd) {
options = SwcTranspiler._swcrcAmd;
}
} else if (this._cmdLine.options.module === ts.ModuleKind.CommonJS || this._cmdLine.options.module === ts.ModuleKind.Node16) {
options = SwcTranspiler._swcrcCommonJS;
}
this._jobs.push(swc.transform(tsSrc, options).then(output => {
// check if output of a DTS-files isn't just "empty" and iff so
// skip this file
if (file.path.endsWith('.d.ts') && _isDefaultEmpty(output.code)) {
return;
}
const outBase = this._cmdLine.options.outDir ?? file.base;
const outPath = this._outputFileNames.getOutputFileName(file.path);
this.onOutfile!(new Vinyl({
path: outPath,
base: outBase,
contents: Buffer.from(output.code),
}));
this._logFn('Transpile', `swc took ${Date.now() - t1}ms for ${file.path}`);
}).catch(err => {
this._onError(err);
}));
}
// --- .swcrc
private static readonly _swcrcAmd: swc.Options = {
exclude: '\.js$',
jsc: {
parser: {
syntax: 'typescript',
tsx: false,
decorators: true
},
target: 'es2022',
loose: false,
minify: {
compress: false,
mangle: false
},
transform: {
useDefineForClassFields: false,
},
},
module: {
type: 'amd',
noInterop: false
},
minify: false,
};
private static readonly _swcrcCommonJS: swc.Options = {
...this._swcrcAmd,
module: {
type: 'commonjs',
importInterop: 'swc'
}
};
private static readonly _swcrcEsm: swc.Options = {
...this._swcrcAmd,
module: {
type: 'es6'
}
};
}

195
package-lock.json generated
View File

@ -54,7 +54,6 @@
},
"devDependencies": {
"@playwright/test": "^1.46.1",
"@swc/core": "1.3.62",
"@types/cookie": "^0.3.3",
"@types/debug": "^4.1.5",
"@types/eslint": "^8.56.10",
@ -1794,200 +1793,6 @@
"integrity": "sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==",
"dev": true
},
"node_modules/@swc/core": {
"version": "1.3.62",
"resolved": "https://registry.npmjs.org/@swc/core/-/core-1.3.62.tgz",
"integrity": "sha512-J58hWY+/G8vOr4J6ZH9hLg0lMSijZtqIIf4HofZezGog/pVX6sJyBJ40dZ1ploFkDIlWTWvJyqtpesBKS73gkQ==",
"dev": true,
"hasInstallScript": true,
"engines": {
"node": ">=10"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/swc"
},
"optionalDependencies": {
"@swc/core-darwin-arm64": "1.3.62",
"@swc/core-darwin-x64": "1.3.62",
"@swc/core-linux-arm-gnueabihf": "1.3.62",
"@swc/core-linux-arm64-gnu": "1.3.62",
"@swc/core-linux-arm64-musl": "1.3.62",
"@swc/core-linux-x64-gnu": "1.3.62",
"@swc/core-linux-x64-musl": "1.3.62",
"@swc/core-win32-arm64-msvc": "1.3.62",
"@swc/core-win32-ia32-msvc": "1.3.62",
"@swc/core-win32-x64-msvc": "1.3.62"
},
"peerDependencies": {
"@swc/helpers": "^0.5.0"
},
"peerDependenciesMeta": {
"@swc/helpers": {
"optional": true
}
}
},
"node_modules/@swc/core-darwin-arm64": {
"version": "1.3.62",
"resolved": "https://registry.npmjs.org/@swc/core-darwin-arm64/-/core-darwin-arm64-1.3.62.tgz",
"integrity": "sha512-MmGilibITz68LEje6vJlKzc2gUUSgzvB3wGLSjEORikTNeM7P8jXVxE4A8fgZqDeudJUm9HVWrxCV+pHDSwXhA==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=10"
}
},
"node_modules/@swc/core-darwin-x64": {
"version": "1.3.62",
"resolved": "https://registry.npmjs.org/@swc/core-darwin-x64/-/core-darwin-x64-1.3.62.tgz",
"integrity": "sha512-Xl93MMB3sCWVlYWuQIB+v6EQgzoiuQYK5tNt9lsHoIEVu2zLdkQjae+5FUHZb1VYqCXIiWcULFfVz0R4Sjb7JQ==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": ">=10"
}
},
"node_modules/@swc/core-linux-arm-gnueabihf": {
"version": "1.3.62",
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm-gnueabihf/-/core-linux-arm-gnueabihf-1.3.62.tgz",
"integrity": "sha512-nJsp6O7kCtAjTTMcIjVB0g5y1JNiYAa5q630eiwrnaHUusEFoANDdORI3Z9vXeikMkng+6yIv9/V8Rb093xLjQ==",
"cpu": [
"arm"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=10"
}
},
"node_modules/@swc/core-linux-arm64-gnu": {
"version": "1.3.62",
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-gnu/-/core-linux-arm64-gnu-1.3.62.tgz",
"integrity": "sha512-XGsV93vpUAopDt5y6vPwbK1Nc/MlL55L77bAZUPIiosWD1cWWPHNtNSpriE6+I+JiMHe0pqtfS/SSTk6ZkFQVw==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=10"
}
},
"node_modules/@swc/core-linux-arm64-musl": {
"version": "1.3.62",
"resolved": "https://registry.npmjs.org/@swc/core-linux-arm64-musl/-/core-linux-arm64-musl-1.3.62.tgz",
"integrity": "sha512-ESUmJjSlTTkoBy9dMG49opcNn8BmviqStMhwyeD1G8XRnmRVCZZgoBOKdvCXmJhw8bQXDhZumeaTUB+OFUKVXg==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=10"
}
},
"node_modules/@swc/core-linux-x64-gnu": {
"version": "1.3.62",
"resolved": "https://registry.npmjs.org/@swc/core-linux-x64-gnu/-/core-linux-x64-gnu-1.3.62.tgz",
"integrity": "sha512-wnHJkt3ZBrax3SFnUHDcncG6mrSg9ZZjMhQV9Mc3JL1x1s1Gy9rGZCoBNnV/BUZWTemxIBcQbANRSDut/WO+9A==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=10"
}
},
"node_modules/@swc/core-linux-x64-musl": {
"version": "1.3.62",
"resolved": "https://registry.npmjs.org/@swc/core-linux-x64-musl/-/core-linux-x64-musl-1.3.62.tgz",
"integrity": "sha512-9oRbuTC/VshB66Rgwi3pTq3sPxSTIb8k9L1vJjES+dDMKa29DAjPtWCXG/pyZ00ufpFZgkGEuAHH5uqUcr1JQg==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"linux"
],
"engines": {
"node": ">=10"
}
},
"node_modules/@swc/core-win32-arm64-msvc": {
"version": "1.3.62",
"resolved": "https://registry.npmjs.org/@swc/core-win32-arm64-msvc/-/core-win32-arm64-msvc-1.3.62.tgz",
"integrity": "sha512-zv14vlF2VRrxS061XkfzGjCYnOrEo5glKJjLK5PwUKysIoVrx/L8nAbFxjkX5cObdlyoqo+ekelyBPAO+4bS0w==",
"cpu": [
"arm64"
],
"dev": true,
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=10"
}
},
"node_modules/@swc/core-win32-ia32-msvc": {
"version": "1.3.62",
"resolved": "https://registry.npmjs.org/@swc/core-win32-ia32-msvc/-/core-win32-ia32-msvc-1.3.62.tgz",
"integrity": "sha512-8MC/PZQSsOP2iA/81tAfNRqMWyEqTS/8zKUI67vPuLvpx6NAjRn3E9qBv7iFqH79iqZNzqSMo3awnLrKZyFbcw==",
"cpu": [
"ia32"
],
"dev": true,
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=10"
}
},
"node_modules/@swc/core-win32-x64-msvc": {
"version": "1.3.62",
"resolved": "https://registry.npmjs.org/@swc/core-win32-x64-msvc/-/core-win32-x64-msvc-1.3.62.tgz",
"integrity": "sha512-GJSmUJ95HKHZXAxiuPUmrcm/S3ivQvEzXhOZaIqYBIwUsm02vFZkClsV7eIKzWjso1t0+I/8MjrnUNaSWqh1rQ==",
"cpu": [
"x64"
],
"dev": true,
"optional": true,
"os": [
"win32"
],
"engines": {
"node": ">=10"
}
},
"node_modules/@szmarczak/http-timer": {
"version": "4.0.6",
"resolved": "https://registry.npmjs.org/@szmarczak/http-timer/-/http-timer-4.0.6.tgz",

View File

@ -112,7 +112,6 @@
},
"devDependencies": {
"@playwright/test": "^1.46.1",
"@swc/core": "1.3.62",
"@types/cookie": "^0.3.3",
"@types/debug": "^4.1.5",
"@types/eslint": "^8.56.10",