@modern-js/plugin-swc 2.22.0 → 2.23.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 CHANGED
@@ -1,5 +1,40 @@
1
1
  # @modern-js/core
2
2
 
3
+ ## 2.23.0
4
+
5
+ ### Minor Changes
6
+
7
+ - b185fdf: refactor: merge the swc plugin
8
+ refactor: 合并 swc 插件
9
+
10
+ ### Patch Changes
11
+
12
+ - 7e6fb5f: chore: publishConfig add provenance config
13
+
14
+ chore: publishConfig 增加 provenance 配置
15
+
16
+ - c3216b5: chore: split the scheme into the plugin
17
+
18
+ chore: 拆分 scheme 到插件内部
19
+
20
+ - Updated dependencies [7e6fb5f]
21
+ - Updated dependencies [a7a7ad7]
22
+ - Updated dependencies [6dec7c2]
23
+ - Updated dependencies [c3216b5]
24
+ - Updated dependencies [b185fdf]
25
+ - @modern-js/builder-plugin-swc@2.23.0
26
+ - @modern-js/utils@2.23.0
27
+
28
+ ## 2.22.1
29
+
30
+ ### Patch Changes
31
+
32
+ - Updated dependencies [e2848a2]
33
+ - Updated dependencies [d4045ed]
34
+ - Updated dependencies [1f02cd2]
35
+ - @modern-js/utils@2.22.1
36
+ - @modern-js/builder-plugin-swc@2.22.1
37
+
3
38
  ## 2.22.0
4
39
 
5
40
  ### Patch Changes
package/dist/index.d.ts CHANGED
@@ -1,3 +1,5 @@
1
1
  import type { AppTools, CliPlugin } from '@modern-js/app-tools';
2
+ import { PluginSwcOptions } from '@modern-js/builder-plugin-swc';
3
+ export declare function factory(name: string, modifySwcOptions: (options: PluginSwcOptions) => PluginSwcOptions): () => CliPlugin<AppTools>;
2
4
  declare const _default: () => CliPlugin<AppTools>;
3
5
  export default _default;
package/dist/index.js CHANGED
@@ -1,30 +1,58 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.factory = void 0;
3
4
  const utils_1 = require("@modern-js/utils");
4
5
  const builder_plugin_swc_1 = require("@modern-js/builder-plugin-swc");
5
6
  const logger_1 = require("@modern-js/utils/logger");
6
- exports.default = () => ({
7
- name: '@modern-js/plugin-swc',
8
- setup: api => ({
9
- validateSchema() {
10
- return utils_1.PLUGIN_SCHEMAS['@modern-js/plugin-swc'];
11
- },
12
- prepare() {
13
- const context = api.useAppContext();
14
- if (!context.builder) {
15
- return;
16
- }
17
- const config = api.useResolvedConfigContext();
18
- const { esbuild, swc = {} } = config.tools;
19
- context.builder.addPlugins([(0, builder_plugin_swc_1.builderPluginSwc)(swc)]);
20
- if (esbuild) {
21
- if (swc.jsMinify !== false && esbuild.minimize !== false) {
22
- 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.');
7
+ function factory(name, modifySwcOptions) {
8
+ return () => ({
9
+ name,
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) {
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
+ };
23
33
  }
24
- if (esbuild.loader !== false) {
25
- 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.');
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
+ }
26
42
  }
27
- }
43
+ },
44
+ }),
45
+ });
46
+ }
47
+ exports.factory = factory;
48
+ const PLUGIN_NAME = '@modern-js/plugin-swc';
49
+ exports.default = factory(PLUGIN_NAME, swcOptions => {
50
+ swcOptions.extensions = {
51
+ ...(swcOptions.extensions || {}),
52
+ ssrLoaderId: {
53
+ runtimePackageName: '@modern-js/runtime',
54
+ functionUseLoaderName: 'useLoader',
28
55
  },
29
- }),
56
+ };
57
+ return swcOptions;
30
58
  });
package/package.json CHANGED
@@ -14,7 +14,7 @@
14
14
  "modern",
15
15
  "modern.js"
16
16
  ],
17
- "version": "2.22.0",
17
+ "version": "2.23.0",
18
18
  "jsnext:source": "./src/index.ts",
19
19
  "types": "./dist/index.d.ts",
20
20
  "main": "./dist/index.js",
@@ -30,23 +30,23 @@
30
30
  }
31
31
  },
32
32
  "dependencies": {
33
- "@modern-js/builder-plugin-swc": "2.22.0",
34
- "@modern-js/utils": "2.22.0"
33
+ "@modern-js/builder-plugin-swc": "2.23.0",
34
+ "@modern-js/utils": "2.23.0"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/jest": "^29",
38
38
  "@types/node": "^14",
39
39
  "typescript": "^5",
40
- "@modern-js/app-tools": "2.22.0",
41
- "@modern-js/builder-shared": "2.22.0",
42
- "@modern-js/babel-preset-app": "2.22.0",
43
- "@modern-js/types": "2.22.0",
44
- "@scripts/jest-config": "2.22.0",
45
- "@scripts/build": "2.22.0"
40
+ "@modern-js/app-tools": "2.23.0",
41
+ "@modern-js/builder-shared": "2.23.0",
42
+ "@modern-js/types": "2.23.0",
43
+ "@scripts/build": "2.23.0",
44
+ "@scripts/jest-config": "2.23.0"
46
45
  },
47
46
  "publishConfig": {
48
47
  "registry": "https://registry.npmjs.org/",
49
- "access": "public"
48
+ "access": "public",
49
+ "provenance": true
50
50
  },
51
51
  "scripts": {
52
52
  "new": "modern-lib new",