@modern-js/plugin-swc 2.27.0 → 2.29.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 +23 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +45 -23
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @modern-js/core
|
|
2
2
|
|
|
3
|
+
## 2.29.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [e6b5355]
|
|
8
|
+
- Updated dependencies [93db783]
|
|
9
|
+
- Updated dependencies [cba7675]
|
|
10
|
+
- Updated dependencies [0f680ec]
|
|
11
|
+
- Updated dependencies [99052ea]
|
|
12
|
+
- Updated dependencies [1d71d2e]
|
|
13
|
+
- @modern-js/utils@2.29.0
|
|
14
|
+
- @modern-js/builder-plugin-swc@2.29.0
|
|
15
|
+
|
|
16
|
+
## 2.28.0
|
|
17
|
+
|
|
18
|
+
### Patch Changes
|
|
19
|
+
|
|
20
|
+
- Updated dependencies [b7b4d84]
|
|
21
|
+
- Updated dependencies [ac0e99c]
|
|
22
|
+
- Updated dependencies [00b58a7]
|
|
23
|
+
- @modern-js/builder-plugin-swc@2.28.0
|
|
24
|
+
- @modern-js/utils@2.28.0
|
|
25
|
+
|
|
3
26
|
## 2.27.0
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
import type { AppTools, CliPlugin } from '@modern-js/app-tools';
|
|
2
2
|
import { PluginSwcOptions } from '@modern-js/builder-plugin-swc';
|
|
3
|
+
import type { ToolsUserConfig } from '@modern-js/app-tools/src/types/config/tools';
|
|
3
4
|
export declare function factory(name: string, modifySwcOptions: (options: PluginSwcOptions) => PluginSwcOptions): () => CliPlugin<AppTools>;
|
|
5
|
+
export declare function applyBuilderSwcConfig(swc: PluginSwcOptions, esbuild: ToolsUserConfig['esbuild'] | undefined, isSSR: boolean): PluginSwcOptions;
|
|
4
6
|
export declare const swcPlugin: () => CliPlugin<AppTools>;
|
|
5
7
|
export default swcPlugin;
|
package/dist/index.js
CHANGED
|
@@ -13,6 +13,9 @@ _export(exports, {
|
|
|
13
13
|
factory: function() {
|
|
14
14
|
return factory;
|
|
15
15
|
},
|
|
16
|
+
applyBuilderSwcConfig: function() {
|
|
17
|
+
return applyBuilderSwcConfig;
|
|
18
|
+
},
|
|
16
19
|
swcPlugin: function() {
|
|
17
20
|
return swcPlugin;
|
|
18
21
|
},
|
|
@@ -47,36 +50,55 @@ function factory(name, modifySwcOptions) {
|
|
|
47
50
|
const config = api.useResolvedConfigContext();
|
|
48
51
|
const { esbuild, swc = {} } = config.tools;
|
|
49
52
|
const swcOptions = modifySwcOptions(swc);
|
|
50
|
-
|
|
51
|
-
swcOptions.extensions = {
|
|
52
|
-
...swcOptions.extensions || {},
|
|
53
|
-
loadableComponents: true
|
|
54
|
-
};
|
|
55
|
-
}
|
|
53
|
+
const finalConfig = applyBuilderSwcConfig(swcOptions, esbuild, (0, _utils.isSSR)(config));
|
|
56
54
|
context.builder.addPlugins([
|
|
57
|
-
(0, _builderpluginswc.builderPluginSwc)(
|
|
55
|
+
(0, _builderpluginswc.builderPluginSwc)(finalConfig)
|
|
58
56
|
]);
|
|
59
|
-
if (esbuild) {
|
|
60
|
-
if (swc.jsMinify !== false && esbuild.minimize !== false) {
|
|
61
|
-
_logger.logger.warn("You have enabled both esbuild minimizer and SWC minimizer, which will cause conflicts. Please remove `tools.esbuild` config and only use SWC to minimize your code.");
|
|
62
|
-
}
|
|
63
|
-
if (esbuild.loader !== false) {
|
|
64
|
-
_logger.logger.warn("You have enabled both esbuild loader and SWC loader, which will cause conflicts. Please remove `tools.esbuild` config and only use SWC to transform your code.");
|
|
65
|
-
}
|
|
66
|
-
}
|
|
67
57
|
}
|
|
68
58
|
})
|
|
69
59
|
});
|
|
70
60
|
}
|
|
61
|
+
function applyBuilderSwcConfig(swc, esbuild, isSSR) {
|
|
62
|
+
if (isSSR) {
|
|
63
|
+
swc = applyConfig(swc, (config) => {
|
|
64
|
+
config.extensions = {
|
|
65
|
+
...config.extensions || {},
|
|
66
|
+
loadableComponents: true
|
|
67
|
+
};
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return applyConfig(swc, (config) => {
|
|
71
|
+
if (esbuild) {
|
|
72
|
+
if (config.jsMinify !== false && esbuild.minimize !== false) {
|
|
73
|
+
_logger.logger.warn("You have enabled both esbuild minimizer and SWC minimizer, which will cause conflicts. Please remove `tools.esbuild` config and only use SWC to minimize your code.");
|
|
74
|
+
}
|
|
75
|
+
if (esbuild.loader !== false) {
|
|
76
|
+
_logger.logger.warn("You have enabled both esbuild loader and SWC loader, which will cause conflicts. Please remove `tools.esbuild` config and only use SWC to transform your code.");
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
71
81
|
const PLUGIN_NAME = "@modern-js/plugin-swc";
|
|
72
82
|
const swcPlugin = factory(PLUGIN_NAME, (swcOptions) => {
|
|
73
|
-
swcOptions
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
83
|
+
return applyConfig(swcOptions, (swcOptions2) => {
|
|
84
|
+
swcOptions2.extensions = {
|
|
85
|
+
...swcOptions2.extensions || {},
|
|
86
|
+
ssrLoaderId: {
|
|
87
|
+
runtimePackageName: "@modern-js/runtime",
|
|
88
|
+
functionUseLoaderName: "useLoader"
|
|
89
|
+
}
|
|
90
|
+
};
|
|
91
|
+
});
|
|
81
92
|
});
|
|
93
|
+
function applyConfig(rawConfig, handler) {
|
|
94
|
+
if (typeof rawConfig === "function") {
|
|
95
|
+
return (config, utils) => {
|
|
96
|
+
handler(config);
|
|
97
|
+
return rawConfig(config, utils);
|
|
98
|
+
};
|
|
99
|
+
} else {
|
|
100
|
+
handler(rawConfig);
|
|
101
|
+
return rawConfig;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
82
104
|
const _default = swcPlugin;
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"modern",
|
|
15
15
|
"modern.js"
|
|
16
16
|
],
|
|
17
|
-
"version": "2.
|
|
17
|
+
"version": "2.29.0",
|
|
18
18
|
"jsnext:source": "./src/index.ts",
|
|
19
19
|
"types": "./dist/index.d.ts",
|
|
20
20
|
"main": "./dist/index.js",
|
|
@@ -31,18 +31,18 @@
|
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
33
|
"@swc/helpers": "0.5.1",
|
|
34
|
-
"@modern-js/utils": "2.
|
|
35
|
-
"@modern-js/builder-plugin-swc": "2.
|
|
34
|
+
"@modern-js/utils": "2.29.0",
|
|
35
|
+
"@modern-js/builder-plugin-swc": "2.29.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
|
-
"@types/jest": "^29",
|
|
39
38
|
"@types/node": "^14",
|
|
39
|
+
"@types/jest": "^29",
|
|
40
40
|
"typescript": "^5",
|
|
41
|
-
"@modern-js/types": "2.
|
|
42
|
-
"@modern-js/app-tools": "2.
|
|
43
|
-
"@modern-js/builder-shared": "2.
|
|
44
|
-
"@scripts/jest-config": "2.
|
|
45
|
-
"@scripts/build": "2.
|
|
41
|
+
"@modern-js/types": "2.29.0",
|
|
42
|
+
"@modern-js/app-tools": "2.29.0",
|
|
43
|
+
"@modern-js/builder-shared": "2.29.0",
|
|
44
|
+
"@scripts/jest-config": "2.29.0",
|
|
45
|
+
"@scripts/build": "2.29.0"
|
|
46
46
|
},
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"registry": "https://registry.npmjs.org/",
|