Skip to content

Commit 6e4221f

Browse files
committed
remove swc
1 parent 4a5fdb2 commit 6e4221f

10 files changed

+14
-417
lines changed

build/azure-pipelines/darwin/product-build-darwin.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ steps:
161161
displayName: Build server (web)
162162
163163
- ${{ else }}:
164-
- script: npm run gulp transpile-client-swc transpile-extensions
164+
- script: npm run gulp transpile-client-esbuild transpile-extensions
165165
env:
166166
GITHUB_TOKEN: "$(github-distro-mixin-password)"
167167
displayName: Transpile

build/azure-pipelines/linux/product-build-linux.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ steps:
275275
displayName: Check GLIBC and GLIBCXX dependencies in server archive
276276
277277
- ${{ else }}:
278-
- script: npm run gulp "transpile-client-swc" "transpile-extensions"
278+
- script: npm run gulp "transpile-client-esbuild" "transpile-extensions"
279279
env:
280280
GITHUB_TOKEN: "$(github-distro-mixin-password)"
281281
displayName: Transpile client and extensions

build/azure-pipelines/win32/product-build-win32.yml

+1-1
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ steps:
129129
retryCountOnTaskFailure: 3
130130

131131
- ${{ if eq(parameters.VSCODE_QUALITY, 'oss') }}:
132-
- powershell: npm run gulp "transpile-client-swc" "transpile-extensions"
132+
- powershell: npm run gulp "transpile-client-esbuild" "transpile-extensions"
133133
env:
134134
GITHUB_TOKEN: "$(github-distro-mixin-password)"
135135
displayName: Transpile client and extensions

build/gulpfile.js

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ gulp.task(compileApiProposalNamesTask);
2020
gulp.task(watchApiProposalNamesTask);
2121

2222
// SWC Client Transpile
23-
const transpileClientSWCTask = task.define('transpile-client-swc', task.series(util.rimraf('out'), transpileTask('src', 'out', true)));
23+
const transpileClientSWCTask = task.define('transpile-client-esbuild', task.series(util.rimraf('out'), transpileTask('src', 'out', true)));
2424
gulp.task(transpileClientSWCTask);
2525

2626
// Transpile only

build/lib/compilation.js

+4-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/lib/compilation.ts

+5-5
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,12 @@ import * as util from './util';
1414
import * as fancyLog from 'fancy-log';
1515
import * as ansiColors from 'ansi-colors';
1616
import * as os from 'os';
17-
import ts = require('typescript');
1817
import * as File from 'vinyl';
1918
import * as task from './task';
2019
import { Mangler } from './mangle/index';
2120
import { RawSourceMap } from 'source-map';
2221
import { gulpPostcss } from './postcss';
22+
import ts = require('typescript');
2323
const watch = require('./watch');
2424

2525

