Skip to content

There can be more than Notion and Miro. AFFiNE(pronounced [ə‘fain]) is a next-gen knowledge base that brings planning, sorting and creating all together. Privacy first, open-source, customizable and ready to use.

build: fine tune swc config (#8384)

pengx17d0050a268a15
diff --git a/tools/cli/src/webpack/config.ts b/tools/cli/src/webpack/config.ts
index 375dae1cce..f0cb54c291 100644
--- a/tools/cli/src/webpack/config.ts
+++ b/tools/cli/src/webpack/config.ts
@@ -251,7 +251,33 @@ export const createConfiguration: (
{
oneOf: [
{
- test: /\.tsx?$/,
+ test: /\.ts$/,
+ exclude: /node_modules/,
+ loader: 'swc-loader',
+ options: {
+ // https://swc.rs/docs/configuring-swc/
+ jsc: {
+ preserveAllComments: true,
+ parser: {
+ syntax: 'typescript',
+ dynamicImport: true,
+ topLevelAwait: false,
+ tsx: false,
+ decorators: true,
+ },
+ target: 'es2022',
+ externalHelpers: false,
+ transform: {
+ useDefineForClassFields: false,
+ decoratorVersion: '2022-03',
+ },
+ },
+ sourceMaps: true,
+ inlineSourcesContent: true,
+ },
+ },
+ {
+ test: /\.tsx$/,
exclude: /node_modules/,
loader: 'swc-loader',
options: {
@@ -333,7 +359,11 @@ export const createConfiguration: (
plugins: compact([
IN_CI ? null : new webpack.ProgressPlugin({ percentBy: 'entries' }),
buildFlags.mode === 'development'
- ? new ReactRefreshWebpackPlugin({ overlay: false, esModule: true })
+ ? new ReactRefreshWebpackPlugin({
+ overlay: false,
+ esModule: true,
+ include: /\.tsx$/,
+ })
: // todo: support multiple entry points
new MiniCssExtractPlugin({
filename: `[name].[contenthash:8].css`,