Skip to content

Commit 505a333

Browse files
authored
Merge pull request #303 from atls/feat/swc-loader
2 parents 7b69992 + 9517b15 commit 505a333

File tree

5 files changed

+353
-11
lines changed

5 files changed

+353
-11
lines changed

.pnp.cjs

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

code/code-service/package.json

+2
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,15 @@
1616
"@atls/config-typescript": "workspace:*",
1717
"@atls/webpack-proto-imports-loader": "workspace:*",
1818
"@atls/webpack-start-server-plugin": "workspace:*",
19+
"@swc/core": "1.4.11",
1920
"@yarnpkg/cli": "4.1.0",
2021
"@yarnpkg/core": "4.0.3",
2122
"css-loader": "6.8.1",
2223
"fast-glob": "3.2.11",
2324
"find-up": "5.0.0",
2425
"string-replace-loader": "3.1.0",
2526
"style-loader": "3.3.3",
27+
"swc-loader": "0.2.6",
2628
"ts-loader": "9.5.1",
2729
"typescript": "5.2.2",
2830
"webpack": "5.89.0",

code/code-service/src/webpack.config.ts

+30-8
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
/* eslint-disable @typescript-eslint/no-empty-function */
12
import { readFile } from 'node:fs/promises'
23
import { join } from 'node:path'
34

@@ -7,9 +8,6 @@ import { Configuration } from 'webpack'
78
import { WebpackPluginInstance } from 'webpack'
89
import { HotModuleReplacementPlugin } from 'webpack'
910

10-
/* eslint-disable @typescript-eslint/no-empty-function */
11-
import { tsConfig } from '@atls/config-typescript'
12-
1311
import { FORCE_UNPLUGGED_PACKAGES } from './webpack.externals'
1412
import { UNUSED_EXTERNALS } from './webpack.externals'
1513
import { ModuleTypes } from './webpack.interfaces'
@@ -125,13 +123,37 @@ export class WebpackConfig {
125123
{
126124
test: /.tsx?$/,
127125
use: {
128-
loader: require.resolve('ts-loader'),
126+
loader: require.resolve('swc-core'),
129127
options: {
130-
transpileOnly: true,
131-
experimentalWatchApi: true,
132-
onlyCompileBundledFiles: true,
133-
compilerOptions: { ...tsConfig.compilerOptions, sourceMap: true },
128+
minify: true,
129+
jsc: {
130+
parser: {
131+
syntax: 'typescript',
132+
jsx: true,
133+
dynamicImport: true,
134+
privateMethod: true,
135+
functionBind: true,
136+
exportDefaultFrom: true,
137+
exportNamespaceFrom: true,
138+
decorators: true,
139+
decoratorsBeforeExport: true,
140+
topLevelAwait: true,
141+
importMeta: true,
142+
},
143+
transform: {
144+
legacyDecorator: true,
145+
decoratorMetadata: true,
146+
},
147+
},
134148
},
149+
// TODO: remove once confirmed swc is full replacement
150+
// loader: require.resolve('ts-loader'),
151+
// options: {
152+
// transpileOnly: true,
153+
// experimentalWatchApi: true,
154+
// onlyCompileBundledFiles: true,
155+
// compilerOptions: { ...tsConfig.compilerOptions, sourceMap: true },
156+
// },
135157
},
136158
},
137159
{ test: /\.proto$/, use: require.resolve('@atls/webpack-proto-imports-loader') },

package.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@
1414
"yarn/**/*",
1515
"cli/*"
1616
],
17+
"scripts": {
18+
"prepare": "husky"
19+
},
1720
"resolutions": {
1821
"@types/react": "16.14.54",
1922
"globby": "11",
@@ -53,8 +56,5 @@
5356
"type": "libraries",
5457
"migration": "1645001973970"
5558
}
56-
},
57-
"scripts": {
58-
"prepare": "husky"
5959
}
6060
}

0 commit comments

Comments
 (0)