@@ -45,7 +45,7 @@ function getTypeScriptCompilerOptions(src: string): ts.CompilerOptions {
4545
interface ICompileTaskOptions {
4646
readonly build: boolean;
4747
readonly emitError: boolean;
48-
readonly transpileOnly: boolean | { swc: boolean };
48+
readonly transpileOnly: boolean | { esbuild: boolean };
4949
readonly preserveEnglish: boolean;
5050
}
5151

@@ -63,7 +63,7 @@ function createCompile(src: string, { build, emitError, transpileOnly, preserveE
6363
const compilation = tsb.create(projectPath, overrideOptions, {
6464
verbose: false,
6565
transpileOnly: Boolean(transpileOnly),
66-
transpileWithSwc: typeof transpileOnly !== 'boolean' && transpileOnly.swc
66+
transpileWithSwc: typeof transpileOnly !== 'boolean' && transpileOnly.esbuild
6767
}, err => reporter(err));
6868

6969
function pipeline(token?: util.ICancellationToken) {
@@ -105,11 +105,11 @@ function createCompile(src: string, { build, emitError, transpileOnly, preserveE
105105
return pipeline;
106106
}
107107

108-
export function transpileTask(src: string, out: string, swc: boolean): task.StreamTask {
108+
export function transpileTask(src: string, out: string, esbuild: boolean): task.StreamTask {
109109

110110
const task = () => {
111111

112-
const transpile = createCompile(src, { build: false, emitError: true, transpileOnly: { swc }, preserveEnglish: false });
112+
const transpile = createCompile(src, { build: false, emitError: true, transpileOnly: { esbuild }, preserveEnglish: false });
113113
const srcPipe = gulp.src(`${src}/**`, { base: `${src}` });
114114

115115
return srcPipe

build/lib/tsb/transpiler.js

+1-96
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

build/lib/tsb/transpiler.ts

-112
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import * as swc from '@swc/core';
76
import * as esbuild from 'esbuild';
87
import * as ts from 'typescript';
98
import * as threads from 'node:worker_threads';
@@ -380,114 +379,3 @@ function _isDefaultEmpty(src: string): boolean {
380379
.replace(/\/\*[\s\S]*?\*\/|([^\\:]|^)\/\/.*$/gm, '$1')
381380
.trim().length === 0;
382381
}
383-
384-
385-
export class SwcTranspiler implements ITranspiler {
386-
387-
onOutfile?: ((file: Vinyl) => void) | undefined;
388-
389-
private readonly _outputFileNames: OutputFileNameOracle;
390-
private _jobs: Promise<any>[] = [];
391-
392-
constructor(
393-
private readonly _logFn: (topic: string, message: string) => void,
394-
private readonly _onError: (err: any) => void,
395-
configFilePath: string,
396-
private readonly _cmdLine: ts.ParsedCommandLine
397-
) {
398-
_logFn('Transpile', `will use SWC to transpile source files`);
399-
this._outputFileNames = new OutputFileNameOracle(_cmdLine, configFilePath);
400-
}
401-
402-
async join(): Promise<void> {
403-
const jobs = this._jobs.slice();
404-
this._jobs.length = 0;
405-
await Promise.allSettled(jobs);
406-
}
407-
408-
transpile(file: Vinyl): void {
409-
if (this._cmdLine.options.noEmit) {
410-
// not doing ANYTHING here
411-
return;
412-
}
413-
414-
const tsSrc = String(file.contents);
415-
const t1 = Date.now();
416-
417-
let options: swc.Options = SwcTranspiler._swcrcEsm;
418-
if (this._cmdLine.options.module === ts.ModuleKind.AMD) {
419-
const isAmd = /\n(import|export)/m.test(tsSrc);
420-
if (isAmd) {
421-
options = SwcTranspiler._swcrcAmd;
422-
}
423-
} else if (this._cmdLine.options.module === ts.ModuleKind.CommonJS || this._cmdLine.options.module === ts.ModuleKind.Node16) {
424-
options = SwcTranspiler._swcrcCommonJS;
425-
}
426-
427-
this._jobs.push(swc.transform(tsSrc, options).then(output => {
428-
429-
// check if output of a DTS-files isn't just "empty" and iff so
430-
// skip this file
431-
if (file.path.endsWith('.d.ts') && _isDefaultEmpty(output.code)) {
432-
return;
433-
}
434-
435-
const outBase = this._cmdLine.options.outDir ?? file.base;
436-
const outPath = this._outputFileNames.getOutputFileName(file.path);
437-
438-
this.onOutfile!(new Vinyl({
439-
path: outPath,
440-
base: outBase,
441-
contents: Buffer.from(output.code),
442-
}));
443-
444-
this._logFn('Transpile', `swc took ${Date.now() - t1}ms for ${file.path}`);
445-
446-
}).catch(err => {
447-
this._onError(err);
448-
}));
449-
}
450-
451-
// --- .swcrc
452-
453-
454-
private static readonly _swcrcAmd: swc.Options = {
455-
exclude: '\.js$',
456-
jsc: {
457-
parser: {
458-
syntax: 'typescript',
459-
tsx: false,
460-
decorators: true
461-
},
462-
target: 'es2022',
463-
loose: false,
464-
minify: {
465-
compress: false,
466-
mangle: false
467-
},
468-
transform: {
469-
useDefineForClassFields: false,
470-
},
471-
},
472-
module: {
473-
type: 'amd',
474-
noInterop: false
475-
},
476-
minify: false,
477-
};
478-
479-
private static readonly _swcrcCommonJS: swc.Options = {
480-
...this._swcrcAmd,
481-
module: {
482-
type: 'commonjs',
483-
importInterop: 'swc'
484-
}
485-
};
486-
487-
private static readonly _swcrcEsm: swc.Options = {
488-
...this._swcrcAmd,
489-
module: {
490-
type: 'es6'
491-
}
492-
};
493-
}

0 commit comments

Comments
 (0)