@modern-js/runtime 2.17.1 → 2.18.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 +13 -0
- package/README.md +6 -0
- package/dist/cjs/ssr/cli/index.js +28 -13
- package/dist/cjs/ssr/cli/loadable-bundler-plugin.js +112 -0
- package/dist/esm/core/compatible.js +13 -13
- package/dist/esm/core/loader/loaderManager.js +7 -7
- package/dist/esm/core/loader/useLoader.js +2 -2
- package/dist/esm/core/plugin.js +6 -6
- package/dist/esm/document/Html.js +5 -5
- package/dist/esm/document/cli/index.js +6 -6
- package/dist/esm/document/constants.js +1 -1
- package/dist/esm/router/cli/index.js +6 -6
- package/dist/esm/router/runtime/DeferredDataScripts.node.js +3 -3
- package/dist/esm/router/runtime/PrefetchLink.js +7 -7
- package/dist/esm/router/runtime/plugin.js +9 -9
- package/dist/esm/router/runtime/plugin.node.js +7 -7
- package/dist/esm/router/runtime/utils.js +6 -6
- package/dist/esm/router/runtime/withRouter.js +4 -4
- package/dist/esm/ssr/cli/index.js +35 -20
- package/dist/esm/ssr/cli/loadable-bundler-plugin.js +209 -0
- package/dist/esm/ssr/index.js +13 -13
- package/dist/esm/ssr/index.node.js +9 -9
- package/dist/esm/ssr/prefetch.js +3 -3
- package/dist/esm/ssr/react/prerender/index.js +1 -1
- package/dist/esm/ssr/serverRender/renderToStream/buildTemplate.after.js +3 -3
- package/dist/esm/ssr/serverRender/renderToStream/loadable.js +1 -1
- package/dist/esm/ssr/serverRender/renderToStream/renderToPipe.js +1 -1
- package/dist/esm/ssr/serverRender/renderToStream/renderToPipe.worker.js +1 -1
- package/dist/esm/ssr/serverRender/renderToStream/template.js +2 -2
- package/dist/esm/ssr/serverRender/renderToString/entry.js +3 -3
- package/dist/esm/ssr/serverRender/renderToString/index.js +2 -2
- package/dist/esm/ssr/serverRender/renderToString/loadable.js +1 -1
- package/dist/esm/ssr/serverRender/renderToString/template.js +1 -1
- package/dist/esm/ssr/utils.js +4 -4
- package/dist/esm/state/cli/index.js +4 -4
- package/dist/esm/state/runtime/plugin.js +7 -7
- package/dist/esm-node/ssr/cli/index.js +28 -13
- package/dist/esm-node/ssr/cli/loadable-bundler-plugin.js +103 -0
- package/dist/types/ssr/cli/loadable-bundler-plugin.d.ts +10 -0
- package/package.json +9 -9
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,18 @@
|
|
|
1
1
|
# @modern-js/runtime
|
|
2
2
|
|
|
3
|
+
## 2.18.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 7de6599: feat: rspack-provider support modern.js ssr mode
|
|
8
|
+
feat: rspack-provider 支持 modern.js ssr 模式
|
|
9
|
+
|
|
10
|
+
### Patch Changes
|
|
11
|
+
|
|
12
|
+
- @modern-js/plugin@2.18.0
|
|
13
|
+
- @modern-js/types@2.18.0
|
|
14
|
+
- @modern-js/utils@2.18.0
|
|
15
|
+
|
|
3
16
|
## 2.17.1
|
|
4
17
|
|
|
5
18
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -24,3 +24,9 @@ Please read the [Contributing Guide](https://github.com/web-infra-dev/modern.js/
|
|
|
24
24
|
## License
|
|
25
25
|
|
|
26
26
|
Modern.js is [MIT licensed](https://github.com/web-infra-dev/modern.js/blob/main/LICENSE).
|
|
27
|
+
|
|
28
|
+
## Credist
|
|
29
|
+
|
|
30
|
+
Thanks to:
|
|
31
|
+
|
|
32
|
+
- [@loadable/webpack-plugin](https://github.com/gregberge/loadable-components) to create a webpack plugin prepare for loadable usage in ssr.
|
|
@@ -42,16 +42,31 @@ const _default = () => {
|
|
|
42
42
|
config() {
|
|
43
43
|
const appContext = api.useAppContext();
|
|
44
44
|
pluginsExportsUtils = (0, _utils.createRuntimeExportsUtils)(appContext.internalDirectory, "plugins");
|
|
45
|
+
const userConfig = api.useResolvedConfigContext();
|
|
45
46
|
const { bundlerType = "webpack" } = api.useAppContext();
|
|
46
|
-
const babelConfig =
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
47
|
+
const babelConfig = (() => {
|
|
48
|
+
if (bundlerType === "webpack") {
|
|
49
|
+
return (config) => {
|
|
50
|
+
var _config_plugins;
|
|
51
|
+
(_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(_path.default.join(__dirname, "./babel-plugin-ssr-loader-id"));
|
|
52
|
+
if ((0, _utils.isUseSSRBundle)(userConfig) && hasStringSSREntry(userConfig)) {
|
|
53
|
+
var _config_plugins1;
|
|
54
|
+
(_config_plugins1 = config.plugins) === null || _config_plugins1 === void 0 ? void 0 : _config_plugins1.push(require.resolve("@loadable/babel-plugin"));
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
} else if (bundlerType === "rspack") {
|
|
58
|
+
if ((0, _utils.isUseSSRBundle)(userConfig)) {
|
|
59
|
+
return (config) => {
|
|
60
|
+
var _config_plugins;
|
|
61
|
+
(_config_plugins = config.plugins) === null || _config_plugins === void 0 ? void 0 : _config_plugins.push(_path.default.join(__dirname, "./babel-plugin-ssr-loader-id"));
|
|
62
|
+
if (hasStringSSREntry(userConfig)) {
|
|
63
|
+
var _config_plugins1;
|
|
64
|
+
(_config_plugins1 = config.plugins) === null || _config_plugins1 === void 0 ? void 0 : _config_plugins1.push(require.resolve("@loadable/babel-plugin"));
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
}
|
|
53
68
|
}
|
|
54
|
-
}
|
|
69
|
+
})();
|
|
55
70
|
return {
|
|
56
71
|
source: {
|
|
57
72
|
alias: {
|
|
@@ -64,11 +79,11 @@ const _default = () => {
|
|
|
64
79
|
}
|
|
65
80
|
},
|
|
66
81
|
tools: {
|
|
67
|
-
|
|
68
|
-
const
|
|
69
|
-
if ((0, _utils.isUseSSRBundle)(
|
|
70
|
-
const
|
|
71
|
-
chain.plugin(CHAIN_ID.PLUGIN.LOADABLE).use(
|
|
82
|
+
bundlerChain(chain, { isServer, isServiceWorker, CHAIN_ID }) {
|
|
83
|
+
const userConfig2 = api.useResolvedConfigContext();
|
|
84
|
+
if ((0, _utils.isUseSSRBundle)(userConfig2) && !isServer && !isServiceWorker && hasStringSSREntry(userConfig2)) {
|
|
85
|
+
const LoadableBundlerPlugin = require("./loadable-bundler-plugin.js");
|
|
86
|
+
chain.plugin(CHAIN_ID.PLUGIN.LOADABLE).use(LoadableBundlerPlugin, [
|
|
72
87
|
{
|
|
73
88
|
filename: _utils.LOADABLE_STATS_FILE
|
|
74
89
|
}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
const _path = /* @__PURE__ */ _interop_require_default(require("path"));
|
|
6
|
+
const _utils = require("@modern-js/utils");
|
|
7
|
+
function _define_property(obj, key, value) {
|
|
8
|
+
if (key in obj) {
|
|
9
|
+
Object.defineProperty(obj, key, {
|
|
10
|
+
value,
|
|
11
|
+
enumerable: true,
|
|
12
|
+
configurable: true,
|
|
13
|
+
writable: true
|
|
14
|
+
});
|
|
15
|
+
} else {
|
|
16
|
+
obj[key] = value;
|
|
17
|
+
}
|
|
18
|
+
return obj;
|
|
19
|
+
}
|
|
20
|
+
function _interop_require_default(obj) {
|
|
21
|
+
return obj && obj.__esModule ? obj : {
|
|
22
|
+
default: obj
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
class LoadablePlugin {
|
|
26
|
+
apply(compiler) {
|
|
27
|
+
this.compiler = compiler;
|
|
28
|
+
compiler.options.output.chunkLoadingGlobal = this.opts.chunkLoadingGlobal;
|
|
29
|
+
if (this.opts.outputAsset || this.opts.writeToDisk) {
|
|
30
|
+
compiler.hooks.make.tap(LoadablePlugin.name, (compilation) => {
|
|
31
|
+
compilation.hooks.processAssets.tap({
|
|
32
|
+
name: LoadablePlugin.name,
|
|
33
|
+
stage: compiler.webpack.Compilation.PROCESS_ASSETS_STAGE_REPORT
|
|
34
|
+
}, () => {
|
|
35
|
+
const asset = this.handleEmit(compilation);
|
|
36
|
+
if (asset) {
|
|
37
|
+
compilation.emitAsset(this.opts.filename, asset);
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
handleEmit(compilation) {
|
|
44
|
+
const stats = compilation.getStats().toJson({
|
|
45
|
+
all: false,
|
|
46
|
+
assets: true,
|
|
47
|
+
// rspack not support cachedAssets,
|
|
48
|
+
cachedAssets: true,
|
|
49
|
+
chunks: true,
|
|
50
|
+
chunkGroups: true,
|
|
51
|
+
entrypoints: true,
|
|
52
|
+
// rspack not support chunkGroupChildren.
|
|
53
|
+
chunkGroupChildren: true,
|
|
54
|
+
hash: true,
|
|
55
|
+
ids: true,
|
|
56
|
+
outputPath: true,
|
|
57
|
+
publicPath: true
|
|
58
|
+
});
|
|
59
|
+
const output = {
|
|
60
|
+
...stats,
|
|
61
|
+
generator: "loadable-components",
|
|
62
|
+
chunks: [
|
|
63
|
+
...stats.chunks || []
|
|
64
|
+
].map((chunk) => {
|
|
65
|
+
return {
|
|
66
|
+
id: chunk.id,
|
|
67
|
+
files: [
|
|
68
|
+
...chunk.files || []
|
|
69
|
+
]
|
|
70
|
+
};
|
|
71
|
+
})
|
|
72
|
+
};
|
|
73
|
+
const result = JSON.stringify(output, null, 2);
|
|
74
|
+
if (this.opts.writeToDisk) {
|
|
75
|
+
this.writeAssetsFile(result);
|
|
76
|
+
}
|
|
77
|
+
if (this.opts.outputAsset) {
|
|
78
|
+
return {
|
|
79
|
+
source() {
|
|
80
|
+
return result;
|
|
81
|
+
},
|
|
82
|
+
size() {
|
|
83
|
+
return result.length;
|
|
84
|
+
}
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
return null;
|
|
88
|
+
}
|
|
89
|
+
writeAssetsFile(manifest) {
|
|
90
|
+
var _this_compiler;
|
|
91
|
+
const outputFolder = (_this_compiler = this.compiler) === null || _this_compiler === void 0 ? void 0 : _this_compiler.options.output.path;
|
|
92
|
+
const outputFile = _path.default.resolve(outputFolder || "", this.opts.filename);
|
|
93
|
+
_utils.fs.outputFileSync(outputFile, manifest);
|
|
94
|
+
}
|
|
95
|
+
constructor({ filename = "loadable-stats.json", path, writeToDisk, outputAsset = true, chunkLoadingGlobal = "__LOADABLE_LOADED_CHUNKS__" } = {
|
|
96
|
+
filename: "loadable-stats.json",
|
|
97
|
+
outputAsset: true,
|
|
98
|
+
chunkLoadingGlobal: "__LOADABLE_LOADED_CHUNKS__"
|
|
99
|
+
}) {
|
|
100
|
+
_define_property(this, "opts", void 0);
|
|
101
|
+
_define_property(this, "compiler", void 0);
|
|
102
|
+
this.opts = {
|
|
103
|
+
filename,
|
|
104
|
+
path,
|
|
105
|
+
writeToDisk,
|
|
106
|
+
outputAsset,
|
|
107
|
+
chunkLoadingGlobal
|
|
108
|
+
};
|
|
109
|
+
this.compiler = null;
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
module.exports = LoadablePlugin;
|
|
@@ -41,7 +41,7 @@ function _async_to_generator(fn) {
|
|
|
41
41
|
function _define_property(obj, key, value) {
|
|
42
42
|
if (key in obj) {
|
|
43
43
|
Object.defineProperty(obj, key, {
|
|
44
|
-
value,
|
|
44
|
+
value: value,
|
|
45
45
|
enumerable: true,
|
|
46
46
|
configurable: true,
|
|
47
47
|
writable: true
|
|
@@ -245,7 +245,7 @@ var runnerMap = /* @__PURE__ */ new WeakMap();
|
|
|
245
245
|
var getInitialContext = function(runner) {
|
|
246
246
|
return {
|
|
247
247
|
loaderManager: createLoaderManager({}),
|
|
248
|
-
runner,
|
|
248
|
+
runner: runner,
|
|
249
249
|
isBrowser: true,
|
|
250
250
|
routeManifest: typeof window !== "undefined" && window[ROUTE_MANIFEST]
|
|
251
251
|
};
|
|
@@ -262,9 +262,9 @@ export var createApp = function(param) {
|
|
|
262
262
|
var element = /* @__PURE__ */ React.createElement(App || React.Fragment, App ? _object_spread({}, props) : null, App ? props.children : /* @__PURE__ */ React.cloneElement(props.children, _object_spread({}, (_props_children = props.children) === null || _props_children === void 0 ? void 0 : _props_children.props, props)));
|
|
263
263
|
var context = useContext(RuntimeReactContext);
|
|
264
264
|
return runner.provide({
|
|
265
|
-
element,
|
|
265
|
+
element: element,
|
|
266
266
|
props: _object_spread({}, props),
|
|
267
|
-
context
|
|
267
|
+
context: context
|
|
268
268
|
}, {
|
|
269
269
|
onLast: function(param2) {
|
|
270
270
|
var element2 = param2.element;
|
|
@@ -340,7 +340,7 @@ export var bootstrap = function() {
|
|
|
340
340
|
return [
|
|
341
341
|
2,
|
|
342
342
|
/* @__PURE__ */ React.createElement(App, {
|
|
343
|
-
context
|
|
343
|
+
context: context
|
|
344
344
|
})
|
|
345
345
|
];
|
|
346
346
|
}
|
|
@@ -418,15 +418,15 @@ export var bootstrap = function() {
|
|
|
418
418
|
return [
|
|
419
419
|
2,
|
|
420
420
|
runner.client({
|
|
421
|
-
App,
|
|
422
|
-
context,
|
|
423
|
-
ModernRender,
|
|
424
|
-
ModernHydrate
|
|
421
|
+
App: App,
|
|
422
|
+
context: context,
|
|
423
|
+
ModernRender: ModernRender,
|
|
424
|
+
ModernHydrate: ModernHydrate
|
|
425
425
|
}, {
|
|
426
426
|
onLast: function(param) {
|
|
427
427
|
var App2 = param.App;
|
|
428
428
|
ModernRender(/* @__PURE__ */ React.createElement(App2, {
|
|
429
|
-
context
|
|
429
|
+
context: context
|
|
430
430
|
}));
|
|
431
431
|
}
|
|
432
432
|
})
|
|
@@ -476,8 +476,8 @@ export var bootstrap = function() {
|
|
|
476
476
|
return [
|
|
477
477
|
2,
|
|
478
478
|
runner.server({
|
|
479
|
-
App,
|
|
480
|
-
context
|
|
479
|
+
App: App,
|
|
480
|
+
context: context
|
|
481
481
|
})
|
|
482
482
|
];
|
|
483
483
|
}
|
|
@@ -497,7 +497,7 @@ export var useRuntimeContext = function() {
|
|
|
497
497
|
var context = useContext(RuntimeReactContext);
|
|
498
498
|
var memoizedContext = useMemo(function() {
|
|
499
499
|
return context.runner.pickContext({
|
|
500
|
-
context,
|
|
500
|
+
context: context,
|
|
501
501
|
pickedContext: {}
|
|
502
502
|
}, {
|
|
503
503
|
onLast: function(param) {
|
|
@@ -285,7 +285,7 @@ var createLoader = function(id) {
|
|
|
285
285
|
return {
|
|
286
286
|
loading: !hasLoaded && status === LoaderStatus.loading,
|
|
287
287
|
reloading: hasLoaded && status === LoaderStatus.loading,
|
|
288
|
-
data,
|
|
288
|
+
data: data,
|
|
289
289
|
error: _instanceof(error, Error) ? "".concat(error.message) : error,
|
|
290
290
|
// redundant fields for ssr log
|
|
291
291
|
_error: error
|
|
@@ -309,8 +309,8 @@ var createLoader = function(id) {
|
|
|
309
309
|
get promise() {
|
|
310
310
|
return promise;
|
|
311
311
|
},
|
|
312
|
-
onChange,
|
|
313
|
-
load
|
|
312
|
+
onChange: onChange,
|
|
313
|
+
load: load
|
|
314
314
|
};
|
|
315
315
|
};
|
|
316
316
|
export var createLoaderManager = function(initialDataMap) {
|
|
@@ -425,9 +425,9 @@ export var createLoaderManager = function(initialDataMap) {
|
|
|
425
425
|
};
|
|
426
426
|
}();
|
|
427
427
|
return {
|
|
428
|
-
hasPendingLoaders,
|
|
429
|
-
awaitPendingLoaders,
|
|
430
|
-
add,
|
|
431
|
-
get
|
|
428
|
+
hasPendingLoaders: hasPendingLoaders,
|
|
429
|
+
awaitPendingLoaders: awaitPendingLoaders,
|
|
430
|
+
add: add,
|
|
431
|
+
get: get
|
|
432
432
|
};
|
|
433
433
|
};
|
|
@@ -12,7 +12,7 @@ function _array_with_holes(arr) {
|
|
|
12
12
|
function _define_property(obj, key, value) {
|
|
13
13
|
if (key in obj) {
|
|
14
14
|
Object.defineProperty(obj, key, {
|
|
15
|
-
value,
|
|
15
|
+
value: value,
|
|
16
16
|
enumerable: true,
|
|
17
17
|
configurable: true,
|
|
18
18
|
writable: true
|
|
@@ -148,7 +148,7 @@ var useLoader = function(loaderFn) {
|
|
|
148
148
|
return Promise.reject(e);
|
|
149
149
|
}
|
|
150
150
|
}, _object_spread_props(_object_spread({}, options), {
|
|
151
|
-
params
|
|
151
|
+
params: params
|
|
152
152
|
}));
|
|
153
153
|
loaderRef.current = loaderManager.get(id);
|
|
154
154
|
(_unlistenLoaderChangeRef_current = unlistenLoaderChangeRef.current) === null || _unlistenLoaderChangeRef_current === void 0 ? void 0 : _unlistenLoaderChangeRef_current.call(unlistenLoaderChangeRef);
|
package/dist/esm/core/plugin.js
CHANGED
|
@@ -138,12 +138,12 @@ var server = createAsyncPipeline();
|
|
|
138
138
|
var init = createAsyncPipeline();
|
|
139
139
|
var pickContext = createPipeline();
|
|
140
140
|
var runtimeHooks = {
|
|
141
|
-
hoc,
|
|
142
|
-
provide,
|
|
143
|
-
client,
|
|
144
|
-
server,
|
|
145
|
-
init,
|
|
146
|
-
pickContext
|
|
141
|
+
hoc: hoc,
|
|
142
|
+
provide: provide,
|
|
143
|
+
client: client,
|
|
144
|
+
server: server,
|
|
145
|
+
init: init,
|
|
146
|
+
pickContext: pickContext
|
|
147
147
|
};
|
|
148
148
|
export var createRuntime = function() {
|
|
149
149
|
return createManager(runtimeHooks);
|
|
@@ -81,11 +81,11 @@ export function Html(props) {
|
|
|
81
81
|
return /* @__PURE__ */ _jsx("html", {
|
|
82
82
|
children: /* @__PURE__ */ _jsxs(DocumentStructureContext.Provider, {
|
|
83
83
|
value: {
|
|
84
|
-
hasSetHead,
|
|
85
|
-
hasSetScripts,
|
|
86
|
-
hasSetLinks,
|
|
87
|
-
hasSetRoot,
|
|
88
|
-
hasSetBody,
|
|
84
|
+
hasSetHead: hasSetHead,
|
|
85
|
+
hasSetScripts: hasSetScripts,
|
|
86
|
+
hasSetLinks: hasSetLinks,
|
|
87
|
+
hasSetRoot: hasSetRoot,
|
|
88
|
+
hasSetBody: hasSetBody,
|
|
89
89
|
docChild: children
|
|
90
90
|
},
|
|
91
91
|
children: [
|
|
@@ -41,7 +41,7 @@ function _async_to_generator(fn) {
|
|
|
41
41
|
function _define_property(obj, key, value) {
|
|
42
42
|
if (key in obj) {
|
|
43
43
|
Object.defineProperty(obj, key, {
|
|
44
|
-
value,
|
|
44
|
+
value: value,
|
|
45
45
|
enumerable: true,
|
|
46
46
|
configurable: true,
|
|
47
47
|
writable: true
|
|
@@ -233,7 +233,7 @@ export default function() {
|
|
|
233
233
|
config: {
|
|
234
234
|
output: config.output
|
|
235
235
|
},
|
|
236
|
-
entryName,
|
|
236
|
+
entryName: entryName,
|
|
237
237
|
templateParams: templateParameters
|
|
238
238
|
};
|
|
239
239
|
}
|
|
@@ -253,8 +253,8 @@ export default function() {
|
|
|
253
253
|
htmlWebpackPlugin = param.htmlWebpackPlugin;
|
|
254
254
|
documentParams = getDocParams({
|
|
255
255
|
config: api.useResolvedConfigContext(),
|
|
256
|
-
entryName,
|
|
257
|
-
templateParameters
|
|
256
|
+
entryName: entryName,
|
|
257
|
+
templateParameters: templateParameters
|
|
258
258
|
});
|
|
259
259
|
tempTsConfigFile = path.join(internalDirectory, "./document/_tempTsconfig.json");
|
|
260
260
|
userTsConfigFilePath = path.join(appDirectory, "tsconfig.json");
|
|
@@ -322,7 +322,7 @@ export default function() {
|
|
|
322
322
|
}
|
|
323
323
|
return {
|
|
324
324
|
path: args.path,
|
|
325
|
-
external
|
|
325
|
+
external: external
|
|
326
326
|
};
|
|
327
327
|
});
|
|
328
328
|
}
|
|
@@ -398,7 +398,7 @@ export default function() {
|
|
|
398
398
|
hackParameters
|
|
399
399
|
);
|
|
400
400
|
var documentHtmlOptions = templateContent ? {
|
|
401
|
-
templateContent,
|
|
401
|
+
templateContent: templateContent,
|
|
402
402
|
inject: false
|
|
403
403
|
} : {};
|
|
404
404
|
return _object_spread({}, options, documentHtmlOptions);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function _define_property(obj, key, value) {
|
|
2
2
|
if (key in obj) {
|
|
3
3
|
Object.defineProperty(obj, key, {
|
|
4
|
-
value,
|
|
4
|
+
value: value,
|
|
5
5
|
enumerable: true,
|
|
6
6
|
configurable: true,
|
|
7
7
|
writable: true
|
|
@@ -107,8 +107,8 @@ export default function() {
|
|
|
107
107
|
throw new Error("should enable runtime.router for entry ".concat(entryName));
|
|
108
108
|
}
|
|
109
109
|
return {
|
|
110
|
-
entrypoint,
|
|
111
|
-
imports
|
|
110
|
+
entrypoint: entrypoint,
|
|
111
|
+
imports: imports
|
|
112
112
|
};
|
|
113
113
|
},
|
|
114
114
|
modifyEntryRuntimePlugins: function modifyEntryRuntimePlugins(param) {
|
|
@@ -128,15 +128,15 @@ export default function() {
|
|
|
128
128
|
plugins.push({
|
|
129
129
|
name: PLUGIN_IDENTIFIER,
|
|
130
130
|
options: JSON.stringify(_object_spread_props(_object_spread({
|
|
131
|
-
serverBase
|
|
131
|
+
serverBase: serverBase
|
|
132
132
|
}, runtimeConfig.router), {
|
|
133
133
|
routesConfig: fileSystemRoutes ? "{ ".concat(ROUTES_IDENTIFIER, ", globalApp: App }") : void 0
|
|
134
134
|
})).replace(/"routesConfig"\s*:\s*"((\S|\s)+)"/g, '"routesConfig": $1,')
|
|
135
135
|
});
|
|
136
136
|
}
|
|
137
137
|
return {
|
|
138
|
-
entrypoint,
|
|
139
|
-
plugins
|
|
138
|
+
entrypoint: entrypoint,
|
|
139
|
+
plugins: plugins
|
|
140
140
|
};
|
|
141
141
|
},
|
|
142
142
|
addRuntimeExports: function addRuntimeExports() {
|
|
@@ -97,7 +97,7 @@ var DeferredDataScripts = function() {
|
|
|
97
97
|
deferredDataScripts.push(/* @__PURE__ */ _jsx(DeferredDataScript, {
|
|
98
98
|
data: deferredData.data[key],
|
|
99
99
|
dataKey: key,
|
|
100
|
-
routeId
|
|
100
|
+
routeId: routeId
|
|
101
101
|
}, "".concat(routeId, " | ").concat(key)));
|
|
102
102
|
return "".concat(JSON.stringify(key), ": _ROUTER_DATA.s(").concat(JSON.stringify(routeId), ",").concat(JSON.stringify(key), ") ");
|
|
103
103
|
} else {
|
|
@@ -146,8 +146,8 @@ var DeferredDataScript = function(param) {
|
|
|
146
146
|
children: typeof document === "undefined" && data && dataKey && routeId ? /* @__PURE__ */ _jsx(Await, {
|
|
147
147
|
resolve: data,
|
|
148
148
|
errorElement: /* @__PURE__ */ _jsx(ErrorDeferredDataScript, {
|
|
149
|
-
routeId,
|
|
150
|
-
dataKey
|
|
149
|
+
routeId: routeId,
|
|
150
|
+
dataKey: dataKey
|
|
151
151
|
}),
|
|
152
152
|
children: function(data2) {
|
|
153
153
|
return /* @__PURE__ */ _jsx("script", {
|
|
@@ -41,7 +41,7 @@ function _async_to_generator(fn) {
|
|
|
41
41
|
function _define_property(obj, key, value) {
|
|
42
42
|
if (key in obj) {
|
|
43
43
|
Object.defineProperty(obj, key, {
|
|
44
|
-
value,
|
|
44
|
+
value: value,
|
|
45
45
|
enumerable: true,
|
|
46
46
|
configurable: true,
|
|
47
47
|
writable: true
|
|
@@ -380,7 +380,7 @@ var createDataHref = function(href) {
|
|
|
380
380
|
return /* @__PURE__ */ _jsx("link", {
|
|
381
381
|
rel: "prefetch",
|
|
382
382
|
as: "fetch",
|
|
383
|
-
href
|
|
383
|
+
href: href
|
|
384
384
|
}, href);
|
|
385
385
|
};
|
|
386
386
|
var getDataHref = function(route, pathname, basename) {
|
|
@@ -404,9 +404,9 @@ var PrefetchPageLinks = function(param) {
|
|
|
404
404
|
return null;
|
|
405
405
|
}
|
|
406
406
|
return /* @__PURE__ */ _jsx(PrefetchDataLinks, {
|
|
407
|
-
matches,
|
|
408
|
-
pathname,
|
|
409
|
-
routeManifest
|
|
407
|
+
matches: matches,
|
|
408
|
+
pathname: pathname,
|
|
409
|
+
routeManifest: routeManifest
|
|
410
410
|
});
|
|
411
411
|
};
|
|
412
412
|
var PrefetchDataLinks = function(param) {
|
|
@@ -455,10 +455,10 @@ var createPrefetchLink = function(Link2) {
|
|
|
455
455
|
children: [
|
|
456
456
|
/* @__PURE__ */ _jsx(Link2, _object_spread({
|
|
457
457
|
ref: forwardedRef,
|
|
458
|
-
to
|
|
458
|
+
to: to
|
|
459
459
|
}, props, prefetchHandlers)),
|
|
460
460
|
shouldPrefetch && __webpack_chunk_load__ && !isAbsolute ? /* @__PURE__ */ _jsx(PrefetchPageLinks, {
|
|
461
|
-
pathname
|
|
461
|
+
pathname: pathname
|
|
462
462
|
}) : null
|
|
463
463
|
]
|
|
464
464
|
});
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
function _define_property(obj, key, value) {
|
|
2
2
|
if (key in obj) {
|
|
3
3
|
Object.defineProperty(obj, key, {
|
|
4
|
-
value,
|
|
4
|
+
value: value,
|
|
5
5
|
enumerable: true,
|
|
6
6
|
configurable: true,
|
|
7
7
|
writable: true
|
|
@@ -89,8 +89,8 @@ export var routerPlugin = function(param) {
|
|
|
89
89
|
init: function init(param2, next) {
|
|
90
90
|
var context = param2.context;
|
|
91
91
|
context.router = {
|
|
92
|
-
useMatches,
|
|
93
|
-
useLocation
|
|
92
|
+
useMatches: useMatches,
|
|
93
|
+
useLocation: useLocation
|
|
94
94
|
};
|
|
95
95
|
Object.defineProperty(context, "routes", {
|
|
96
96
|
get: function get() {
|
|
@@ -98,14 +98,14 @@ export var routerPlugin = function(param) {
|
|
|
98
98
|
}
|
|
99
99
|
});
|
|
100
100
|
return next({
|
|
101
|
-
context
|
|
101
|
+
context: context
|
|
102
102
|
});
|
|
103
103
|
},
|
|
104
104
|
hoc: function(param2, next) {
|
|
105
105
|
var App = param2.App;
|
|
106
106
|
if (!finalRouteConfig && !createRoutes) {
|
|
107
107
|
return next({
|
|
108
|
-
App
|
|
108
|
+
App: App
|
|
109
109
|
});
|
|
110
110
|
}
|
|
111
111
|
var getRouteApp = function() {
|
|
@@ -114,7 +114,7 @@ export var routerPlugin = function(param) {
|
|
|
114
114
|
beforeCreateRouter = false;
|
|
115
115
|
routes = createRoutes ? createRoutes() : createRoutesFromElements(renderRoutes({
|
|
116
116
|
routesConfig: finalRouteConfig,
|
|
117
|
-
props
|
|
117
|
+
props: props
|
|
118
118
|
}));
|
|
119
119
|
var runner = api.useHookRunners();
|
|
120
120
|
routes = runner.modifyRoutes(routes);
|
|
@@ -128,14 +128,14 @@ export var routerPlugin = function(param) {
|
|
|
128
128
|
}
|
|
129
129
|
var router = supportHtml5History ? createBrowserRouter(routes, {
|
|
130
130
|
basename: _basename,
|
|
131
|
-
hydrationData
|
|
131
|
+
hydrationData: hydrationData
|
|
132
132
|
}) : createHashRouter(routes, {
|
|
133
133
|
basename: _basename,
|
|
134
|
-
hydrationData
|
|
134
|
+
hydrationData: hydrationData
|
|
135
135
|
});
|
|
136
136
|
return /* @__PURE__ */ _jsx(App, _object_spread_props(_object_spread({}, props), {
|
|
137
137
|
children: /* @__PURE__ */ _jsx(RouterProvider, {
|
|
138
|
-
router
|
|
138
|
+
router: router
|
|
139
139
|
})
|
|
140
140
|
}));
|
|
141
141
|
};
|
|
@@ -41,7 +41,7 @@ function _async_to_generator(fn) {
|
|
|
41
41
|
function _define_property(obj, key, value) {
|
|
42
42
|
if (key in obj) {
|
|
43
43
|
Object.defineProperty(obj, key, {
|
|
44
|
-
value,
|
|
44
|
+
value: value,
|
|
45
45
|
enumerable: true,
|
|
46
46
|
configurable: true,
|
|
47
47
|
writable: true
|
|
@@ -337,7 +337,7 @@ export var routerPlugin = function(param) {
|
|
|
337
337
|
return [
|
|
338
338
|
2,
|
|
339
339
|
next({
|
|
340
|
-
context
|
|
340
|
+
context: context
|
|
341
341
|
})
|
|
342
342
|
];
|
|
343
343
|
}
|
|
@@ -345,8 +345,8 @@ export var routerPlugin = function(param) {
|
|
|
345
345
|
baseUrl = request.baseUrl;
|
|
346
346
|
_basename = baseUrl === "/" ? urlJoin(baseUrl, basename) : baseUrl;
|
|
347
347
|
routes = createRoutes ? createRoutes() : createRoutesFromElements(renderRoutes({
|
|
348
|
-
routesConfig,
|
|
349
|
-
ssrMode
|
|
348
|
+
routesConfig: routesConfig,
|
|
349
|
+
ssrMode: ssrMode
|
|
350
350
|
}));
|
|
351
351
|
query = createStaticHandler(routes, {
|
|
352
352
|
basename: _basename
|
|
@@ -374,7 +374,7 @@ export var routerPlugin = function(param) {
|
|
|
374
374
|
return [
|
|
375
375
|
2,
|
|
376
376
|
next({
|
|
377
|
-
context
|
|
377
|
+
context: context
|
|
378
378
|
})
|
|
379
379
|
];
|
|
380
380
|
}
|
|
@@ -385,7 +385,7 @@ export var routerPlugin = function(param) {
|
|
|
385
385
|
var App = param2.App;
|
|
386
386
|
if (!routesConfig) {
|
|
387
387
|
return next({
|
|
388
|
-
App
|
|
388
|
+
App: App
|
|
389
389
|
});
|
|
390
390
|
}
|
|
391
391
|
var getRouteApp = function() {
|
|
@@ -393,7 +393,7 @@ export var routerPlugin = function(param) {
|
|
|
393
393
|
var _useContext = useContext(RuntimeReactContext), router = _useContext.router, routerContext = _useContext.routerContext;
|
|
394
394
|
return /* @__PURE__ */ _jsx(App, _object_spread_props(_object_spread({}, props), {
|
|
395
395
|
children: /* @__PURE__ */ _jsx(StaticRouterProvider, {
|
|
396
|
-
router,
|
|
396
|
+
router: router,
|
|
397
397
|
context: routerContext,
|
|
398
398
|
hydrate: false
|
|
399
399
|
})
|