@modern-js/runtime 2.63.2 → 2.63.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.
- package/dist/cjs/cli/code.js +2 -2
- package/dist/cjs/cli/index.js +102 -108
- package/dist/cjs/cli/ssr/index.js +49 -52
- package/dist/cjs/core/server/string/loadable.js +13 -3
- package/dist/cjs/document/cli/index.js +32 -34
- package/dist/cjs/router/cli/code/index.js +5 -5
- package/dist/cjs/router/cli/handler.js +6 -6
- package/dist/cjs/router/cli/index.js +76 -78
- package/dist/cjs/router/runtime/plugin.js +1 -4
- package/dist/cjs/state/cli/index.js +22 -24
- package/dist/esm/cli/code.js +3 -3
- package/dist/esm/cli/index.js +120 -130
- package/dist/esm/cli/ssr/index.js +50 -53
- package/dist/esm/core/server/string/loadable.js +17 -5
- package/dist/esm/document/cli/index.js +28 -30
- package/dist/esm/router/cli/code/index.js +8 -8
- package/dist/esm/router/cli/handler.js +6 -6
- package/dist/esm/router/cli/index.js +161 -157
- package/dist/esm/router/runtime/plugin.js +1 -4
- package/dist/esm/state/cli/index.js +23 -25
- package/dist/esm-node/cli/code.js +2 -2
- package/dist/esm-node/cli/index.js +102 -108
- package/dist/esm-node/cli/ssr/index.js +49 -52
- package/dist/esm-node/core/server/string/loadable.js +13 -3
- package/dist/esm-node/document/cli/index.js +32 -34
- package/dist/esm-node/router/cli/code/index.js +5 -5
- package/dist/esm-node/router/cli/handler.js +6 -6
- package/dist/esm-node/router/cli/index.js +76 -78
- package/dist/esm-node/router/runtime/plugin.js +1 -4
- package/dist/esm-node/state/cli/index.js +22 -24
- package/dist/types/cli/code.d.ts +2 -9
- package/dist/types/cli/index.d.ts +3 -3
- package/dist/types/cli/ssr/index.d.ts +2 -2
- package/dist/types/core/server/string/loadable.d.ts +3 -2
- package/dist/types/document/cli/index.d.ts +2 -2
- package/dist/types/router/cli/code/index.d.ts +3 -3
- package/dist/types/router/cli/code/templates.d.ts +2 -2
- package/dist/types/router/cli/handler.d.ts +4 -4
- package/dist/types/router/cli/index.d.ts +2 -2
- package/dist/types/router/runtime/types.d.ts +0 -10
- package/dist/types/state/cli/index.d.ts +2 -2
- package/package.json +11 -11
|
@@ -50,87 +50,85 @@ const routerPlugin = () => ({
|
|
|
50
50
|
setup: (api) => {
|
|
51
51
|
const nestedRoutes = {};
|
|
52
52
|
const nestedRoutesForServer = {};
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
serverBase
|
|
69
|
-
}
|
|
70
|
-
});
|
|
71
|
-
}
|
|
72
|
-
return {
|
|
73
|
-
entrypoint,
|
|
74
|
-
plugins
|
|
75
|
-
};
|
|
76
|
-
},
|
|
77
|
-
checkEntryPoint({ path: path2, entry }) {
|
|
78
|
-
return {
|
|
79
|
-
path: path2,
|
|
80
|
-
entry: entry || (0, import_entry.isRouteEntry)(path2)
|
|
81
|
-
};
|
|
82
|
-
},
|
|
83
|
-
config() {
|
|
84
|
-
return {
|
|
85
|
-
source: {
|
|
86
|
-
include: [
|
|
87
|
-
// react-router v6 is no longer support ie 11
|
|
88
|
-
// so we need to compile these packages to ensure the compatibility
|
|
89
|
-
// https://github.com/remix-run/react-router/commit/f6df0697e1b2064a2b3a12e8b39577326fdd945b
|
|
90
|
-
/node_modules\/react-router/,
|
|
91
|
-
/node_modules\/react-router-dom/,
|
|
92
|
-
/node_modules\/@remix-run\/router/
|
|
93
|
-
]
|
|
53
|
+
api._internalRuntimePlugins(({ entrypoint, plugins }) => {
|
|
54
|
+
var _getEntryOptions;
|
|
55
|
+
const { packageName, serverRoutes, metaName } = api.getAppContext();
|
|
56
|
+
const serverBase = serverRoutes.filter((route) => route.entryName === entrypoint.entryName).map((route) => route.urlPath).sort((a, b) => a.length - b.length > 0 ? -1 : 1);
|
|
57
|
+
const userConfig = api.getNormalizedConfig();
|
|
58
|
+
const routerConfig = (_getEntryOptions = (0, import_utils.getEntryOptions)(entrypoint.entryName, entrypoint.isMainEntry, userConfig.runtime, userConfig.runtimeByEntries, packageName)) === null || _getEntryOptions === void 0 ? void 0 : _getEntryOptions.router;
|
|
59
|
+
if (routerConfig && !(0, import_utils.isRouterV5)(userConfig)) {
|
|
60
|
+
plugins.push({
|
|
61
|
+
name: "router",
|
|
62
|
+
path: `@${metaName}/runtime/router`,
|
|
63
|
+
config: typeof routerConfig === "boolean" ? {
|
|
64
|
+
serverBase
|
|
65
|
+
} : {
|
|
66
|
+
...routerConfig,
|
|
67
|
+
serverBase
|
|
94
68
|
}
|
|
95
|
-
};
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
return {
|
|
72
|
+
entrypoint,
|
|
73
|
+
plugins
|
|
74
|
+
};
|
|
75
|
+
});
|
|
76
|
+
api.checkEntryPoint(({ path: path2, entry }) => {
|
|
77
|
+
return {
|
|
78
|
+
path: path2,
|
|
79
|
+
entry: entry || (0, import_entry.isRouteEntry)(path2)
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
api.config(() => {
|
|
83
|
+
return {
|
|
84
|
+
source: {
|
|
85
|
+
include: [
|
|
86
|
+
// react-router v6 is no longer support ie 11
|
|
87
|
+
// so we need to compile these packages to ensure the compatibility
|
|
88
|
+
// https://github.com/remix-run/react-router/commit/f6df0697e1b2064a2b3a12e8b39577326fdd945b
|
|
89
|
+
/node_modules\/react-router/,
|
|
90
|
+
/node_modules\/react-router-dom/,
|
|
91
|
+
/node_modules\/@remix-run\/router/
|
|
92
|
+
]
|
|
112
93
|
}
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
code
|
|
131
|
-
};
|
|
94
|
+
};
|
|
95
|
+
});
|
|
96
|
+
api.modifyEntrypoints(async ({ entrypoints }) => {
|
|
97
|
+
const newEntryPoints = await (0, import_handler.handleModifyEntrypoints)(api, entrypoints);
|
|
98
|
+
return {
|
|
99
|
+
entrypoints: newEntryPoints
|
|
100
|
+
};
|
|
101
|
+
});
|
|
102
|
+
api.generateEntryCode(async ({ entrypoints }) => {
|
|
103
|
+
await (0, import_handler.handleGeneratorEntryCode)(api, entrypoints);
|
|
104
|
+
});
|
|
105
|
+
api.addRuntimeExports(() => {
|
|
106
|
+
const userConfig = api.useResolvedConfigContext();
|
|
107
|
+
const { internalDirectory, metaName } = api.useAppContext();
|
|
108
|
+
const pluginsExportsUtils = (0, import_utils.createRuntimeExportsUtils)(internalDirectory, "plugins");
|
|
109
|
+
if (!(0, import_utils.isRouterV5)(userConfig)) {
|
|
110
|
+
pluginsExportsUtils.addExport(`export { default as router } from '@${metaName}/runtime/router'`);
|
|
132
111
|
}
|
|
133
|
-
};
|
|
112
|
+
});
|
|
113
|
+
api.onFileChanged(async (e) => {
|
|
114
|
+
await (0, import_handler.handleFileChange)(api, e);
|
|
115
|
+
});
|
|
116
|
+
api.modifyFileSystemRoutes(({ entrypoint, routes }) => {
|
|
117
|
+
nestedRoutes[entrypoint.entryName] = routes;
|
|
118
|
+
nestedRoutesForServer[entrypoint.entryName] = (0, import_utils2.filterRoutesForServer)(routes);
|
|
119
|
+
return {
|
|
120
|
+
entrypoint,
|
|
121
|
+
routes
|
|
122
|
+
};
|
|
123
|
+
});
|
|
124
|
+
api.onBeforeGenerateRoutes(async ({ entrypoint, code }) => {
|
|
125
|
+
const { distDirectory } = api.getAppContext();
|
|
126
|
+
await import_utils.fs.outputJSON(import_node_path.default.resolve(distDirectory, import_utils.NESTED_ROUTE_SPEC_FILE), nestedRoutesForServer);
|
|
127
|
+
return {
|
|
128
|
+
entrypoint,
|
|
129
|
+
code
|
|
130
|
+
};
|
|
131
|
+
});
|
|
134
132
|
}
|
|
135
133
|
});
|
|
136
134
|
var cli_default = routerPlugin;
|
|
@@ -26,7 +26,6 @@ __export(plugin_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(plugin_exports);
|
|
27
27
|
var import_jsx_runtime = require("react/jsx-runtime");
|
|
28
28
|
var import_merge = require("@modern-js/runtime-utils/merge");
|
|
29
|
-
var import_parsed = require("@modern-js/runtime-utils/parsed");
|
|
30
29
|
var import_router = require("@modern-js/runtime-utils/router");
|
|
31
30
|
var import_react = require("react");
|
|
32
31
|
var import_core = require("../../core");
|
|
@@ -54,7 +53,6 @@ const routerPlugin = (userConfig = {}) => {
|
|
|
54
53
|
},
|
|
55
54
|
setup: (api) => {
|
|
56
55
|
let routes = [];
|
|
57
|
-
window._SERVER_DATA = (0, import_parsed.parsedJSONFromElement)("__MODERN_SERVER_DATA__");
|
|
58
56
|
return {
|
|
59
57
|
beforeRender(context) {
|
|
60
58
|
context.router = {
|
|
@@ -82,9 +80,8 @@ const routerPlugin = (userConfig = {}) => {
|
|
|
82
80
|
}
|
|
83
81
|
const getRouteApp = () => {
|
|
84
82
|
const useCreateRouter = (props) => {
|
|
85
|
-
var _window__SERVER_DATA;
|
|
86
83
|
const runtimeContext = (0, import_react.useContext)(import_core.RuntimeReactContext);
|
|
87
|
-
const baseUrl =
|
|
84
|
+
const baseUrl = select(location.pathname).replace(/^\/*/, "/");
|
|
88
85
|
const _basename = baseUrl === "/" ? (0, import_utils.urlJoin)(baseUrl, runtimeContext._internalRouterBaseName || basename) : baseUrl;
|
|
89
86
|
let hydrationData = window._ROUTER_DATA;
|
|
90
87
|
const { unstable_getBlockNavState: getBlockNavState } = runtimeContext;
|
|
@@ -30,31 +30,29 @@ const statePlugin = () => ({
|
|
|
30
30
|
"@modern-js/runtime"
|
|
31
31
|
],
|
|
32
32
|
setup: (api) => {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
});
|
|
46
|
-
}
|
|
47
|
-
return {
|
|
48
|
-
entrypoint,
|
|
49
|
-
plugins
|
|
50
|
-
};
|
|
51
|
-
},
|
|
52
|
-
addRuntimeExports() {
|
|
53
|
-
const { internalDirectory, metaName } = api.useAppContext();
|
|
54
|
-
const pluginsExportsUtils = (0, import_utils.createRuntimeExportsUtils)(internalDirectory, "plugins");
|
|
55
|
-
pluginsExportsUtils.addExport(`export { default as state } from '@${metaName}/runtime/model'`);
|
|
33
|
+
api._internalRuntimePlugins(({ entrypoint, plugins }) => {
|
|
34
|
+
var _getEntryOptions;
|
|
35
|
+
const { entryName, isMainEntry } = entrypoint;
|
|
36
|
+
const userConfig = api.useResolvedConfigContext();
|
|
37
|
+
const { packageName, metaName } = api.useAppContext();
|
|
38
|
+
const stateConfig = (_getEntryOptions = (0, import_utils.getEntryOptions)(entryName, isMainEntry, userConfig.runtime, userConfig.runtimeByEntries, packageName)) === null || _getEntryOptions === void 0 ? void 0 : _getEntryOptions.state;
|
|
39
|
+
if (stateConfig) {
|
|
40
|
+
plugins.push({
|
|
41
|
+
name: PLUGIN_IDENTIFIER,
|
|
42
|
+
path: `@${metaName}/runtime/model`,
|
|
43
|
+
config: typeof stateConfig === "boolean" ? {} : stateConfig
|
|
44
|
+
});
|
|
56
45
|
}
|
|
57
|
-
|
|
46
|
+
return {
|
|
47
|
+
entrypoint,
|
|
48
|
+
plugins
|
|
49
|
+
};
|
|
50
|
+
});
|
|
51
|
+
api.addRuntimeExports(() => {
|
|
52
|
+
const { internalDirectory, metaName } = api.useAppContext();
|
|
53
|
+
const pluginsExportsUtils = (0, import_utils.createRuntimeExportsUtils)(internalDirectory, "plugins");
|
|
54
|
+
pluginsExportsUtils.addExport(`export { default as state } from '@${metaName}/runtime/model'`);
|
|
55
|
+
});
|
|
58
56
|
}
|
|
59
57
|
});
|
|
60
58
|
var cli_default = statePlugin;
|
package/dist/esm/cli/code.js
CHANGED
|
@@ -22,7 +22,7 @@ function getSSRMode(entry, config) {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
var generateCode = function() {
|
|
25
|
-
var _ref = _async_to_generator(function(entrypoints, appContext, config,
|
|
25
|
+
var _ref = _async_to_generator(function(entrypoints, appContext, config, hooks) {
|
|
26
26
|
var mountId, enableAsyncEntry, runtimeConfigFile, internalDirectory, internalSrcAlias, metaName, srcDirectory;
|
|
27
27
|
return _ts_generator(this, function(_state) {
|
|
28
28
|
switch (_state.label) {
|
|
@@ -41,7 +41,7 @@ var generateCode = function() {
|
|
|
41
41
|
entryName = entrypoint.entryName, isAutoMount = entrypoint.isAutoMount, entry = entrypoint.entry, customEntry = entrypoint.customEntry, customBootstrap = entrypoint.customBootstrap, customServerEntry = entrypoint.customServerEntry;
|
|
42
42
|
return [
|
|
43
43
|
4,
|
|
44
|
-
|
|
44
|
+
hooks._internalRuntimePlugins.call({
|
|
45
45
|
entrypoint,
|
|
46
46
|
plugins: []
|
|
47
47
|
})
|
|
@@ -125,7 +125,7 @@ var generateCode = function() {
|
|
|
125
125
|
}
|
|
126
126
|
});
|
|
127
127
|
});
|
|
128
|
-
return function generateCode2(entrypoints, appContext, config,
|
|
128
|
+
return function generateCode2(entrypoints, appContext, config, hooks) {
|
|
129
129
|
return _ref.apply(this, arguments);
|
|
130
130
|
};
|
|
131
131
|
}();
|
package/dist/esm/cli/index.js
CHANGED
|
@@ -30,143 +30,133 @@ var runtimePlugin = function(params) {
|
|
|
30
30
|
documentPlugin()
|
|
31
31
|
],
|
|
32
32
|
setup: function(api) {
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
33
|
+
api.checkEntryPoint(function(param) {
|
|
34
|
+
var path2 = param.path, entry = param.entry;
|
|
35
|
+
return {
|
|
36
|
+
path: path2,
|
|
37
|
+
entry: entry || isRuntimeEntry(path2)
|
|
38
|
+
};
|
|
39
|
+
});
|
|
40
|
+
api.modifyEntrypoints(function(param) {
|
|
41
|
+
var entrypoints = param.entrypoints;
|
|
42
|
+
var internalDirectory = api.getAppContext().internalDirectory;
|
|
43
|
+
var _api_getNormalizedConfig = api.getNormalizedConfig(), enableAsyncEntry = _api_getNormalizedConfig.source.enableAsyncEntry;
|
|
44
|
+
var newEntryPoints = entrypoints.map(function(entrypoint) {
|
|
45
|
+
if (entrypoint.isAutoMount) {
|
|
46
|
+
entrypoint.internalEntry = path.resolve(internalDirectory, "./".concat(entrypoint.entryName, "/").concat(enableAsyncEntry ? ENTRY_BOOTSTRAP_FILE_NAME : ENTRY_POINT_FILE_NAME));
|
|
47
|
+
}
|
|
48
|
+
return entrypoint;
|
|
49
|
+
});
|
|
50
|
+
return {
|
|
51
|
+
entrypoints: newEntryPoints
|
|
52
|
+
};
|
|
53
|
+
});
|
|
54
|
+
api.generateEntryCode(function() {
|
|
55
|
+
var _ref = _async_to_generator(function(param) {
|
|
56
|
+
var entrypoints, appContext, resolvedConfig, hooks;
|
|
57
|
+
return _ts_generator(this, function(_state) {
|
|
58
|
+
switch (_state.label) {
|
|
59
|
+
case 0:
|
|
60
|
+
entrypoints = param.entrypoints;
|
|
61
|
+
appContext = api.getAppContext();
|
|
62
|
+
resolvedConfig = api.getNormalizedConfig();
|
|
63
|
+
hooks = api.getHooks();
|
|
64
|
+
return [
|
|
65
|
+
4,
|
|
66
|
+
generateCode(entrypoints, appContext, resolvedConfig, hooks)
|
|
67
|
+
];
|
|
68
|
+
case 1:
|
|
69
|
+
_state.sent();
|
|
70
|
+
return [
|
|
71
|
+
2
|
|
72
|
+
];
|
|
48
73
|
}
|
|
49
|
-
return entrypoint;
|
|
50
74
|
});
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
*/
|
|
82
|
-
prepare: function prepare() {
|
|
83
|
-
var _api_useAppContext = api.useAppContext(), builder = _api_useAppContext.builder, entrypoints = _api_useAppContext.entrypoints, internalDirectory = _api_useAppContext.internalDirectory, metaName = _api_useAppContext.metaName;
|
|
84
|
-
builder === null || builder === void 0 ? void 0 : builder.addPlugins([
|
|
85
|
-
builderPluginAlias({
|
|
86
|
-
entrypoints,
|
|
87
|
-
internalDirectory,
|
|
88
|
-
metaName
|
|
89
|
-
})
|
|
90
|
-
]);
|
|
91
|
-
},
|
|
92
|
-
config: function config() {
|
|
93
|
-
var _api_useAppContext = api.useAppContext(), appDirectory = _api_useAppContext.appDirectory, metaName = _api_useAppContext.metaName, internalDirectory = _api_useAppContext.internalDirectory;
|
|
94
|
-
var isReact18 = checkIsReact18(appDirectory);
|
|
95
|
-
process.env.IS_REACT18 = isReact18.toString();
|
|
96
|
-
var pluginsExportsUtils = createRuntimeExportsUtils(internalDirectory, "plugins");
|
|
97
|
-
var _obj;
|
|
98
|
-
return {
|
|
99
|
-
runtime: {},
|
|
100
|
-
runtimeByEntries: {},
|
|
101
|
-
source: {
|
|
102
|
-
alias: (_obj = {
|
|
103
|
-
/**
|
|
104
|
-
* twin.macro inserts styled-components into the code during the compilation process
|
|
105
|
-
* But it will not be installed under the user project.
|
|
106
|
-
* So need to add alias
|
|
107
|
-
*/
|
|
108
|
-
"styled-components": require.resolve("styled-components")
|
|
109
|
-
}, /**
|
|
110
|
-
* Compatible with the reference path of the old version of the plugin.
|
|
75
|
+
});
|
|
76
|
+
return function(_) {
|
|
77
|
+
return _ref.apply(this, arguments);
|
|
78
|
+
};
|
|
79
|
+
}());
|
|
80
|
+
api.onPrepare(function() {
|
|
81
|
+
var _api_getAppContext = api.getAppContext(), builder = _api_getAppContext.builder, entrypoints = _api_getAppContext.entrypoints, internalDirectory = _api_getAppContext.internalDirectory, metaName = _api_getAppContext.metaName;
|
|
82
|
+
builder === null || builder === void 0 ? void 0 : builder.addPlugins([
|
|
83
|
+
builderPluginAlias({
|
|
84
|
+
entrypoints,
|
|
85
|
+
internalDirectory,
|
|
86
|
+
metaName
|
|
87
|
+
})
|
|
88
|
+
]);
|
|
89
|
+
});
|
|
90
|
+
api.config(function() {
|
|
91
|
+
var _api_getAppContext = api.getAppContext(), appDirectory = _api_getAppContext.appDirectory, metaName = _api_getAppContext.metaName, internalDirectory = _api_getAppContext.internalDirectory;
|
|
92
|
+
var isReact18 = checkIsReact18(appDirectory);
|
|
93
|
+
process.env.IS_REACT18 = isReact18.toString();
|
|
94
|
+
var pluginsExportsUtils = createRuntimeExportsUtils(internalDirectory, "plugins");
|
|
95
|
+
var _obj;
|
|
96
|
+
return {
|
|
97
|
+
runtime: {},
|
|
98
|
+
runtimeByEntries: {},
|
|
99
|
+
source: {
|
|
100
|
+
alias: (_obj = {
|
|
101
|
+
/**
|
|
102
|
+
* twin.macro inserts styled-components into the code during the compilation process
|
|
103
|
+
* But it will not be installed under the user project.
|
|
104
|
+
* So need to add alias
|
|
111
105
|
*/
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
106
|
+
"styled-components": require.resolve("styled-components")
|
|
107
|
+
}, /**
|
|
108
|
+
* Compatible with the reference path of the old version of the plugin.
|
|
109
|
+
*/
|
|
110
|
+
_define_property(_obj, "@".concat(metaName, "/runtime/plugins"), pluginsExportsUtils.getPath()), _define_property(_obj, "@meta/runtime/browser$", require.resolve("@modern-js/runtime/browser")), _define_property(_obj, "@meta/runtime/react$", require.resolve("@modern-js/runtime/react")), _define_property(_obj, "@meta/runtime/context$", require.resolve("@modern-js/runtime/context")), _define_property(_obj, "@meta/runtime$", require.resolve("@modern-js/runtime")), _obj),
|
|
111
|
+
globalVars: {
|
|
112
|
+
"process.env.IS_REACT18": process.env.IS_REACT18
|
|
113
|
+
}
|
|
114
|
+
},
|
|
115
|
+
tools: {
|
|
116
|
+
styledComponents: {
|
|
117
|
+
// https://github.com/styled-components/babel-plugin-styled-components/issues/287
|
|
118
|
+
topLevelImportPaths: [
|
|
119
|
+
"@modern-js/runtime/styled"
|
|
120
|
+
]
|
|
121
|
+
},
|
|
122
|
+
bundlerChain: function(chain) {
|
|
123
|
+
chain.module.rule("modern-entry").test(/\.jsx?$/).include.add(path.resolve(appDirectory, "node_modules", ".".concat(metaName))).end().sideEffects(true);
|
|
124
|
+
},
|
|
125
|
+
/**
|
|
126
|
+
* Add IgnorePlugin to fix react-dom/client import error when use react17
|
|
127
|
+
*/
|
|
128
|
+
webpackChain: function(chain, param) {
|
|
129
|
+
var webpack = param.webpack;
|
|
130
|
+
if (!isReact18) {
|
|
131
|
+
chain.plugin("ignore-plugin").use(webpack.IgnorePlugin, [
|
|
132
|
+
{
|
|
133
|
+
resourceRegExp: /^react-dom\/client$/,
|
|
134
|
+
contextRegExp: /./
|
|
135
|
+
}
|
|
136
|
+
]);
|
|
115
137
|
}
|
|
116
138
|
},
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
},
|
|
127
|
-
/**
|
|
128
|
-
* Add IgnorePlugin to fix react-dom/client import error when use react17
|
|
129
|
-
*/
|
|
130
|
-
webpackChain: function(chain, param) {
|
|
131
|
-
var webpack = param.webpack;
|
|
132
|
-
if (!isReact18) {
|
|
133
|
-
chain.plugin("ignore-plugin").use(webpack.IgnorePlugin, [
|
|
134
|
-
{
|
|
135
|
-
resourceRegExp: /^react-dom\/client$/,
|
|
136
|
-
contextRegExp: /./
|
|
137
|
-
}
|
|
138
|
-
]);
|
|
139
|
-
}
|
|
140
|
-
},
|
|
141
|
-
rspack: function(_config, param) {
|
|
142
|
-
var appendPlugins = param.appendPlugins, rspack = param.rspack;
|
|
143
|
-
if (!isReact18) {
|
|
144
|
-
appendPlugins([
|
|
145
|
-
new rspack.IgnorePlugin({
|
|
146
|
-
resourceRegExp: /^react-dom\/client$/,
|
|
147
|
-
contextRegExp: /./
|
|
148
|
-
})
|
|
149
|
-
]);
|
|
150
|
-
}
|
|
139
|
+
rspack: function(_config, param) {
|
|
140
|
+
var appendPlugins = param.appendPlugins, rspack = param.rspack;
|
|
141
|
+
if (!isReact18) {
|
|
142
|
+
appendPlugins([
|
|
143
|
+
new rspack.IgnorePlugin({
|
|
144
|
+
resourceRegExp: /^react-dom\/client$/,
|
|
145
|
+
contextRegExp: /./
|
|
146
|
+
})
|
|
147
|
+
]);
|
|
151
148
|
}
|
|
152
149
|
}
|
|
153
|
-
}
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
return [
|
|
164
|
-
2
|
|
165
|
-
];
|
|
166
|
-
});
|
|
167
|
-
})();
|
|
168
|
-
}
|
|
169
|
-
};
|
|
150
|
+
}
|
|
151
|
+
};
|
|
152
|
+
});
|
|
153
|
+
api.onBeforeRestart(function() {
|
|
154
|
+
cleanRequireCache([
|
|
155
|
+
require.resolve("../state/cli"),
|
|
156
|
+
require.resolve("../router/cli"),
|
|
157
|
+
require.resolve("./ssr")
|
|
158
|
+
]);
|
|
159
|
+
});
|
|
170
160
|
}
|
|
171
161
|
};
|
|
172
162
|
};
|