@modern-js/plugin-swc 2.35.1 → 2.36.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/dist/index.js +38 -31
- package/package.json +8 -8
package/dist/index.js
CHANGED
|
@@ -1,31 +1,32 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
6
7
|
for (var name in all)
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
return factory;
|
|
15
|
-
},
|
|
16
|
-
applyBuilderSwcConfig: function() {
|
|
17
|
-
return applyBuilderSwcConfig;
|
|
18
|
-
},
|
|
19
|
-
swcPlugin: function() {
|
|
20
|
-
return swcPlugin;
|
|
21
|
-
},
|
|
22
|
-
default: function() {
|
|
23
|
-
return _default;
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
24
15
|
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var src_exports = {};
|
|
20
|
+
__export(src_exports, {
|
|
21
|
+
applyBuilderSwcConfig: () => applyBuilderSwcConfig,
|
|
22
|
+
default: () => src_default,
|
|
23
|
+
factory: () => factory,
|
|
24
|
+
swcPlugin: () => swcPlugin
|
|
25
25
|
});
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
26
|
+
module.exports = __toCommonJS(src_exports);
|
|
27
|
+
var import_utils = require("@modern-js/utils");
|
|
28
|
+
var import_builder_plugin_swc = require("@modern-js/builder-plugin-swc");
|
|
29
|
+
var import_logger = require("@modern-js/utils/logger");
|
|
29
30
|
function factory(name, modifySwcOptions) {
|
|
30
31
|
return () => ({
|
|
31
32
|
name,
|
|
@@ -51,16 +52,16 @@ function factory(name, modifySwcOptions) {
|
|
|
51
52
|
const config = api.useResolvedConfigContext();
|
|
52
53
|
const { esbuild, swc = {} } = config.tools;
|
|
53
54
|
const swcOptions = modifySwcOptions(swc);
|
|
54
|
-
const finalConfig = applyBuilderSwcConfig(swcOptions, esbuild, (0,
|
|
55
|
+
const finalConfig = applyBuilderSwcConfig(swcOptions, esbuild, (0, import_utils.isSSR)(config));
|
|
55
56
|
context.builder.addPlugins([
|
|
56
|
-
(0,
|
|
57
|
+
(0, import_builder_plugin_swc.builderPluginSwc)(finalConfig)
|
|
57
58
|
]);
|
|
58
59
|
}
|
|
59
60
|
})
|
|
60
61
|
});
|
|
61
62
|
}
|
|
62
|
-
function applyBuilderSwcConfig(swc, esbuild,
|
|
63
|
-
if (
|
|
63
|
+
function applyBuilderSwcConfig(swc, esbuild, isSSR2) {
|
|
64
|
+
if (isSSR2) {
|
|
64
65
|
swc = applyConfig(swc, (config) => {
|
|
65
66
|
config.extensions = {
|
|
66
67
|
...config.extensions || {},
|
|
@@ -71,10 +72,10 @@ function applyBuilderSwcConfig(swc, esbuild, isSSR) {
|
|
|
71
72
|
return applyConfig(swc, (config) => {
|
|
72
73
|
if (esbuild) {
|
|
73
74
|
if (config.jsMinify !== false && esbuild.minimize !== false) {
|
|
74
|
-
|
|
75
|
+
import_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.");
|
|
75
76
|
}
|
|
76
77
|
if (esbuild.loader !== false) {
|
|
77
|
-
|
|
78
|
+
import_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.");
|
|
78
79
|
}
|
|
79
80
|
}
|
|
80
81
|
});
|
|
@@ -102,4 +103,10 @@ function applyConfig(rawConfig, handler) {
|
|
|
102
103
|
return rawConfig;
|
|
103
104
|
}
|
|
104
105
|
}
|
|
105
|
-
|
|
106
|
+
var src_default = swcPlugin;
|
|
107
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
108
|
+
0 && (module.exports = {
|
|
109
|
+
applyBuilderSwcConfig,
|
|
110
|
+
factory,
|
|
111
|
+
swcPlugin
|
|
112
|
+
});
|
package/package.json
CHANGED
|
@@ -14,7 +14,7 @@
|
|
|
14
14
|
"modern",
|
|
15
15
|
"modern.js"
|
|
16
16
|
],
|
|
17
|
-
"version": "2.
|
|
17
|
+
"version": "2.36.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/builder-plugin-swc": "2.
|
|
35
|
-
"@modern-js/utils": "2.
|
|
34
|
+
"@modern-js/builder-plugin-swc": "2.36.0",
|
|
35
|
+
"@modern-js/utils": "2.36.0"
|
|
36
36
|
},
|
|
37
37
|
"devDependencies": {
|
|
38
38
|
"@types/node": "^14",
|
|
39
39
|
"@types/jest": "^29",
|
|
40
40
|
"typescript": "^5",
|
|
41
|
-
"@modern-js/
|
|
42
|
-
"@modern-js/
|
|
43
|
-
"@modern-js/
|
|
44
|
-
"@scripts/
|
|
45
|
-
"@scripts/
|
|
41
|
+
"@modern-js/app-tools": "2.36.0",
|
|
42
|
+
"@modern-js/builder-shared": "2.36.0",
|
|
43
|
+
"@modern-js/types": "2.36.0",
|
|
44
|
+
"@scripts/build": "2.36.0",
|
|
45
|
+
"@scripts/jest-config": "2.36.0"
|
|
46
46
|
},
|
|
47
47
|
"publishConfig": {
|
|
48
48
|
"registry": "https://registry.npmjs.org/",
|