@modern-js/runtime 3.0.3 → 3.0.4

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.
@@ -105,7 +105,7 @@ const runtimePlugin = (params)=>({
105
105
  'process.env.IS_REACT18': process.env.IS_REACT18
106
106
  },
107
107
  include: [
108
- new RegExp(`[\\\\/]node_modules[\\\\/]@${metaName}[\\\\/]runtime[\\\\/].*[\\\\/]head\\.[jt]sx?$`)
108
+ new RegExp(`[\\\\/]node_modules[\\\\/]@${metaName}[\\\\/]runtime[\\\\/].*[\\\\/]head\\.`)
109
109
  ]
110
110
  },
111
111
  tools: {
@@ -57,7 +57,7 @@ const checkUseStringSSR = (config, appDirectory, entrypoints)=>{
57
57
  }
58
58
  return true;
59
59
  };
60
- const ssrBuilderPlugin = (modernAPI, outputModule)=>({
60
+ const ssrBuilderPlugin = (modernAPI, outputModule, exportLoadablePath)=>({
61
61
  name: '@modern-js/builder-plugin-ssr',
62
62
  setup (api) {
63
63
  api.modifyEnvironmentConfig((config, { name, mergeEnvironmentConfig })=>{
@@ -67,6 +67,7 @@ const ssrBuilderPlugin = (modernAPI, outputModule)=>({
67
67
  const appContext = modernAPI.getAppContext();
68
68
  const { appDirectory, entrypoints } = appContext;
69
69
  const useLoadablePlugin = (0, utils_namespaceObject.isUseSSRBundle)(userConfig) && !isServerEnvironment && checkUseStringSSR(userConfig, appDirectory, entrypoints);
70
+ const useLoadableComponents = (0, utils_namespaceObject.isUseSSRBundle)(userConfig) && checkUseStringSSR(userConfig, appDirectory, entrypoints);
70
71
  return mergeEnvironmentConfig(config, {
71
72
  source: {
72
73
  define: {
@@ -84,33 +85,8 @@ const ssrBuilderPlugin = (modernAPI, outputModule)=>({
84
85
  filename: utils_namespaceObject.LOADABLE_STATS_FILE
85
86
  }
86
87
  ]);
87
- } : void 0
88
- }
89
- });
90
- });
91
- }
92
- });
93
- const ssrPlugin = ()=>({
94
- name: '@modern-js/plugin-ssr',
95
- required: [
96
- '@modern-js/runtime'
97
- ],
98
- setup: (api)=>{
99
- const appContext = api.getAppContext();
100
- const exportLoadablePath = `@${appContext.metaName}/runtime/loadable`;
101
- const runtimeUtilsPath = require.resolve('@modern-js/runtime-utils/node');
102
- const aliasPath = runtimeUtilsPath.replace(`${external_path_default().sep}cjs${external_path_default().sep}`, `${external_path_default().sep}esm${external_path_default().sep}`).replace(/\.js$/, '.mjs');
103
- api.config(()=>({
104
- builderPlugins: [
105
- ssrBuilderPlugin(api, 'module' === appContext.moduleType)
106
- ],
107
- resolve: {
108
- alias: {
109
- '@modern-js/runtime-utils/node$': aliasPath
110
- }
111
- },
112
- tools: {
113
- swc: {
88
+ } : void 0,
89
+ swc: useLoadableComponents ? {
114
90
  jsc: {
115
91
  experimental: {
116
92
  plugins: [
@@ -140,6 +116,29 @@ const ssrPlugin = ()=>({
140
116
  ]
141
117
  }
142
118
  }
119
+ } : void 0
120
+ }
121
+ });
122
+ });
123
+ }
124
+ });
125
+ const ssrPlugin = ()=>({
126
+ name: '@modern-js/plugin-ssr',
127
+ required: [
128
+ '@modern-js/runtime'
129
+ ],
130
+ setup: (api)=>{
131
+ const appContext = api.getAppContext();
132
+ const exportLoadablePath = `@${appContext.metaName}/runtime/loadable`;
133
+ const runtimeUtilsPath = require.resolve('@modern-js/runtime-utils/node');
134
+ const aliasPath = runtimeUtilsPath.replace(`${external_path_default().sep}cjs${external_path_default().sep}`, `${external_path_default().sep}esm${external_path_default().sep}`).replace(/\.js$/, '.mjs');
135
+ api.config(()=>({
136
+ builderPlugins: [
137
+ ssrBuilderPlugin(api, 'module' === appContext.moduleType, exportLoadablePath)
138
+ ],
139
+ resolve: {
140
+ alias: {
141
+ '@modern-js/runtime-utils/node$': aliasPath
143
142
  }
144
143
  }
145
144
  }));
@@ -129,6 +129,10 @@ const configureChildCompiler = (child, compiler, appDirectory)=>{
129
129
  node: true
130
130
  };
131
131
  child.options.devtool = false;
132
+ if (child.options.optimization && 'object' == typeof child.options.optimization) child.options.optimization.minimize = false;
133
+ else child.options.optimization = {
134
+ minimize: false
135
+ };
132
136
  };
133
137
  const applyExternalsPlugin = (child, compiler)=>{
134
138
  const ExternalsPlugin = compiler.rspack?.ExternalsPlugin;
@@ -62,7 +62,7 @@ const runtimePlugin = (params)=>({
62
62
  'process.env.IS_REACT18': process.env.IS_REACT18
63
63
  },
64
64
  include: [
65
- new RegExp(`[\\\\/]node_modules[\\\\/]@${metaName}[\\\\/]runtime[\\\\/].*[\\\\/]head\\.[jt]sx?$`)
65
+ new RegExp(`[\\\\/]node_modules[\\\\/]@${metaName}[\\\\/]runtime[\\\\/].*[\\\\/]head\\.`)
66
66
  ]
67
67
  },
68
68
  tools: {
@@ -17,7 +17,7 @@ const checkUseStringSSR = (config, appDirectory, entrypoints)=>{
17
17
  }
18
18
  return true;
19
19
  };
20
- const ssrBuilderPlugin = (modernAPI, outputModule)=>({
20
+ const ssrBuilderPlugin = (modernAPI, outputModule, exportLoadablePath)=>({
21
21
  name: '@modern-js/builder-plugin-ssr',
22
22
  setup (api) {
23
23
  api.modifyEnvironmentConfig((config, { name, mergeEnvironmentConfig })=>{
@@ -27,6 +27,7 @@ const ssrBuilderPlugin = (modernAPI, outputModule)=>({
27
27
  const appContext = modernAPI.getAppContext();
28
28
  const { appDirectory, entrypoints } = appContext;
29
29
  const useLoadablePlugin = isUseSSRBundle(userConfig) && !isServerEnvironment && checkUseStringSSR(userConfig, appDirectory, entrypoints);
30
+ const useLoadableComponents = isUseSSRBundle(userConfig) && checkUseStringSSR(userConfig, appDirectory, entrypoints);
30
31
  return mergeEnvironmentConfig(config, {
31
32
  source: {
32
33
  define: {
@@ -44,33 +45,8 @@ const ssrBuilderPlugin = (modernAPI, outputModule)=>({
44
45
  filename: LOADABLE_STATS_FILE
45
46
  }
46
47
  ]);
47
- } : void 0
48
- }
49
- });
50
- });
51
- }
52
- });
53
- const ssrPlugin = ()=>({
54
- name: '@modern-js/plugin-ssr',
55
- required: [
56
- '@modern-js/runtime'
57
- ],
58
- setup: (api)=>{
59
- const appContext = api.getAppContext();
60
- const exportLoadablePath = `@${appContext.metaName}/runtime/loadable`;
61
- const runtimeUtilsPath = require.resolve('@modern-js/runtime-utils/node');
62
- const aliasPath = runtimeUtilsPath.replace(`${path.sep}cjs${path.sep}`, `${path.sep}esm${path.sep}`).replace(/\.js$/, '.mjs');
63
- api.config(()=>({
64
- builderPlugins: [
65
- ssrBuilderPlugin(api, 'module' === appContext.moduleType)
66
- ],
67
- resolve: {
68
- alias: {
69
- '@modern-js/runtime-utils/node$': aliasPath
70
- }
71
- },
72
- tools: {
73
- swc: {
48
+ } : void 0,
49
+ swc: useLoadableComponents ? {
74
50
  jsc: {
75
51
  experimental: {
76
52
  plugins: [
@@ -100,6 +76,29 @@ const ssrPlugin = ()=>({
100
76
  ]
101
77
  }
102
78
  }
79
+ } : void 0
80
+ }
81
+ });
82
+ });
83
+ }
84
+ });
85
+ const ssrPlugin = ()=>({
86
+ name: '@modern-js/plugin-ssr',
87
+ required: [
88
+ '@modern-js/runtime'
89
+ ],
90
+ setup: (api)=>{
91
+ const appContext = api.getAppContext();
92
+ const exportLoadablePath = `@${appContext.metaName}/runtime/loadable`;
93
+ const runtimeUtilsPath = require.resolve('@modern-js/runtime-utils/node');
94
+ const aliasPath = runtimeUtilsPath.replace(`${path.sep}cjs${path.sep}`, `${path.sep}esm${path.sep}`).replace(/\.js$/, '.mjs');
95
+ api.config(()=>({
96
+ builderPlugins: [
97
+ ssrBuilderPlugin(api, 'module' === appContext.moduleType, exportLoadablePath)
98
+ ],
99
+ resolve: {
100
+ alias: {
101
+ '@modern-js/runtime-utils/node$': aliasPath
103
102
  }
104
103
  }
105
104
  }));
@@ -88,6 +88,10 @@ const configureChildCompiler = (child, compiler, appDirectory)=>{
88
88
  node: true
89
89
  };
90
90
  child.options.devtool = false;
91
+ if (child.options.optimization && 'object' == typeof child.options.optimization) child.options.optimization.minimize = false;
92
+ else child.options.optimization = {
93
+ minimize: false
94
+ };
91
95
  };
92
96
  const applyExternalsPlugin = (child, compiler)=>{
93
97
  const ExternalsPlugin = compiler.rspack?.ExternalsPlugin;
@@ -64,7 +64,7 @@ const runtimePlugin = (params)=>({
64
64
  'process.env.IS_REACT18': process.env.IS_REACT18
65
65
  },
66
66
  include: [
67
- new RegExp(`[\\\\/]node_modules[\\\\/]@${metaName}[\\\\/]runtime[\\\\/].*[\\\\/]head\\.[jt]sx?$`)
67
+ new RegExp(`[\\\\/]node_modules[\\\\/]@${metaName}[\\\\/]runtime[\\\\/].*[\\\\/]head\\.`)
68
68
  ]
69
69
  },
70
70
  tools: {
@@ -19,7 +19,7 @@ const checkUseStringSSR = (config, appDirectory, entrypoints)=>{
19
19
  }
20
20
  return true;
21
21
  };
22
- const ssrBuilderPlugin = (modernAPI, outputModule)=>({
22
+ const ssrBuilderPlugin = (modernAPI, outputModule, exportLoadablePath)=>({
23
23
  name: '@modern-js/builder-plugin-ssr',
24
24
  setup (api) {
25
25
  api.modifyEnvironmentConfig((config, { name, mergeEnvironmentConfig })=>{
@@ -29,6 +29,7 @@ const ssrBuilderPlugin = (modernAPI, outputModule)=>({
29
29
  const appContext = modernAPI.getAppContext();
30
30
  const { appDirectory, entrypoints } = appContext;
31
31
  const useLoadablePlugin = isUseSSRBundle(userConfig) && !isServerEnvironment && checkUseStringSSR(userConfig, appDirectory, entrypoints);
32
+ const useLoadableComponents = isUseSSRBundle(userConfig) && checkUseStringSSR(userConfig, appDirectory, entrypoints);
32
33
  return mergeEnvironmentConfig(config, {
33
34
  source: {
34
35
  define: {
@@ -46,33 +47,8 @@ const ssrBuilderPlugin = (modernAPI, outputModule)=>({
46
47
  filename: LOADABLE_STATS_FILE
47
48
  }
48
49
  ]);
49
- } : void 0
50
- }
51
- });
52
- });
53
- }
54
- });
55
- const ssrPlugin = ()=>({
56
- name: '@modern-js/plugin-ssr',
57
- required: [
58
- '@modern-js/runtime'
59
- ],
60
- setup: (api)=>{
61
- const appContext = api.getAppContext();
62
- const exportLoadablePath = `@${appContext.metaName}/runtime/loadable`;
63
- const runtimeUtilsPath = require.resolve('@modern-js/runtime-utils/node');
64
- const aliasPath = runtimeUtilsPath.replace(`${path.sep}cjs${path.sep}`, `${path.sep}esm${path.sep}`).replace(/\.js$/, '.mjs');
65
- api.config(()=>({
66
- builderPlugins: [
67
- ssrBuilderPlugin(api, 'module' === appContext.moduleType)
68
- ],
69
- resolve: {
70
- alias: {
71
- '@modern-js/runtime-utils/node$': aliasPath
72
- }
73
- },
74
- tools: {
75
- swc: {
50
+ } : void 0,
51
+ swc: useLoadableComponents ? {
76
52
  jsc: {
77
53
  experimental: {
78
54
  plugins: [
@@ -102,6 +78,29 @@ const ssrPlugin = ()=>({
102
78
  ]
103
79
  }
104
80
  }
81
+ } : void 0
82
+ }
83
+ });
84
+ });
85
+ }
86
+ });
87
+ const ssrPlugin = ()=>({
88
+ name: '@modern-js/plugin-ssr',
89
+ required: [
90
+ '@modern-js/runtime'
91
+ ],
92
+ setup: (api)=>{
93
+ const appContext = api.getAppContext();
94
+ const exportLoadablePath = `@${appContext.metaName}/runtime/loadable`;
95
+ const runtimeUtilsPath = require.resolve('@modern-js/runtime-utils/node');
96
+ const aliasPath = runtimeUtilsPath.replace(`${path.sep}cjs${path.sep}`, `${path.sep}esm${path.sep}`).replace(/\.js$/, '.mjs');
97
+ api.config(()=>({
98
+ builderPlugins: [
99
+ ssrBuilderPlugin(api, 'module' === appContext.moduleType, exportLoadablePath)
100
+ ],
101
+ resolve: {
102
+ alias: {
103
+ '@modern-js/runtime-utils/node$': aliasPath
105
104
  }
106
105
  }
107
106
  }));
@@ -90,6 +90,10 @@ const configureChildCompiler = (child, compiler, appDirectory)=>{
90
90
  node: true
91
91
  };
92
92
  child.options.devtool = false;
93
+ if (child.options.optimization && 'object' == typeof child.options.optimization) child.options.optimization.minimize = false;
94
+ else child.options.optimization = {
95
+ minimize: false
96
+ };
93
97
  };
94
98
  const applyExternalsPlugin = (child, compiler)=>{
95
99
  const ExternalsPlugin = compiler.rspack?.ExternalsPlugin;
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "3.0.3",
18
+ "version": "3.0.4",
19
19
  "engines": {
20
20
  "node": ">=20"
21
21
  },
@@ -215,12 +215,12 @@
215
215
  "isbot": "3.8.0",
216
216
  "react-helmet": "^6.1.0",
217
217
  "react-is": "^18.3.1",
218
- "@modern-js/plugin": "3.0.3",
219
- "@modern-js/plugin-data-loader": "3.0.3",
220
- "@modern-js/render": "3.0.3",
221
- "@modern-js/runtime-utils": "3.0.3",
222
- "@modern-js/types": "3.0.3",
223
- "@modern-js/utils": "3.0.3"
218
+ "@modern-js/plugin": "3.0.4",
219
+ "@modern-js/plugin-data-loader": "3.0.4",
220
+ "@modern-js/render": "3.0.4",
221
+ "@modern-js/runtime-utils": "3.0.4",
222
+ "@modern-js/types": "3.0.4",
223
+ "@modern-js/utils": "3.0.4"
224
224
  },
225
225
  "peerDependencies": {
226
226
  "react": ">=17.0.2",
@@ -240,7 +240,7 @@
240
240
  "react-dom": "^19.2.4",
241
241
  "ts-node": "^10.9.2",
242
242
  "typescript": "^5",
243
- "@modern-js/app-tools": "3.0.3",
243
+ "@modern-js/app-tools": "3.0.4",
244
244
  "@modern-js/rslib": "2.68.10",
245
245
  "@scripts/rstest-config": "2.66.0"
246
246
  },