@modern-js/plugin-swc 2.26.0 → 2.27.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 +14 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +78 -55
- package/package.json +11 -10
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @modern-js/core
|
|
2
2
|
|
|
3
|
+
## 2.27.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 8322a51: chore: migrate packages from tsc to module-lib build
|
|
8
|
+
|
|
9
|
+
chore: 将使用 tsc 的包迁移到 module-lib 构建
|
|
10
|
+
|
|
11
|
+
- Updated dependencies [91d14b8]
|
|
12
|
+
- Updated dependencies [8322a51]
|
|
13
|
+
- Updated dependencies [6d7104d]
|
|
14
|
+
- @modern-js/utils@2.27.0
|
|
15
|
+
- @modern-js/builder-plugin-swc@2.27.0
|
|
16
|
+
|
|
3
17
|
## 2.26.0
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/index.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ import type { AppTools, CliPlugin } from '@modern-js/app-tools';
|
|
|
2
2
|
import { PluginSwcOptions } from '@modern-js/builder-plugin-swc';
|
|
3
3
|
export declare function factory(name: string, modifySwcOptions: (options: PluginSwcOptions) => PluginSwcOptions): () => CliPlugin<AppTools>;
|
|
4
4
|
export declare const swcPlugin: () => CliPlugin<AppTools>;
|
|
5
|
-
export default swcPlugin;
|
|
5
|
+
export default swcPlugin;
|
package/dist/index.js
CHANGED
|
@@ -1,59 +1,82 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
setup: api => ({
|
|
11
|
-
validateSchema() {
|
|
12
|
-
return [
|
|
13
|
-
{
|
|
14
|
-
target: 'tools.swc',
|
|
15
|
-
schema: { typeof: ['object'] },
|
|
16
|
-
},
|
|
17
|
-
];
|
|
18
|
-
},
|
|
19
|
-
prepare() {
|
|
20
|
-
const context = api.useAppContext();
|
|
21
|
-
if (!context.builder || context.bundlerType === 'rspack') {
|
|
22
|
-
return;
|
|
23
|
-
}
|
|
24
|
-
const config = api.useResolvedConfigContext();
|
|
25
|
-
const { esbuild, swc = {} } = config.tools;
|
|
26
|
-
const swcOptions = modifySwcOptions(swc);
|
|
27
|
-
// common configuration
|
|
28
|
-
if ((0, utils_1.isSSR)(config)) {
|
|
29
|
-
swcOptions.extensions = {
|
|
30
|
-
...(swcOptions.extensions || {}),
|
|
31
|
-
loadableComponents: true,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
context.builder.addPlugins([(0, builder_plugin_swc_1.builderPluginSwc)(swcOptions)]);
|
|
35
|
-
if (esbuild) {
|
|
36
|
-
if (swc.jsMinify !== false && esbuild.minimize !== false) {
|
|
37
|
-
logger_1.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.');
|
|
38
|
-
}
|
|
39
|
-
if (esbuild.loader !== false) {
|
|
40
|
-
logger_1.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.');
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
},
|
|
44
|
-
}),
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
function _export(target, all) {
|
|
6
|
+
for (var name in all)
|
|
7
|
+
Object.defineProperty(target, name, {
|
|
8
|
+
enumerable: true,
|
|
9
|
+
get: all[name]
|
|
45
10
|
});
|
|
46
11
|
}
|
|
47
|
-
exports
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
12
|
+
_export(exports, {
|
|
13
|
+
factory: function() {
|
|
14
|
+
return factory;
|
|
15
|
+
},
|
|
16
|
+
swcPlugin: function() {
|
|
17
|
+
return swcPlugin;
|
|
18
|
+
},
|
|
19
|
+
default: function() {
|
|
20
|
+
return _default;
|
|
21
|
+
}
|
|
22
|
+
});
|
|
23
|
+
const _utils = require("@modern-js/utils");
|
|
24
|
+
const _builderpluginswc = require("@modern-js/builder-plugin-swc");
|
|
25
|
+
const _logger = require("@modern-js/utils/logger");
|
|
26
|
+
function factory(name, modifySwcOptions) {
|
|
27
|
+
return () => ({
|
|
28
|
+
name,
|
|
29
|
+
setup: (api) => ({
|
|
30
|
+
validateSchema() {
|
|
31
|
+
return [
|
|
32
|
+
{
|
|
33
|
+
target: "tools.swc",
|
|
34
|
+
schema: {
|
|
35
|
+
typeof: [
|
|
36
|
+
"object"
|
|
37
|
+
]
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
];
|
|
41
|
+
},
|
|
42
|
+
prepare() {
|
|
43
|
+
const context = api.useAppContext();
|
|
44
|
+
if (!context.builder || context.bundlerType === "rspack") {
|
|
45
|
+
return;
|
|
46
|
+
}
|
|
47
|
+
const config = api.useResolvedConfigContext();
|
|
48
|
+
const { esbuild, swc = {} } = config.tools;
|
|
49
|
+
const swcOptions = modifySwcOptions(swc);
|
|
50
|
+
if ((0, _utils.isSSR)(config)) {
|
|
51
|
+
swcOptions.extensions = {
|
|
52
|
+
...swcOptions.extensions || {},
|
|
53
|
+
loadableComponents: true
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
context.builder.addPlugins([
|
|
57
|
+
(0, _builderpluginswc.builderPluginSwc)(swcOptions)
|
|
58
|
+
]);
|
|
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
|
+
}
|
|
68
|
+
})
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
const PLUGIN_NAME = "@modern-js/plugin-swc";
|
|
72
|
+
const swcPlugin = factory(PLUGIN_NAME, (swcOptions) => {
|
|
73
|
+
swcOptions.extensions = {
|
|
74
|
+
...swcOptions.extensions || {},
|
|
75
|
+
ssrLoaderId: {
|
|
76
|
+
runtimePackageName: "@modern-js/runtime",
|
|
77
|
+
functionUseLoaderName: "useLoader"
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
return swcOptions;
|
|
58
81
|
});
|
|
59
|
-
|
|
82
|
+
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.27.0",
|
|
18
18
|
"jsnext:source": "./src/index.ts",
|
|
19
19
|
"types": "./dist/index.d.ts",
|
|
20
20
|
"main": "./dist/index.js",
|
|
@@ -30,18 +30,19 @@
|
|
|
30
30
|
}
|
|
31
31
|
},
|
|
32
32
|
"dependencies": {
|
|
33
|
-
"@
|
|
34
|
-
"@modern-js/utils": "2.
|
|
33
|
+
"@swc/helpers": "0.5.1",
|
|
34
|
+
"@modern-js/utils": "2.27.0",
|
|
35
|
+
"@modern-js/builder-plugin-swc": "2.27.0"
|
|
35
36
|
},
|
|
36
37
|
"devDependencies": {
|
|
37
38
|
"@types/jest": "^29",
|
|
38
39
|
"@types/node": "^14",
|
|
39
40
|
"typescript": "^5",
|
|
40
|
-
"@modern-js/
|
|
41
|
-
"@modern-js/
|
|
42
|
-
"@modern-js/
|
|
43
|
-
"@scripts/jest-config": "2.
|
|
44
|
-
"@scripts/build": "2.
|
|
41
|
+
"@modern-js/types": "2.27.0",
|
|
42
|
+
"@modern-js/app-tools": "2.27.0",
|
|
43
|
+
"@modern-js/builder-shared": "2.27.0",
|
|
44
|
+
"@scripts/jest-config": "2.27.0",
|
|
45
|
+
"@scripts/build": "2.27.0"
|
|
45
46
|
},
|
|
46
47
|
"publishConfig": {
|
|
47
48
|
"registry": "https://registry.npmjs.org/",
|
|
@@ -50,8 +51,8 @@
|
|
|
50
51
|
},
|
|
51
52
|
"scripts": {
|
|
52
53
|
"new": "modern-lib new",
|
|
53
|
-
"build": "
|
|
54
|
-
"dev": "
|
|
54
|
+
"build": "modern-lib build",
|
|
55
|
+
"dev": "modern-lib build --watch",
|
|
55
56
|
"test": "jest"
|
|
56
57
|
}
|
|
57
58
|
}
|