@modern-js/runtime 3.0.2 → 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.
@@ -103,7 +103,10 @@ const runtimePlugin = (params)=>({
103
103
  source: {
104
104
  globalVars: {
105
105
  'process.env.IS_REACT18': process.env.IS_REACT18
106
- }
106
+ },
107
+ include: [
108
+ new RegExp(`[\\\\/]node_modules[\\\\/]@${metaName}[\\\\/]runtime[\\\\/].*[\\\\/]head\\.`)
109
+ ]
107
110
  },
108
111
  tools: {
109
112
  bundlerChain: (chain)=>{
@@ -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;
@@ -1,19 +1,6 @@
1
1
  "use strict";
2
- var __webpack_modules__ = {
3
- "react-helmet" (module) {
4
- module.exports = require("react-helmet");
5
- }
6
- };
7
- var __webpack_module_cache__ = {};
8
- function __webpack_require__(moduleId) {
9
- var cachedModule = __webpack_module_cache__[moduleId];
10
- if (void 0 !== cachedModule) return cachedModule.exports;
11
- var module = __webpack_module_cache__[moduleId] = {
12
- exports: {}
13
- };
14
- __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
15
- return module.exports;
16
- }
2
+ "use client";
3
+ var __webpack_require__ = {};
17
4
  (()=>{
18
5
  __webpack_require__.n = (module)=>{
19
6
  var getter = module && module.__esModule ? ()=>module['default'] : ()=>module;
@@ -45,20 +32,18 @@ function __webpack_require__(moduleId) {
45
32
  };
46
33
  })();
47
34
  var __webpack_exports__ = {};
48
- (()=>{
49
- __webpack_require__.r(__webpack_exports__);
50
- __webpack_require__.d(__webpack_exports__, {
51
- default: ()=>__rspack_default_export
52
- });
53
- var react_helmet__rspack_import_0 = __webpack_require__("react-helmet");
54
- var react_helmet__rspack_import_0_default = /*#__PURE__*/ __webpack_require__.n(react_helmet__rspack_import_0);
55
- var __rspack_reexport = {};
56
- for(const __rspack_import_key in react_helmet__rspack_import_0)if ("default" !== __rspack_import_key) __rspack_reexport[__rspack_import_key] = ()=>react_helmet__rspack_import_0[__rspack_import_key];
57
- __webpack_require__.d(__webpack_exports__, __rspack_reexport);
58
- const __rspack_default_export = react_helmet__rspack_import_0_default();
59
- })();
35
+ __webpack_require__.r(__webpack_exports__);
36
+ __webpack_require__.d(__webpack_exports__, {
37
+ Helmet: ()=>external_react_helmet_namespaceObject.Helmet,
38
+ default: ()=>head
39
+ });
40
+ const external_react_helmet_namespaceObject = require("react-helmet");
41
+ var external_react_helmet_default = /*#__PURE__*/ __webpack_require__.n(external_react_helmet_namespaceObject);
42
+ const head = external_react_helmet_default();
43
+ exports.Helmet = __webpack_exports__.Helmet;
60
44
  exports["default"] = __webpack_exports__["default"];
61
45
  for(var __rspack_i in __webpack_exports__)if (-1 === [
46
+ "Helmet",
62
47
  "default"
63
48
  ].indexOf(__rspack_i)) exports[__rspack_i] = __webpack_exports__[__rspack_i];
64
49
  Object.defineProperty(exports, '__esModule', {
@@ -60,7 +60,10 @@ const runtimePlugin = (params)=>({
60
60
  source: {
61
61
  globalVars: {
62
62
  'process.env.IS_REACT18': process.env.IS_REACT18
63
- }
63
+ },
64
+ include: [
65
+ new RegExp(`[\\\\/]node_modules[\\\\/]@${metaName}[\\\\/]runtime[\\\\/].*[\\\\/]head\\.`)
66
+ ]
64
67
  },
65
68
  tools: {
66
69
  bundlerChain: (chain)=>{
@@ -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;
@@ -1,4 +1,4 @@
1
- import react_helmet from "react-helmet";
2
- export * from "react-helmet";
1
+ "use client";
2
+ import react_helmet, { Helmet } from "react-helmet";
3
3
  const head = react_helmet;
4
- export { head as default };
4
+ export { Helmet, head as default };
@@ -62,7 +62,10 @@ const runtimePlugin = (params)=>({
62
62
  source: {
63
63
  globalVars: {
64
64
  'process.env.IS_REACT18': process.env.IS_REACT18
65
- }
65
+ },
66
+ include: [
67
+ new RegExp(`[\\\\/]node_modules[\\\\/]@${metaName}[\\\\/]runtime[\\\\/].*[\\\\/]head\\.`)
68
+ ]
66
69
  },
67
70
  tools: {
68
71
  bundlerChain: (chain)=>{
@@ -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;
@@ -1,5 +1,5 @@
1
1
  import "node:module";
2
- import react_helmet from "react-helmet";
3
- export * from "react-helmet";
2
+ "use client";
3
+ import react_helmet, { Helmet } from "react-helmet";
4
4
  const head = react_helmet;
5
- export { head as default };
5
+ export { Helmet, head as default };
@@ -1,3 +1,4 @@
1
1
  import head from 'react-helmet';
2
2
  export default head;
3
- export * from 'react-helmet';
3
+ export { Helmet } from 'react-helmet';
4
+ export type { HelmetTags, HelmetProps, HelmetPropsToState, HelmetData, HelmetDatum, HelmetHTMLBodyDatum, HelmetHTMLElementDatum, } from 'react-helmet';
package/package.json CHANGED
@@ -15,7 +15,7 @@
15
15
  "modern",
16
16
  "modern.js"
17
17
  ],
18
- "version": "3.0.2",
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.2",
219
- "@modern-js/render": "3.0.2",
220
- "@modern-js/runtime-utils": "3.0.2",
221
- "@modern-js/plugin-data-loader": "3.0.2",
222
- "@modern-js/types": "3.0.2",
223
- "@modern-js/utils": "3.0.2"
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",
@@ -229,7 +229,7 @@
229
229
  "devDependencies": {
230
230
  "@remix-run/web-fetch": "^4.1.3",
231
231
  "@rsbuild/core": "2.0.0-beta.4",
232
- "@rslib/core": "0.19.5",
232
+ "@rslib/core": "0.19.6",
233
233
  "@testing-library/dom": "^10.4.1",
234
234
  "@testing-library/react": "^16.3.2",
235
235
  "@types/cookie": "0.6.0",
@@ -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.2",
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
  },