@bleedingdev/modern-js-runtime 3.9.3-ultramodern.13 → 3.9.3-ultramodern.15

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.
@@ -116,7 +116,8 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
116
116
  return stream;
117
117
  };
118
118
  const onStartupAbort = ()=>fail(request.signal.reason);
119
- const deliver = (source)=>{
119
+ const deliver = (source, fallback = false)=>{
120
+ if (!fallback) for (const extender of extenders)source = extender.processResponseStream?.(source) ?? source;
120
121
  const stream = (0, external_shared_js_namespaceObject.observeSSRStream)(source, {
121
122
  lifecycle,
122
123
  signal: request.signal,
@@ -259,7 +260,7 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
259
260
  });
260
261
  if (failed) return;
261
262
  options.onShellError?.(error);
262
- deliver((0, external_shared_js_namespaceObject_1.getReadableStreamFromString)(`${shellBefore}${shellAfter}`));
263
+ deliver((0, external_shared_js_namespaceObject_1.getReadableStreamFromString)(`${shellBefore}${shellAfter}`), true);
263
264
  };
264
265
  request.signal.addEventListener('abort', onStartupAbort, {
265
266
  once: true
@@ -195,6 +195,7 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
195
195
  if (shellChunkStatus === external_shared_js_namespaceObject_1.ShellChunkStatus.FINISH) coordinator?.enqueueResolver(script);
196
196
  else pendingScripts.push(script);
197
197
  });
198
+ for (const extender of extenders)pendingSource = extender.processResponseStream?.(pendingSource) ?? pendingSource;
198
199
  return (0, external_shared_js_namespaceObject.observeSSRStream)(pendingSource, {
199
200
  lifecycle,
200
201
  async onError (error) {
@@ -37,6 +37,7 @@ var __webpack_require__ = {};
37
37
  var __webpack_exports__ = {};
38
38
  __webpack_require__.r(__webpack_exports__);
39
39
  __webpack_require__.d(__webpack_exports__, {
40
+ applyExternalsPlugin: ()=>applyExternalsPlugin,
40
41
  default: ()=>cli,
41
42
  documentPlugin: ()=>documentPlugin,
42
43
  getDocumentByEntryName: ()=>getDocumentByEntryName,
@@ -141,10 +142,13 @@ const configureChildCompiler = (child, compiler, appDirectory)=>{
141
142
  };
142
143
  };
143
144
  const applyExternalsPlugin = (child, compiler)=>{
145
+ const aliases = compiler.options.resolve.alias ?? {};
146
+ const names = Array.isArray(aliases) ? aliases.map((alias)=>`${alias.name}${alias.onlyModule && !alias.name.endsWith('$') ? '$' : ''}`) : Object.keys(aliases);
147
+ const mappings = Object.fromEntries(Object.entries(EXTERNAL_MAPPINGS).filter(([request])=>!names.some((name)=>name.endsWith('$') ? name === `${request}$` : request === name || request.startsWith(`${name}/`))));
144
148
  const ExternalsPlugin = compiler.rspack?.ExternalsPlugin;
145
149
  if (ExternalsPlugin) new ExternalsPlugin('commonjs', [
146
150
  createExternalHandler(),
147
- EXTERNAL_MAPPINGS
151
+ mappings
148
152
  ]).apply(child);
149
153
  };
150
154
  const generateEntryCode = (docPath, _entryName)=>{
@@ -398,12 +402,14 @@ const documentPlugin = ()=>({
398
402
  }
399
403
  });
400
404
  const cli = documentPlugin;
405
+ exports.applyExternalsPlugin = __webpack_exports__.applyExternalsPlugin;
401
406
  exports["default"] = __webpack_exports__["default"];
402
407
  exports.documentPlugin = __webpack_exports__.documentPlugin;
403
408
  exports.getDocumentByEntryName = __webpack_exports__.getDocumentByEntryName;
404
409
  exports.getDocumentTempEntry = __webpack_exports__.getDocumentTempEntry;
405
410
  exports.processScriptPlaceholders = __webpack_exports__.processScriptPlaceholders;
406
411
  for(var __rspack_i in __webpack_exports__)if (-1 === [
412
+ "applyExternalsPlugin",
407
413
  "default",
408
414
  "documentPlugin",
409
415
  "getDocumentByEntryName",
@@ -84,7 +84,8 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
84
84
  return stream;
85
85
  };
86
86
  const onStartupAbort = ()=>fail(request.signal.reason);
87
- const deliver = (source)=>{
87
+ const deliver = (source, fallback = false)=>{
88
+ if (!fallback) for (const extender of extenders)source = extender.processResponseStream?.(source) ?? source;
88
89
  const stream = observeSSRStream(source, {
89
90
  lifecycle,
90
91
  signal: request.signal,
@@ -227,7 +228,7 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
227
228
  });
228
229
  if (failed) return;
229
230
  options.onShellError?.(error);
230
- deliver(getReadableStreamFromString(`${shellBefore}${shellAfter}`));
231
+ deliver(getReadableStreamFromString(`${shellBefore}${shellAfter}`), true);
231
232
  };
232
233
  request.signal.addEventListener('abort', onStartupAbort, {
233
234
  once: true
@@ -153,6 +153,7 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
153
153
  if (shellChunkStatus === ShellChunkStatus.FINISH) coordinator?.enqueueResolver(script);
154
154
  else pendingScripts.push(script);
155
155
  });
156
+ for (const extender of extenders)pendingSource = extender.processResponseStream?.(pendingSource) ?? pendingSource;
156
157
  return observeSSRStream(pendingSource, {
157
158
  lifecycle,
158
159
  async onError (error) {
@@ -94,10 +94,13 @@ const configureChildCompiler = (child, compiler, appDirectory)=>{
94
94
  };
95
95
  };
96
96
  const applyExternalsPlugin = (child, compiler)=>{
97
+ const aliases = compiler.options.resolve.alias ?? {};
98
+ const names = Array.isArray(aliases) ? aliases.map((alias)=>`${alias.name}${alias.onlyModule && !alias.name.endsWith('$') ? '$' : ''}`) : Object.keys(aliases);
99
+ const mappings = Object.fromEntries(Object.entries(EXTERNAL_MAPPINGS).filter(([request])=>!names.some((name)=>name.endsWith('$') ? name === `${request}$` : request === name || request.startsWith(`${name}/`))));
97
100
  const ExternalsPlugin = compiler.rspack?.ExternalsPlugin;
98
101
  if (ExternalsPlugin) new ExternalsPlugin('commonjs', [
99
102
  createExternalHandler(),
100
- EXTERNAL_MAPPINGS
103
+ mappings
101
104
  ]).apply(child);
102
105
  };
103
106
  const generateEntryCode = (docPath, _entryName)=>{
@@ -352,4 +355,4 @@ const documentPlugin = ()=>({
352
355
  });
353
356
  const cli = documentPlugin;
354
357
  export default cli;
355
- export { documentPlugin, getDocumentByEntryName, getDocumentTempEntry, processScriptPlaceholders };
358
+ export { applyExternalsPlugin, documentPlugin, getDocumentByEntryName, getDocumentTempEntry, processScriptPlaceholders };
@@ -85,7 +85,8 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
85
85
  return stream;
86
86
  };
87
87
  const onStartupAbort = ()=>fail(request.signal.reason);
88
- const deliver = (source)=>{
88
+ const deliver = (source, fallback = false)=>{
89
+ if (!fallback) for (const extender of extenders)source = extender.processResponseStream?.(source) ?? source;
89
90
  const stream = observeSSRStream(source, {
90
91
  lifecycle,
91
92
  signal: request.signal,
@@ -228,7 +229,7 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
228
229
  });
229
230
  if (failed) return;
230
231
  options.onShellError?.(error);
231
- deliver(getReadableStreamFromString(`${shellBefore}${shellAfter}`));
232
+ deliver(getReadableStreamFromString(`${shellBefore}${shellAfter}`), true);
232
233
  };
233
234
  request.signal.addEventListener('abort', onStartupAbort, {
234
235
  once: true
@@ -154,6 +154,7 @@ const createReadableStreamFromElement = async (request, rootElement, options)=>{
154
154
  if (shellChunkStatus === ShellChunkStatus.FINISH) coordinator?.enqueueResolver(script);
155
155
  else pendingScripts.push(script);
156
156
  });
157
+ for (const extender of extenders)pendingSource = extender.processResponseStream?.(pendingSource) ?? pendingSource;
157
158
  return observeSSRStream(pendingSource, {
158
159
  lifecycle,
159
160
  async onError (error) {
@@ -96,10 +96,13 @@ const configureChildCompiler = (child, compiler, appDirectory)=>{
96
96
  };
97
97
  };
98
98
  const applyExternalsPlugin = (child, compiler)=>{
99
+ const aliases = compiler.options.resolve.alias ?? {};
100
+ const names = Array.isArray(aliases) ? aliases.map((alias)=>`${alias.name}${alias.onlyModule && !alias.name.endsWith('$') ? '$' : ''}`) : Object.keys(aliases);
101
+ const mappings = Object.fromEntries(Object.entries(EXTERNAL_MAPPINGS).filter(([request])=>!names.some((name)=>name.endsWith('$') ? name === `${request}$` : request === name || request.startsWith(`${name}/`))));
99
102
  const ExternalsPlugin = compiler.rspack?.ExternalsPlugin;
100
103
  if (ExternalsPlugin) new ExternalsPlugin('commonjs', [
101
104
  createExternalHandler(),
102
- EXTERNAL_MAPPINGS
105
+ mappings
103
106
  ]).apply(child);
104
107
  };
105
108
  const generateEntryCode = (docPath, _entryName)=>{
@@ -354,4 +357,4 @@ const documentPlugin = ()=>({
354
357
  });
355
358
  const cli = documentPlugin;
356
359
  export default cli;
357
- export { documentPlugin, getDocumentByEntryName, getDocumentTempEntry, processScriptPlaceholders };
360
+ export { applyExternalsPlugin, documentPlugin, getDocumentByEntryName, getDocumentTempEntry, processScriptPlaceholders };
@@ -1,7 +1,10 @@
1
1
  import type { AppTools, CliPlugin } from '@modern-js/app-tools';
2
2
  import type { Entrypoint } from '@modern-js/types/cli';
3
+ import type { Rspack } from '@rsbuild/core';
4
+ type Compiler = Rspack.Compiler;
3
5
  export declare const processScriptPlaceholders: (html: string, nonce?: string) => string;
4
6
  export declare const getDocumentByEntryName: (entrypoints: Entrypoint[], entryName: string, fallbackDir?: string) => string | undefined;
7
+ export declare const applyExternalsPlugin: (child: Compiler, compiler: Compiler) => void;
5
8
  export declare const getDocumentTempEntry: (internalDirectory: string, compilerName: string | undefined, entryName: string) => string;
6
9
  export declare const documentPlugin: () => CliPlugin<AppTools>;
7
10
  export default documentPlugin;
package/package.json CHANGED
@@ -17,7 +17,7 @@
17
17
  "modern",
18
18
  "modern.js"
19
19
  ],
20
- "version": "3.9.3-ultramodern.13",
20
+ "version": "3.9.3-ultramodern.15",
21
21
  "engines": {
22
22
  "node": ">=20"
23
23
  },
@@ -217,15 +217,15 @@
217
217
  "dependencies": {
218
218
  "@loadable/component": "5.16.7",
219
219
  "@loadable/server": "5.16.7",
220
- "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.3-ultramodern.13",
221
- "@modern-js/plugin-data-loader": "npm:@bleedingdev/modern-js-plugin-data-loader@3.9.3-ultramodern.13",
222
- "@modern-js/render": "npm:@bleedingdev/modern-js-render@3.9.3-ultramodern.13",
223
- "@modern-js/runtime-extensions": "npm:@bleedingdev/modern-js-runtime-extensions@3.9.3-ultramodern.13",
224
- "@modern-js/runtime-renderer-extensions": "npm:@bleedingdev/modern-js-runtime-renderer-extensions@3.9.3-ultramodern.13",
225
- "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.9.3-ultramodern.13",
226
- "@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.9.3-ultramodern.13",
227
- "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.3-ultramodern.13",
228
- "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.3-ultramodern.13",
220
+ "@modern-js/plugin": "npm:@bleedingdev/modern-js-plugin@3.9.3-ultramodern.15",
221
+ "@modern-js/plugin-data-loader": "npm:@bleedingdev/modern-js-plugin-data-loader@3.9.3-ultramodern.15",
222
+ "@modern-js/render": "npm:@bleedingdev/modern-js-render@3.9.3-ultramodern.15",
223
+ "@modern-js/runtime-extensions": "npm:@bleedingdev/modern-js-runtime-extensions@3.9.3-ultramodern.15",
224
+ "@modern-js/runtime-renderer-extensions": "npm:@bleedingdev/modern-js-runtime-renderer-extensions@3.9.3-ultramodern.15",
225
+ "@modern-js/runtime-utils": "npm:@bleedingdev/modern-js-runtime-utils@3.9.3-ultramodern.15",
226
+ "@modern-js/server-core": "npm:@bleedingdev/modern-js-server-core@3.9.3-ultramodern.15",
227
+ "@modern-js/types": "npm:@bleedingdev/modern-js-types@3.9.3-ultramodern.15",
228
+ "@modern-js/utils": "npm:@bleedingdev/modern-js-utils@3.9.3-ultramodern.15",
229
229
  "@rsbuild/plugin-react": "2.1.1",
230
230
  "@rsbuild/plugin-svgr": "2.0.5",
231
231
  "@swc/core": "1.16.18",
@@ -249,7 +249,7 @@
249
249
  "react-dom": "^19.3.1"
250
250
  },
251
251
  "devDependencies": {
252
- "@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.9.3-ultramodern.13",
252
+ "@modern-js/app-tools": "npm:@bleedingdev/modern-js-app-tools@3.9.3-ultramodern.15",
253
253
  "@remix-run/web-fetch": "^4.4.2",
254
254
  "@rsbuild/core": "2.2.13",
255
255
  "@rslib/core": "1.0.3",