@workleap/swc-configs 1.0.0 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +13 -1
- package/README.md +10 -386
- package/dist/applyTransformers.d.ts +9 -0
- package/dist/applyTransformers.js +8 -0
- package/dist/applyTransformers.mjs +1 -0
- package/dist/build.d.ts +6 -30
- package/dist/build.js +51 -62
- package/dist/build.mjs +2 -3
- package/dist/chunk-3UBBOKDF.mjs +6 -0
- package/dist/chunk-5BJAOXJX.mjs +56 -0
- package/dist/chunk-MYINGMHM.mjs +45 -0
- package/dist/chunk-YG2X6TFX.mjs +55 -0
- package/dist/dev.d.ts +6 -27
- package/dist/dev.js +50 -63
- package/dist/dev.mjs +2 -3
- package/dist/index.d.ts +5 -5
- package/dist/index.js +135 -146
- package/dist/index.mjs +4 -5
- package/dist/jest.d.ts +5 -19
- package/dist/jest.js +40 -61
- package/dist/jest.mjs +2 -3
- package/package.json +7 -6
- package/dist/chunk-4LXCYXR5.mjs +0 -18
- package/dist/chunk-4XYHUSOR.mjs +0 -51
- package/dist/chunk-5HQ4FWBC.mjs +0 -49
- package/dist/chunk-JW562DWU.mjs +0 -50
- package/dist/chunk-XCGQZSNA.mjs +0 -6
- package/dist/cloneObjectExceptFunctions.d.ts +0 -3
- package/dist/cloneObjectExceptFunctions.js +0 -8
- package/dist/cloneObjectExceptFunctions.mjs +0 -1
- package/dist/resolveOverrides.d.ts +0 -7
- package/dist/resolveOverrides.js +0 -20
- package/dist/resolveOverrides.mjs +0 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { applyTransformers } from './chunk-3UBBOKDF.mjs';
|
|
2
|
+
|
|
3
|
+
// src/jest.ts
|
|
4
|
+
function defineJestConfig(options = {}) {
|
|
5
|
+
const {
|
|
6
|
+
react = false,
|
|
7
|
+
parser = "typescript",
|
|
8
|
+
transformers = []
|
|
9
|
+
} = options;
|
|
10
|
+
const config = {
|
|
11
|
+
jsc: {
|
|
12
|
+
parser: parser === "ecmascript" ? {
|
|
13
|
+
syntax: "ecmascript",
|
|
14
|
+
jsx: react
|
|
15
|
+
} : {
|
|
16
|
+
syntax: "typescript",
|
|
17
|
+
tsx: react
|
|
18
|
+
},
|
|
19
|
+
// The output environment that the code will be compiled for.
|
|
20
|
+
target: "esnext",
|
|
21
|
+
transform: react ? {
|
|
22
|
+
react: {
|
|
23
|
+
// Use "react/jsx-runtime".
|
|
24
|
+
runtime: "automatic",
|
|
25
|
+
// Use the native "Object.assign()" instead of "_extends".
|
|
26
|
+
useBuiltins: true
|
|
27
|
+
}
|
|
28
|
+
} : void 0
|
|
29
|
+
},
|
|
30
|
+
module: {
|
|
31
|
+
// The output module resolution system that the code will be compiled for.
|
|
32
|
+
type: "es6",
|
|
33
|
+
// Prevent SWC from exporting the `__esModule` property.
|
|
34
|
+
strict: true,
|
|
35
|
+
// Preserve dynamic imports.
|
|
36
|
+
ignoreDynamic: true
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
const transformedConfig = applyTransformers(config, transformers, {
|
|
40
|
+
environment: "jest"
|
|
41
|
+
});
|
|
42
|
+
return transformedConfig;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export { defineJestConfig };
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { applyTransformers } from './chunk-3UBBOKDF.mjs';
|
|
2
|
+
|
|
3
|
+
// src/dev.ts
|
|
4
|
+
function defineDevConfig(options) {
|
|
5
|
+
const {
|
|
6
|
+
browsers,
|
|
7
|
+
fastRefresh = false,
|
|
8
|
+
parser = "typescript",
|
|
9
|
+
transformers = []
|
|
10
|
+
} = options;
|
|
11
|
+
const config = {
|
|
12
|
+
jsc: {
|
|
13
|
+
parser: parser === "ecmascript" ? {
|
|
14
|
+
syntax: "ecmascript",
|
|
15
|
+
jsx: true
|
|
16
|
+
} : {
|
|
17
|
+
syntax: "typescript",
|
|
18
|
+
tsx: true
|
|
19
|
+
},
|
|
20
|
+
// The output environment that the code will be compiled for.
|
|
21
|
+
target: "esnext",
|
|
22
|
+
transform: {
|
|
23
|
+
react: {
|
|
24
|
+
// Use "react/jsx-runtime".
|
|
25
|
+
runtime: "automatic",
|
|
26
|
+
// Use the native "Object.assign()" instead of "_extends".
|
|
27
|
+
useBuiltins: true,
|
|
28
|
+
// Enable React experimental "fast-refresh" feature.
|
|
29
|
+
// Also need to install @pmmmwh/react-refresh-webpack-plugin.
|
|
30
|
+
refresh: fastRefresh
|
|
31
|
+
}
|
|
32
|
+
},
|
|
33
|
+
// Import shims from an external module rather than inlining them in bundle files to greatly reduce the bundles size.
|
|
34
|
+
// Requires to add "@swc/helpers" as a project dependency.
|
|
35
|
+
externalHelpers: true
|
|
36
|
+
},
|
|
37
|
+
module: {
|
|
38
|
+
// The output module resolution system that the code will be compiled for.
|
|
39
|
+
type: "es6",
|
|
40
|
+
// Prevent SWC from exporting the `__esModule` property.
|
|
41
|
+
strict: true,
|
|
42
|
+
// Preserve dynamic imports.
|
|
43
|
+
ignoreDynamic: true
|
|
44
|
+
},
|
|
45
|
+
env: {
|
|
46
|
+
targets: browsers
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const transformedConfig = applyTransformers(config, transformers, {
|
|
50
|
+
environment: "dev"
|
|
51
|
+
});
|
|
52
|
+
return transformedConfig;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export { defineDevConfig };
|
package/dist/dev.d.ts
CHANGED
|
@@ -1,33 +1,12 @@
|
|
|
1
1
|
import { Config } from '@swc/core';
|
|
2
|
-
import {
|
|
2
|
+
import { SwcConfigTransformer } from './applyTransformers.js';
|
|
3
3
|
|
|
4
|
-
declare const DefaultDevConfig: {
|
|
5
|
-
jsc: {
|
|
6
|
-
parser: {
|
|
7
|
-
syntax: "typescript";
|
|
8
|
-
tsx: true;
|
|
9
|
-
};
|
|
10
|
-
target: "es2022";
|
|
11
|
-
transform: {
|
|
12
|
-
react: {
|
|
13
|
-
runtime: "automatic";
|
|
14
|
-
useBuiltins: true;
|
|
15
|
-
refresh: false;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
|
-
externalHelpers: true;
|
|
19
|
-
};
|
|
20
|
-
module: {
|
|
21
|
-
type: "es6";
|
|
22
|
-
strict: true;
|
|
23
|
-
ignoreDynamic: true;
|
|
24
|
-
};
|
|
25
|
-
};
|
|
26
4
|
interface DefineDevConfigOptions {
|
|
5
|
+
browsers: any;
|
|
27
6
|
fastRefresh?: boolean;
|
|
28
|
-
parser?: "ecmascript";
|
|
29
|
-
|
|
7
|
+
parser?: "ecmascript" | "typescript";
|
|
8
|
+
transformers?: SwcConfigTransformer[];
|
|
30
9
|
}
|
|
31
|
-
declare function defineDevConfig(
|
|
10
|
+
declare function defineDevConfig(options: DefineDevConfigOptions): Config;
|
|
32
11
|
|
|
33
|
-
export {
|
|
12
|
+
export { DefineDevConfigOptions, defineDevConfig };
|
package/dist/dev.js
CHANGED
|
@@ -1,73 +1,60 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
// src/
|
|
4
|
-
function
|
|
5
|
-
return
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
// src/resolveOverrides.ts
|
|
9
|
-
function resolveOverrides(config, configOverride) {
|
|
10
|
-
if (typeof configOverride === "function") {
|
|
11
|
-
return {
|
|
12
|
-
...config,
|
|
13
|
-
...configOverride(config)
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
if (configOverride) {
|
|
17
|
-
return {
|
|
18
|
-
...config,
|
|
19
|
-
...configOverride
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
return config;
|
|
3
|
+
// src/applyTransformers.ts
|
|
4
|
+
function applyTransformers(config, transformers, context) {
|
|
5
|
+
return transformers.reduce((acc, transformer) => transformer(acc, context), config);
|
|
23
6
|
}
|
|
24
7
|
|
|
25
8
|
// src/dev.ts
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
9
|
+
function defineDevConfig(options) {
|
|
10
|
+
const {
|
|
11
|
+
browsers,
|
|
12
|
+
fastRefresh = false,
|
|
13
|
+
parser = "typescript",
|
|
14
|
+
transformers = []
|
|
15
|
+
} = options;
|
|
16
|
+
const config = {
|
|
17
|
+
jsc: {
|
|
18
|
+
parser: parser === "ecmascript" ? {
|
|
19
|
+
syntax: "ecmascript",
|
|
20
|
+
jsx: true
|
|
21
|
+
} : {
|
|
22
|
+
syntax: "typescript",
|
|
23
|
+
tsx: true
|
|
24
|
+
},
|
|
25
|
+
// The output environment that the code will be compiled for.
|
|
26
|
+
target: "esnext",
|
|
27
|
+
transform: {
|
|
28
|
+
react: {
|
|
29
|
+
// Use "react/jsx-runtime".
|
|
30
|
+
runtime: "automatic",
|
|
31
|
+
// Use the native "Object.assign()" instead of "_extends".
|
|
32
|
+
useBuiltins: true,
|
|
33
|
+
// Enable React experimental "fast-refresh" feature.
|
|
34
|
+
// Also need to install @pmmmwh/react-refresh-webpack-plugin.
|
|
35
|
+
refresh: fastRefresh
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
// Import shims from an external module rather than inlining them in bundle files to greatly reduce the bundles size.
|
|
39
|
+
// Requires to add "@swc/helpers" as a project dependency.
|
|
40
|
+
externalHelpers: true
|
|
31
41
|
},
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
useBuiltins: true,
|
|
40
|
-
// Enable React experimental "fast-refresh" feature.
|
|
41
|
-
// Also need to install @pmmmwh/react-refresh-webpack-plugin.
|
|
42
|
-
refresh: false
|
|
43
|
-
}
|
|
42
|
+
module: {
|
|
43
|
+
// The output module resolution system that the code will be compiled for.
|
|
44
|
+
type: "es6",
|
|
45
|
+
// Prevent SWC from exporting the `__esModule` property.
|
|
46
|
+
strict: true,
|
|
47
|
+
// Preserve dynamic imports.
|
|
48
|
+
ignoreDynamic: true
|
|
44
49
|
},
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
strict: true,
|
|
54
|
-
// Preserve dynamic imports.
|
|
55
|
-
ignoreDynamic: true
|
|
56
|
-
}
|
|
57
|
-
};
|
|
58
|
-
function defineDevConfig({ fastRefresh, parser, configOverride } = {}) {
|
|
59
|
-
const config = cloneObjectExceptFunctions(DefaultDevConfig);
|
|
60
|
-
if (fastRefresh) {
|
|
61
|
-
config.jsc.transform.react.refresh = true;
|
|
62
|
-
}
|
|
63
|
-
if (parser === "ecmascript") {
|
|
64
|
-
config.jsc.parser = {
|
|
65
|
-
syntax: "ecmascript",
|
|
66
|
-
jsx: true
|
|
67
|
-
};
|
|
68
|
-
}
|
|
69
|
-
return resolveOverrides(config, configOverride);
|
|
50
|
+
env: {
|
|
51
|
+
targets: browsers
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const transformedConfig = applyTransformers(config, transformers, {
|
|
55
|
+
environment: "dev"
|
|
56
|
+
});
|
|
57
|
+
return transformedConfig;
|
|
70
58
|
}
|
|
71
59
|
|
|
72
|
-
exports.DefaultDevConfig = DefaultDevConfig;
|
|
73
60
|
exports.defineDevConfig = defineDevConfig;
|
package/dist/dev.mjs
CHANGED
|
@@ -1,3 +1,2 @@
|
|
|
1
|
-
export {
|
|
2
|
-
import './chunk-
|
|
3
|
-
import './chunk-4LXCYXR5.mjs';
|
|
1
|
+
export { defineDevConfig } from './chunk-YG2X6TFX.mjs';
|
|
2
|
+
import './chunk-3UBBOKDF.mjs';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
export {
|
|
5
|
-
|
|
1
|
+
export { Config as SwcConfig } from '@swc/core';
|
|
2
|
+
export { SwcConfigTransformer, SwcConfigTransformerContext } from './applyTransformers.js';
|
|
3
|
+
export { DefineBuildConfigOptions, defineBuildConfig } from './build.js';
|
|
4
|
+
export { DefineDevConfigOptions, defineDevConfig } from './dev.js';
|
|
5
|
+
export { DefineJestConfigOptions, defineJestConfig } from './jest.js';
|
package/dist/index.js
CHANGED
|
@@ -1,168 +1,157 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
// src/
|
|
4
|
-
function
|
|
5
|
-
return
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
// src/resolveOverrides.ts
|
|
9
|
-
function resolveOverrides(config, configOverride) {
|
|
10
|
-
if (typeof configOverride === "function") {
|
|
11
|
-
return {
|
|
12
|
-
...config,
|
|
13
|
-
...configOverride(config)
|
|
14
|
-
};
|
|
15
|
-
}
|
|
16
|
-
if (configOverride) {
|
|
17
|
-
return {
|
|
18
|
-
...config,
|
|
19
|
-
...configOverride
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
return config;
|
|
3
|
+
// src/applyTransformers.ts
|
|
4
|
+
function applyTransformers(config, transformers, context) {
|
|
5
|
+
return transformers.reduce((acc, transformer) => transformer(acc, context), config);
|
|
23
6
|
}
|
|
24
7
|
|
|
25
8
|
// src/build.ts
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
9
|
+
function defineBuildConfig(options) {
|
|
10
|
+
const {
|
|
11
|
+
browsers,
|
|
12
|
+
parser = "typescript",
|
|
13
|
+
transformers = []
|
|
14
|
+
} = options;
|
|
15
|
+
const config = {
|
|
16
|
+
jsc: {
|
|
17
|
+
parser: parser === "ecmascript" ? {
|
|
18
|
+
syntax: "ecmascript",
|
|
19
|
+
jsx: true
|
|
20
|
+
} : {
|
|
21
|
+
syntax: "typescript",
|
|
22
|
+
tsx: true
|
|
23
|
+
},
|
|
24
|
+
// The output environment that the code will be compiled for.
|
|
25
|
+
target: "esnext",
|
|
26
|
+
// View https://swc.rs/docs/configuration/minification for options.
|
|
27
|
+
minify: {
|
|
28
|
+
compress: true,
|
|
29
|
+
mangle: true
|
|
30
|
+
},
|
|
31
|
+
transform: {
|
|
32
|
+
react: {
|
|
33
|
+
// Use "react/jsx-runtime".
|
|
34
|
+
runtime: "automatic",
|
|
35
|
+
// Use the native "Object.assign()" instead of "_extends".
|
|
36
|
+
useBuiltins: true
|
|
37
|
+
}
|
|
38
|
+
},
|
|
39
|
+
// Import shims from an external module rather than inlining them in bundle files to greatly reduce the bundles size.
|
|
40
|
+
// Requires to add "@swc/helpers" as a project dependency.
|
|
41
|
+
externalHelpers: true
|
|
38
42
|
},
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
43
|
+
module: {
|
|
44
|
+
// The output module resolution system that the code will be compiled for.
|
|
45
|
+
type: "es6",
|
|
46
|
+
// Prevent SWC from exporting the `__esModule` property.
|
|
47
|
+
strict: true,
|
|
48
|
+
// Preserve dynamic imports.
|
|
49
|
+
ignoreDynamic: true
|
|
46
50
|
},
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
strict: true,
|
|
56
|
-
// Preserve dynamic imports.
|
|
57
|
-
ignoreDynamic: true
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
function defineBuildConfig({ parser, configOverride } = {}) {
|
|
61
|
-
const config = cloneObjectExceptFunctions(DefaultBuildConfig);
|
|
62
|
-
if (parser === "ecmascript") {
|
|
63
|
-
config.jsc.parser = {
|
|
64
|
-
syntax: "ecmascript",
|
|
65
|
-
jsx: true
|
|
66
|
-
};
|
|
67
|
-
}
|
|
68
|
-
return resolveOverrides(config, configOverride);
|
|
51
|
+
env: {
|
|
52
|
+
targets: browsers
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
const transformedConfig = applyTransformers(config, transformers, {
|
|
56
|
+
environment: "build"
|
|
57
|
+
});
|
|
58
|
+
return transformedConfig;
|
|
69
59
|
}
|
|
70
60
|
|
|
71
61
|
// src/dev.ts
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
62
|
+
function defineDevConfig(options) {
|
|
63
|
+
const {
|
|
64
|
+
browsers,
|
|
65
|
+
fastRefresh = false,
|
|
66
|
+
parser = "typescript",
|
|
67
|
+
transformers = []
|
|
68
|
+
} = options;
|
|
69
|
+
const config = {
|
|
70
|
+
jsc: {
|
|
71
|
+
parser: parser === "ecmascript" ? {
|
|
72
|
+
syntax: "ecmascript",
|
|
73
|
+
jsx: true
|
|
74
|
+
} : {
|
|
75
|
+
syntax: "typescript",
|
|
76
|
+
tsx: true
|
|
77
|
+
},
|
|
78
|
+
// The output environment that the code will be compiled for.
|
|
79
|
+
target: "esnext",
|
|
80
|
+
transform: {
|
|
81
|
+
react: {
|
|
82
|
+
// Use "react/jsx-runtime".
|
|
83
|
+
runtime: "automatic",
|
|
84
|
+
// Use the native "Object.assign()" instead of "_extends".
|
|
85
|
+
useBuiltins: true,
|
|
86
|
+
// Enable React experimental "fast-refresh" feature.
|
|
87
|
+
// Also need to install @pmmmwh/react-refresh-webpack-plugin.
|
|
88
|
+
refresh: fastRefresh
|
|
89
|
+
}
|
|
90
|
+
},
|
|
91
|
+
// Import shims from an external module rather than inlining them in bundle files to greatly reduce the bundles size.
|
|
92
|
+
// Requires to add "@swc/helpers" as a project dependency.
|
|
93
|
+
externalHelpers: true
|
|
77
94
|
},
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
useBuiltins: true,
|
|
86
|
-
// Enable React experimental "fast-refresh" feature.
|
|
87
|
-
// Also need to install @pmmmwh/react-refresh-webpack-plugin.
|
|
88
|
-
refresh: false
|
|
89
|
-
}
|
|
95
|
+
module: {
|
|
96
|
+
// The output module resolution system that the code will be compiled for.
|
|
97
|
+
type: "es6",
|
|
98
|
+
// Prevent SWC from exporting the `__esModule` property.
|
|
99
|
+
strict: true,
|
|
100
|
+
// Preserve dynamic imports.
|
|
101
|
+
ignoreDynamic: true
|
|
90
102
|
},
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
strict: true,
|
|
100
|
-
// Preserve dynamic imports.
|
|
101
|
-
ignoreDynamic: true
|
|
102
|
-
}
|
|
103
|
-
};
|
|
104
|
-
function defineDevConfig({ fastRefresh, parser, configOverride } = {}) {
|
|
105
|
-
const config = cloneObjectExceptFunctions(DefaultDevConfig);
|
|
106
|
-
if (fastRefresh) {
|
|
107
|
-
config.jsc.transform.react.refresh = true;
|
|
108
|
-
}
|
|
109
|
-
if (parser === "ecmascript") {
|
|
110
|
-
config.jsc.parser = {
|
|
111
|
-
syntax: "ecmascript",
|
|
112
|
-
jsx: true
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
return resolveOverrides(config, configOverride);
|
|
103
|
+
env: {
|
|
104
|
+
targets: browsers
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
const transformedConfig = applyTransformers(config, transformers, {
|
|
108
|
+
environment: "dev"
|
|
109
|
+
});
|
|
110
|
+
return transformedConfig;
|
|
116
111
|
}
|
|
117
112
|
|
|
118
113
|
// src/jest.ts
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
114
|
+
function defineJestConfig(options = {}) {
|
|
115
|
+
const {
|
|
116
|
+
react = false,
|
|
117
|
+
parser = "typescript",
|
|
118
|
+
transformers = []
|
|
119
|
+
} = options;
|
|
120
|
+
const config = {
|
|
121
|
+
jsc: {
|
|
122
|
+
parser: parser === "ecmascript" ? {
|
|
123
|
+
syntax: "ecmascript",
|
|
124
|
+
jsx: react
|
|
125
|
+
} : {
|
|
126
|
+
syntax: "typescript",
|
|
127
|
+
tsx: react
|
|
128
|
+
},
|
|
129
|
+
// The output environment that the code will be compiled for.
|
|
130
|
+
target: "esnext",
|
|
131
|
+
transform: react ? {
|
|
132
|
+
react: {
|
|
133
|
+
// Use "react/jsx-runtime".
|
|
134
|
+
runtime: "automatic",
|
|
135
|
+
// Use the native "Object.assign()" instead of "_extends".
|
|
136
|
+
useBuiltins: true
|
|
137
|
+
}
|
|
138
|
+
} : void 0
|
|
123
139
|
},
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
// The output module resolution system that the code will be compiled for.
|
|
132
|
-
type: "es6",
|
|
133
|
-
// Prevent SWC from exporting the `__esModule` property.
|
|
134
|
-
strict: true,
|
|
135
|
-
// Preserve dynamic imports.
|
|
136
|
-
ignoreDynamic: true
|
|
137
|
-
}
|
|
138
|
-
};
|
|
139
|
-
function defineJestConfig({ react, parser, configOverride } = {}) {
|
|
140
|
-
const config = cloneObjectExceptFunctions(DefaultJestConfig);
|
|
141
|
-
if (react) {
|
|
142
|
-
config.jsc.transform = {
|
|
143
|
-
react: {
|
|
144
|
-
// Use "react/jsx-runtime".
|
|
145
|
-
runtime: "automatic",
|
|
146
|
-
// Use the native "Object.assign()" instead of "_extends".
|
|
147
|
-
useBuiltins: true
|
|
148
|
-
}
|
|
149
|
-
};
|
|
150
|
-
}
|
|
151
|
-
if (parser === "ecmascript") {
|
|
152
|
-
const parserConfig = { syntax: "ecmascript" };
|
|
153
|
-
if (react) {
|
|
154
|
-
parserConfig.jsx = true;
|
|
140
|
+
module: {
|
|
141
|
+
// The output module resolution system that the code will be compiled for.
|
|
142
|
+
type: "es6",
|
|
143
|
+
// Prevent SWC from exporting the `__esModule` property.
|
|
144
|
+
strict: true,
|
|
145
|
+
// Preserve dynamic imports.
|
|
146
|
+
ignoreDynamic: true
|
|
155
147
|
}
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
}
|
|
160
|
-
return
|
|
148
|
+
};
|
|
149
|
+
const transformedConfig = applyTransformers(config, transformers, {
|
|
150
|
+
environment: "jest"
|
|
151
|
+
});
|
|
152
|
+
return transformedConfig;
|
|
161
153
|
}
|
|
162
154
|
|
|
163
|
-
exports.DefaultBuildConfig = DefaultBuildConfig;
|
|
164
|
-
exports.DefaultDevConfig = DefaultDevConfig;
|
|
165
|
-
exports.DefaultJestConfig = DefaultJestConfig;
|
|
166
155
|
exports.defineBuildConfig = defineBuildConfig;
|
|
167
156
|
exports.defineDevConfig = defineDevConfig;
|
|
168
157
|
exports.defineJestConfig = defineJestConfig;
|
package/dist/index.mjs
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
export {
|
|
2
|
-
export {
|
|
3
|
-
export {
|
|
4
|
-
import './chunk-
|
|
5
|
-
import './chunk-4LXCYXR5.mjs';
|
|
1
|
+
export { defineBuildConfig } from './chunk-5BJAOXJX.mjs';
|
|
2
|
+
export { defineDevConfig } from './chunk-YG2X6TFX.mjs';
|
|
3
|
+
export { defineJestConfig } from './chunk-MYINGMHM.mjs';
|
|
4
|
+
import './chunk-3UBBOKDF.mjs';
|
package/dist/jest.d.ts
CHANGED
|
@@ -1,25 +1,11 @@
|
|
|
1
1
|
import { Config } from '@swc/core';
|
|
2
|
-
import {
|
|
2
|
+
import { SwcConfigTransformer } from './applyTransformers.js';
|
|
3
3
|
|
|
4
|
-
declare const DefaultJestConfig: {
|
|
5
|
-
jsc: {
|
|
6
|
-
parser: {
|
|
7
|
-
syntax: "typescript";
|
|
8
|
-
};
|
|
9
|
-
target: "es2022";
|
|
10
|
-
externalHelpers: true;
|
|
11
|
-
};
|
|
12
|
-
module: {
|
|
13
|
-
type: "es6";
|
|
14
|
-
strict: true;
|
|
15
|
-
ignoreDynamic: true;
|
|
16
|
-
};
|
|
17
|
-
};
|
|
18
4
|
interface DefineJestConfigOptions {
|
|
19
5
|
react?: boolean;
|
|
20
|
-
parser?: "ecmascript";
|
|
21
|
-
|
|
6
|
+
parser?: "ecmascript" | "typescript";
|
|
7
|
+
transformers?: SwcConfigTransformer[];
|
|
22
8
|
}
|
|
23
|
-
declare function defineJestConfig(
|
|
9
|
+
declare function defineJestConfig(options?: DefineJestConfigOptions): Config;
|
|
24
10
|
|
|
25
|
-
export {
|
|
11
|
+
export { DefineJestConfigOptions, defineJestConfig };
|