@modern-js/plugin-swc 2.22.1 → 2.23.1

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.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies [f08bbfc]
8
+ - Updated dependencies [a6b313a]
9
+ - Updated dependencies [8f2cab0]
10
+ - @modern-js/utils@2.23.1
11
+ - @modern-js/builder-plugin-swc@2.23.1
12
+
13
+ ## 2.23.0
14
+
15
+ ### Minor Changes
16
+
17
+ - b185fdf: refactor: merge the swc plugin
18
+ refactor: 合并 swc 插件
19
+
20
+ ### Patch Changes
21
+
22
+ - 7e6fb5f: chore: publishConfig add provenance config
23
+
24
+ chore: publishConfig 增加 provenance 配置
25
+
26
+ - c3216b5: chore: split the scheme into the plugin
27
+
28
+ chore: 拆分 scheme 到插件内部
29
+
30
+ - Updated dependencies [7e6fb5f]
31
+ - Updated dependencies [a7a7ad7]
32
+ - Updated dependencies [6dec7c2]
33
+ - Updated dependencies [c3216b5]
34
+ - Updated dependencies [b185fdf]
35
+ - @modern-js/builder-plugin-swc@2.23.0
36
+ - @modern-js/utils@2.23.0
37
+
3
38
  ## 2.22.1
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.1",
17
+ "version": "2.23.1",
18
18
  "jsnext:source": "./src/index.ts",
19
19
  "types": "./dist/index.d.ts",
20
20
  "main": "./dist/index.js",
@@ -30,22 +30,23 @@
30
30
  }
31
31
  },
32
32
  "dependencies": {
33
- "@modern-js/builder-plugin-swc": "2.22.1",
34
- "@modern-js/utils": "2.22.1"
33
+ "@modern-js/builder-plugin-swc": "2.23.1",
34
+ "@modern-js/utils": "2.23.1"
35
35
  },
36
36
  "devDependencies": {
37
37
  "@types/jest": "^29",
38
38
  "@types/node": "^14",
39
39
  "typescript": "^5",
40
- "@modern-js/types": "2.22.1",
41
- "@modern-js/app-tools": "2.22.1",
42
- "@modern-js/builder-shared": "2.22.1",
43
- "@scripts/build": "2.22.1",
44
- "@scripts/jest-config": "2.22.1"
40
+ "@modern-js/types": "2.23.1",
41
+ "@modern-js/builder-shared": "2.23.1",
42
+ "@modern-js/app-tools": "2.23.1",
43
+ "@scripts/build": "2.23.1",
44
+ "@scripts/jest-config": "2.23.1"
45
45
  },
46
46
  "publishConfig": {
47
47
  "registry": "https://registry.npmjs.org/",
48
- "access": "public"
48
+ "access": "public",
49
+ "provenance": true
49
50
  },
50
51
  "scripts": {
51
52
  "new": "modern-lib new",