@unpackjs/plugin-react 1.7.5 → 1.7.6
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/click-to-component/index.cjs +99 -88
- package/dist/click-to-component/index.d.ts.map +1 -1
- package/dist/click-to-component/index.js +55 -70
- package/dist/click-to-component/injectScript.js +103 -121
- package/dist/index.cjs +153 -126
- package/dist/index.js +109 -111
- package/dist/mpa.cjs +144 -138
- package/dist/mpa.js +99 -126
- package/dist/react-compiler-loader/index.cjs +95 -63
- package/dist/react-compiler-loader/index.js +48 -44
- package/dist/splitChunks.cjs +55 -52
- package/dist/splitChunks.js +25 -42
- package/package.json +6 -6
package/dist/mpa.cjs
CHANGED
|
@@ -1,150 +1,156 @@
|
|
|
1
|
-
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
)
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
var __webpack_require__ = {};
|
|
3
|
+
(()=>{
|
|
4
|
+
__webpack_require__.n = function(module) {
|
|
5
|
+
var getter = module && module.__esModule ? function() {
|
|
6
|
+
return module['default'];
|
|
7
|
+
} : function() {
|
|
8
|
+
return module;
|
|
9
|
+
};
|
|
10
|
+
__webpack_require__.d(getter, {
|
|
11
|
+
a: getter
|
|
12
|
+
});
|
|
13
|
+
return getter;
|
|
14
|
+
};
|
|
15
|
+
})();
|
|
16
|
+
(()=>{
|
|
17
|
+
__webpack_require__.d = function(exports1, definition) {
|
|
18
|
+
for(var key in definition)if (__webpack_require__.o(definition, key) && !__webpack_require__.o(exports1, key)) Object.defineProperty(exports1, key, {
|
|
19
|
+
enumerable: true,
|
|
20
|
+
get: definition[key]
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
})();
|
|
24
|
+
(()=>{
|
|
25
|
+
__webpack_require__.o = function(obj, prop) {
|
|
26
|
+
return Object.prototype.hasOwnProperty.call(obj, prop);
|
|
27
|
+
};
|
|
28
|
+
})();
|
|
29
|
+
(()=>{
|
|
30
|
+
__webpack_require__.r = function(exports1) {
|
|
31
|
+
if ('undefined' != typeof Symbol && Symbol.toStringTag) Object.defineProperty(exports1, Symbol.toStringTag, {
|
|
32
|
+
value: 'Module'
|
|
33
|
+
});
|
|
34
|
+
Object.defineProperty(exports1, '__esModule', {
|
|
35
|
+
value: true
|
|
36
|
+
});
|
|
37
|
+
};
|
|
38
|
+
})();
|
|
39
|
+
var __webpack_exports__ = {};
|
|
40
|
+
__webpack_require__.r(__webpack_exports__);
|
|
41
|
+
__webpack_require__.d(__webpack_exports__, {
|
|
42
|
+
applyMpaConfig: ()=>applyMpaConfig
|
|
31
43
|
});
|
|
32
|
-
|
|
33
|
-
var
|
|
34
|
-
|
|
35
|
-
var
|
|
36
|
-
const
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const { layout } = userOptions;
|
|
62
|
-
const layoutImport = layout ? `import Layout from '${(0, import_core.getPathInJs)(import_node_path.default.resolve(unpackConfig.root, layout))}'` : "";
|
|
63
|
-
const layoutJSX = layout ? "<Layout><App /></Layout>" : "<App />";
|
|
64
|
-
const rootElement = `document.getElementById('${unpackConfig.html?.mountId}')`;
|
|
65
|
-
const reactDOMSource = "react-dom/client";
|
|
66
|
-
const renderer = `ReactDOM.createRoot(${rootElement}).render(${layoutJSX})`;
|
|
67
|
-
Object.entries(entry2).forEach(([entryName, entryConfig]) => {
|
|
68
|
-
const filePath = import_node_path.default.join(unpackConfig.root, tempDirectory, `${entryName}.jsx`);
|
|
69
|
-
const tpl = `
|
|
44
|
+
const external_node_fs_namespaceObject = require("node:fs");
|
|
45
|
+
var external_node_fs_default = /*#__PURE__*/ __webpack_require__.n(external_node_fs_namespaceObject);
|
|
46
|
+
const external_node_path_namespaceObject = require("node:path");
|
|
47
|
+
var external_node_path_default = /*#__PURE__*/ __webpack_require__.n(external_node_path_namespaceObject);
|
|
48
|
+
const core_namespaceObject = require("@unpackjs/core");
|
|
49
|
+
const applyMpaConfig = ({ config, unpackConfig, mergeConfig, HtmlPlugin })=>{
|
|
50
|
+
if (!unpackConfig.mpa) return config;
|
|
51
|
+
const isRspack = 'rspack' === unpackConfig.bundler;
|
|
52
|
+
const tempDirectory = external_node_path_default().join(core_namespaceObject.TEMP_DIR, 'mpa');
|
|
53
|
+
const userOptions = (0, core_namespaceObject.isPlainObject)(unpackConfig.mpa) ? unpackConfig.mpa : {};
|
|
54
|
+
const getPageConfig = (indexPath)=>{
|
|
55
|
+
const filePath = external_node_path_default().join(indexPath, '../config.json');
|
|
56
|
+
let pageConfig = {};
|
|
57
|
+
if (external_node_fs_default().existsSync(filePath)) pageConfig = JSON.parse(external_node_fs_default().readFileSync(filePath, 'utf-8'));
|
|
58
|
+
return pageConfig;
|
|
59
|
+
};
|
|
60
|
+
const createTempFile = (entry)=>{
|
|
61
|
+
var _userOptions_globalImport, _unpackConfig_html;
|
|
62
|
+
(0, core_namespaceObject.removeDir)(external_node_path_default().join(unpackConfig.root, tempDirectory));
|
|
63
|
+
const globalImport = (null === (_userOptions_globalImport = userOptions.globalImport) || void 0 === _userOptions_globalImport ? void 0 : _userOptions_globalImport.reduce((acc, curr)=>`${acc}\nimport '${(0, core_namespaceObject.getPathInJs)(external_node_path_default().resolve(unpackConfig.root, curr))}'`, '')) || '';
|
|
64
|
+
const { layout } = userOptions;
|
|
65
|
+
const layoutImport = layout ? `import Layout from '${(0, core_namespaceObject.getPathInJs)(external_node_path_default().resolve(unpackConfig.root, layout))}'` : '';
|
|
66
|
+
const layoutJSX = layout ? '<Layout><App /></Layout>' : '<App />';
|
|
67
|
+
const rootElement = `document.getElementById('${null === (_unpackConfig_html = unpackConfig.html) || void 0 === _unpackConfig_html ? void 0 : _unpackConfig_html.mountId}')`;
|
|
68
|
+
const reactDOMSource = 'react-dom/client';
|
|
69
|
+
const renderer = `ReactDOM.createRoot(${rootElement}).render(${layoutJSX})`;
|
|
70
|
+
Object.entries(entry).forEach(([entryName, entryConfig])=>{
|
|
71
|
+
const filePath = external_node_path_default().join(unpackConfig.root, tempDirectory, `${entryName}.jsx`);
|
|
72
|
+
const tpl = `
|
|
70
73
|
import React from 'react'
|
|
71
74
|
import ReactDOM from '${reactDOMSource}'
|
|
72
|
-
import App from '${(0,
|
|
73
|
-
${layoutImport}`}
|
|
75
|
+
import App from '${(0, core_namespaceObject.getPathInJs)(entryConfig.import[0])}'${layoutImport && `\n${layoutImport}`}
|
|
74
76
|
${globalImport}
|
|
75
77
|
${renderer}
|
|
76
78
|
`;
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
};
|
|
86
|
-
const collectEntry = () => {
|
|
87
|
-
const start = performance.now();
|
|
88
|
-
const entry2 = {};
|
|
89
|
-
const html2 = [];
|
|
90
|
-
const getIndexFilePath = (dir) => {
|
|
91
|
-
const extensions = [".tsx", ".jsx"];
|
|
92
|
-
for (const extension of extensions) {
|
|
93
|
-
const indexFilePath = import_node_path.default.join(dir, `index${extension}`);
|
|
94
|
-
if (import_node_fs.default.existsSync(indexFilePath)) {
|
|
95
|
-
return indexFilePath;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
return null;
|
|
79
|
+
const dir = external_node_path_default().dirname(filePath);
|
|
80
|
+
if (!external_node_fs_default().existsSync(dir)) external_node_fs_default().mkdirSync(dir, {
|
|
81
|
+
recursive: true
|
|
82
|
+
});
|
|
83
|
+
external_node_fs_default().writeFileSync(filePath, tpl, 'utf-8');
|
|
84
|
+
entryConfig.import[0] = filePath;
|
|
85
|
+
});
|
|
86
|
+
return entry;
|
|
99
87
|
};
|
|
100
|
-
const
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
88
|
+
const collectEntry = ()=>{
|
|
89
|
+
const start = performance.now();
|
|
90
|
+
const entry = {};
|
|
91
|
+
const html = [];
|
|
92
|
+
const getIndexFilePath = (dir)=>{
|
|
93
|
+
const extensions = [
|
|
94
|
+
'.tsx',
|
|
95
|
+
'.jsx'
|
|
96
|
+
];
|
|
97
|
+
for (const extension of extensions){
|
|
98
|
+
const indexFilePath = external_node_path_default().join(dir, `index${extension}`);
|
|
99
|
+
if (external_node_fs_default().existsSync(indexFilePath)) return indexFilePath;
|
|
100
|
+
}
|
|
101
|
+
return null;
|
|
113
102
|
};
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
103
|
+
const pagesRoot = external_node_path_default().join(unpackConfig.root, 'src', 'pages');
|
|
104
|
+
external_node_fs_default().readdirSync(pagesRoot).forEach((filename)=>{
|
|
105
|
+
if (filename.startsWith('.')) return;
|
|
106
|
+
const indexFilePath = getIndexFilePath(external_node_path_default().join(pagesRoot, filename));
|
|
107
|
+
if (indexFilePath) {
|
|
108
|
+
var _unpackConfig_html, _unpackConfig_html1, _unpackConfig_html2, _unpackConfig_html3, _unpackConfig_html4, _unpackConfig_html5, _unpackConfig_html6, _unpackConfig_html7, _unpackConfig_html8;
|
|
109
|
+
const pageConfig = getPageConfig(indexFilePath);
|
|
110
|
+
let entryName = true === userOptions.lowerCase ? filename.toLowerCase() : filename;
|
|
111
|
+
if (pageConfig.filename) entryName = pageConfig.filename.slice(0, -5);
|
|
112
|
+
entry[entryName] = {
|
|
113
|
+
import: [
|
|
114
|
+
indexFilePath
|
|
115
|
+
]
|
|
116
|
+
};
|
|
117
|
+
if (pageConfig.template) pageConfig.template = external_node_path_default().join(indexFilePath, '../', pageConfig.template);
|
|
118
|
+
html.push({
|
|
119
|
+
template: (null === (_unpackConfig_html = unpackConfig.html) || void 0 === _unpackConfig_html ? void 0 : _unpackConfig_html.template) || (isRspack ? void 0 : ''),
|
|
120
|
+
templateContent: (null === (_unpackConfig_html1 = unpackConfig.html) || void 0 === _unpackConfig_html1 ? void 0 : _unpackConfig_html1.templateContent) || ((null === (_unpackConfig_html2 = unpackConfig.html) || void 0 === _unpackConfig_html2 ? void 0 : _unpackConfig_html2.template) ? !!isRspack && void 0 : core_namespaceObject.TEMPLATE_CONTENT),
|
|
121
|
+
minify: false,
|
|
122
|
+
filename: `${entryName}.html`,
|
|
123
|
+
chunks: [
|
|
124
|
+
entryName
|
|
125
|
+
],
|
|
126
|
+
...pageConfig,
|
|
127
|
+
templateParameters: {
|
|
128
|
+
mountId: null === (_unpackConfig_html3 = unpackConfig.html) || void 0 === _unpackConfig_html3 ? void 0 : _unpackConfig_html3.mountId,
|
|
129
|
+
title: (0, core_namespaceObject.isFunction)(null === (_unpackConfig_html4 = unpackConfig.html) || void 0 === _unpackConfig_html4 ? void 0 : _unpackConfig_html4.title) ? null === (_unpackConfig_html5 = unpackConfig.html) || void 0 === _unpackConfig_html5 ? void 0 : _unpackConfig_html5.title({
|
|
130
|
+
entryName
|
|
131
|
+
}) : (null === (_unpackConfig_html6 = unpackConfig.html) || void 0 === _unpackConfig_html6 ? void 0 : _unpackConfig_html6.title) || '',
|
|
132
|
+
headTag: (null === (_unpackConfig_html7 = unpackConfig.html) || void 0 === _unpackConfig_html7 ? void 0 : _unpackConfig_html7.headTag) || '',
|
|
133
|
+
...null === (_unpackConfig_html8 = unpackConfig.html) || void 0 === _unpackConfig_html8 ? void 0 : _unpackConfig_html8.templateParameters,
|
|
134
|
+
...pageConfig.templateParameters
|
|
135
|
+
}
|
|
136
|
+
});
|
|
137
|
+
}
|
|
132
138
|
});
|
|
133
|
-
|
|
139
|
+
(0, core_namespaceObject.isDevServer)() || core_namespaceObject.logger.info(`Collect entries in ${(performance.now() - start).toFixed(2)}ms ${core_namespaceObject.colors.dim('[MPA]')}`);
|
|
140
|
+
return {
|
|
141
|
+
entry,
|
|
142
|
+
html
|
|
143
|
+
};
|
|
144
|
+
};
|
|
145
|
+
const { entry, html } = collectEntry();
|
|
146
|
+
config = mergeConfig(config, {
|
|
147
|
+
entry: createTempFile(entry),
|
|
148
|
+
plugins: html.map((h)=>new HtmlPlugin(h))
|
|
134
149
|
});
|
|
135
|
-
|
|
136
|
-
`Collect entries in ${(performance.now() - start).toFixed(2)}ms ${import_core.colors.dim("[MPA]")}`
|
|
137
|
-
);
|
|
138
|
-
return { entry: entry2, html: html2 };
|
|
139
|
-
};
|
|
140
|
-
const { entry, html } = collectEntry();
|
|
141
|
-
config = mergeConfig(config, {
|
|
142
|
-
entry: createTempFile(entry),
|
|
143
|
-
plugins: html.map((h) => new HtmlPlugin(h))
|
|
144
|
-
});
|
|
145
|
-
return config;
|
|
150
|
+
return config;
|
|
146
151
|
};
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
152
|
+
var __webpack_export_target__ = exports;
|
|
153
|
+
for(var __webpack_i__ in __webpack_exports__)__webpack_export_target__[__webpack_i__] = __webpack_exports__[__webpack_i__];
|
|
154
|
+
if (__webpack_exports__.__esModule) Object.defineProperty(__webpack_export_target__, '__esModule', {
|
|
155
|
+
value: true
|
|
150
156
|
});
|
package/dist/mpa.js
CHANGED
|
@@ -1,136 +1,109 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
const
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
return config;
|
|
31
|
-
const isRspack = unpackConfig.bundler === "rspack";
|
|
32
|
-
const tempDirectory = path2.join(TEMP_DIR, "mpa");
|
|
33
|
-
const userOptions = isPlainObject(unpackConfig.mpa) ? unpackConfig.mpa : {};
|
|
34
|
-
const getPageConfig = (indexPath) => {
|
|
35
|
-
const filePath = path2.join(indexPath, "../config.json");
|
|
36
|
-
let pageConfig = {};
|
|
37
|
-
if (fs.existsSync(filePath)) {
|
|
38
|
-
pageConfig = JSON.parse(fs.readFileSync(filePath, "utf-8"));
|
|
39
|
-
}
|
|
40
|
-
return pageConfig;
|
|
41
|
-
};
|
|
42
|
-
const createTempFile = (entry2) => {
|
|
43
|
-
removeDir(path2.join(unpackConfig.root, tempDirectory));
|
|
44
|
-
const globalImport = userOptions.globalImport?.reduce((acc, curr) => {
|
|
45
|
-
return `${acc}
|
|
46
|
-
import '${getPathInJs(path2.resolve(unpackConfig.root, curr))}'`;
|
|
47
|
-
}, "") || "";
|
|
48
|
-
const { layout } = userOptions;
|
|
49
|
-
const layoutImport = layout ? `import Layout from '${getPathInJs(path2.resolve(unpackConfig.root, layout))}'` : "";
|
|
50
|
-
const layoutJSX = layout ? "<Layout><App /></Layout>" : "<App />";
|
|
51
|
-
const rootElement = `document.getElementById('${unpackConfig.html?.mountId}')`;
|
|
52
|
-
const reactDOMSource = "react-dom/client";
|
|
53
|
-
const renderer = `ReactDOM.createRoot(${rootElement}).render(${layoutJSX})`;
|
|
54
|
-
Object.entries(entry2).forEach(([entryName, entryConfig]) => {
|
|
55
|
-
const filePath = path2.join(unpackConfig.root, tempDirectory, `${entryName}.jsx`);
|
|
56
|
-
const tpl = `
|
|
1
|
+
import __rslib_shim_module__ from 'module';
|
|
2
|
+
/*#__PURE__*/ import.meta.url;
|
|
3
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__ from "node:fs";
|
|
4
|
+
import * as __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__ from "node:path";
|
|
5
|
+
import * as __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__ from "@unpackjs/core";
|
|
6
|
+
const applyMpaConfig = ({ config, unpackConfig, mergeConfig, HtmlPlugin })=>{
|
|
7
|
+
if (!unpackConfig.mpa) return config;
|
|
8
|
+
const isRspack = 'rspack' === unpackConfig.bundler;
|
|
9
|
+
const tempDirectory = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(__WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.TEMP_DIR, 'mpa');
|
|
10
|
+
const userOptions = (0, __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.isPlainObject)(unpackConfig.mpa) ? unpackConfig.mpa : {};
|
|
11
|
+
const getPageConfig = (indexPath)=>{
|
|
12
|
+
const filePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(indexPath, '../config.json');
|
|
13
|
+
let pageConfig = {};
|
|
14
|
+
if (__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync(filePath)) pageConfig = JSON.parse(__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readFileSync(filePath, 'utf-8'));
|
|
15
|
+
return pageConfig;
|
|
16
|
+
};
|
|
17
|
+
const createTempFile = (entry)=>{
|
|
18
|
+
var _userOptions_globalImport, _unpackConfig_html;
|
|
19
|
+
(0, __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.removeDir)(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(unpackConfig.root, tempDirectory));
|
|
20
|
+
const globalImport = (null === (_userOptions_globalImport = userOptions.globalImport) || void 0 === _userOptions_globalImport ? void 0 : _userOptions_globalImport.reduce((acc, curr)=>`${acc}\nimport '${(0, __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.getPathInJs)(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(unpackConfig.root, curr))}'`, '')) || '';
|
|
21
|
+
const { layout } = userOptions;
|
|
22
|
+
const layoutImport = layout ? `import Layout from '${(0, __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.getPathInJs)(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].resolve(unpackConfig.root, layout))}'` : '';
|
|
23
|
+
const layoutJSX = layout ? '<Layout><App /></Layout>' : '<App />';
|
|
24
|
+
const rootElement = `document.getElementById('${null === (_unpackConfig_html = unpackConfig.html) || void 0 === _unpackConfig_html ? void 0 : _unpackConfig_html.mountId}')`;
|
|
25
|
+
const reactDOMSource = 'react-dom/client';
|
|
26
|
+
const renderer = `ReactDOM.createRoot(${rootElement}).render(${layoutJSX})`;
|
|
27
|
+
Object.entries(entry).forEach(([entryName, entryConfig])=>{
|
|
28
|
+
const filePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(unpackConfig.root, tempDirectory, `${entryName}.jsx`);
|
|
29
|
+
const tpl = `
|
|
57
30
|
import React from 'react'
|
|
58
31
|
import ReactDOM from '${reactDOMSource}'
|
|
59
|
-
import App from '${getPathInJs(entryConfig.import[0])}'${layoutImport && `
|
|
60
|
-
${layoutImport}`}
|
|
32
|
+
import App from '${(0, __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.getPathInJs)(entryConfig.import[0])}'${layoutImport && `\n${layoutImport}`}
|
|
61
33
|
${globalImport}
|
|
62
34
|
${renderer}
|
|
63
35
|
`;
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
};
|
|
73
|
-
const collectEntry = () => {
|
|
74
|
-
const start = performance.now();
|
|
75
|
-
const entry2 = {};
|
|
76
|
-
const html2 = [];
|
|
77
|
-
const getIndexFilePath = (dir) => {
|
|
78
|
-
const extensions = [".tsx", ".jsx"];
|
|
79
|
-
for (const extension of extensions) {
|
|
80
|
-
const indexFilePath = path2.join(dir, `index${extension}`);
|
|
81
|
-
if (fs.existsSync(indexFilePath)) {
|
|
82
|
-
return indexFilePath;
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
return null;
|
|
36
|
+
const dir = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].dirname(filePath);
|
|
37
|
+
if (!__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync(dir)) __WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].mkdirSync(dir, {
|
|
38
|
+
recursive: true
|
|
39
|
+
});
|
|
40
|
+
__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].writeFileSync(filePath, tpl, 'utf-8');
|
|
41
|
+
entryConfig.import[0] = filePath;
|
|
42
|
+
});
|
|
43
|
+
return entry;
|
|
86
44
|
};
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
45
|
+
const collectEntry = ()=>{
|
|
46
|
+
const start = performance.now();
|
|
47
|
+
const entry = {};
|
|
48
|
+
const html = [];
|
|
49
|
+
const getIndexFilePath = (dir)=>{
|
|
50
|
+
const extensions = [
|
|
51
|
+
'.tsx',
|
|
52
|
+
'.jsx'
|
|
53
|
+
];
|
|
54
|
+
for (const extension of extensions){
|
|
55
|
+
const indexFilePath = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(dir, `index${extension}`);
|
|
56
|
+
if (__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].existsSync(indexFilePath)) return indexFilePath;
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
100
59
|
};
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
60
|
+
const pagesRoot = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(unpackConfig.root, 'src', 'pages');
|
|
61
|
+
__WEBPACK_EXTERNAL_MODULE_node_fs_5ea92f0c__["default"].readdirSync(pagesRoot).forEach((filename)=>{
|
|
62
|
+
if (filename.startsWith('.')) return;
|
|
63
|
+
const indexFilePath = getIndexFilePath(__WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(pagesRoot, filename));
|
|
64
|
+
if (indexFilePath) {
|
|
65
|
+
var _unpackConfig_html, _unpackConfig_html1, _unpackConfig_html2, _unpackConfig_html3, _unpackConfig_html4, _unpackConfig_html5, _unpackConfig_html6, _unpackConfig_html7, _unpackConfig_html8;
|
|
66
|
+
const pageConfig = getPageConfig(indexFilePath);
|
|
67
|
+
let entryName = true === userOptions.lowerCase ? filename.toLowerCase() : filename;
|
|
68
|
+
if (pageConfig.filename) entryName = pageConfig.filename.slice(0, -5);
|
|
69
|
+
entry[entryName] = {
|
|
70
|
+
import: [
|
|
71
|
+
indexFilePath
|
|
72
|
+
]
|
|
73
|
+
};
|
|
74
|
+
if (pageConfig.template) pageConfig.template = __WEBPACK_EXTERNAL_MODULE_node_path_c5b9b54f__["default"].join(indexFilePath, '../', pageConfig.template);
|
|
75
|
+
html.push({
|
|
76
|
+
template: (null === (_unpackConfig_html = unpackConfig.html) || void 0 === _unpackConfig_html ? void 0 : _unpackConfig_html.template) || (isRspack ? void 0 : ''),
|
|
77
|
+
templateContent: (null === (_unpackConfig_html1 = unpackConfig.html) || void 0 === _unpackConfig_html1 ? void 0 : _unpackConfig_html1.templateContent) || ((null === (_unpackConfig_html2 = unpackConfig.html) || void 0 === _unpackConfig_html2 ? void 0 : _unpackConfig_html2.template) ? !!isRspack && void 0 : __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.TEMPLATE_CONTENT),
|
|
78
|
+
minify: false,
|
|
79
|
+
filename: `${entryName}.html`,
|
|
80
|
+
chunks: [
|
|
81
|
+
entryName
|
|
82
|
+
],
|
|
83
|
+
...pageConfig,
|
|
84
|
+
templateParameters: {
|
|
85
|
+
mountId: null === (_unpackConfig_html3 = unpackConfig.html) || void 0 === _unpackConfig_html3 ? void 0 : _unpackConfig_html3.mountId,
|
|
86
|
+
title: (0, __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.isFunction)(null === (_unpackConfig_html4 = unpackConfig.html) || void 0 === _unpackConfig_html4 ? void 0 : _unpackConfig_html4.title) ? null === (_unpackConfig_html5 = unpackConfig.html) || void 0 === _unpackConfig_html5 ? void 0 : _unpackConfig_html5.title({
|
|
87
|
+
entryName
|
|
88
|
+
}) : (null === (_unpackConfig_html6 = unpackConfig.html) || void 0 === _unpackConfig_html6 ? void 0 : _unpackConfig_html6.title) || '',
|
|
89
|
+
headTag: (null === (_unpackConfig_html7 = unpackConfig.html) || void 0 === _unpackConfig_html7 ? void 0 : _unpackConfig_html7.headTag) || '',
|
|
90
|
+
...null === (_unpackConfig_html8 = unpackConfig.html) || void 0 === _unpackConfig_html8 ? void 0 : _unpackConfig_html8.templateParameters,
|
|
91
|
+
...pageConfig.templateParameters
|
|
92
|
+
}
|
|
93
|
+
});
|
|
94
|
+
}
|
|
119
95
|
});
|
|
120
|
-
|
|
96
|
+
(0, __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.isDevServer)() || __WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.logger.info(`Collect entries in ${(performance.now() - start).toFixed(2)}ms ${__WEBPACK_EXTERNAL_MODULE__unpackjs_core_a401ca19__.colors.dim('[MPA]')}`);
|
|
97
|
+
return {
|
|
98
|
+
entry,
|
|
99
|
+
html
|
|
100
|
+
};
|
|
101
|
+
};
|
|
102
|
+
const { entry, html } = collectEntry();
|
|
103
|
+
config = mergeConfig(config, {
|
|
104
|
+
entry: createTempFile(entry),
|
|
105
|
+
plugins: html.map((h)=>new HtmlPlugin(h))
|
|
121
106
|
});
|
|
122
|
-
|
|
123
|
-
`Collect entries in ${(performance.now() - start).toFixed(2)}ms ${colors.dim("[MPA]")}`
|
|
124
|
-
);
|
|
125
|
-
return { entry: entry2, html: html2 };
|
|
126
|
-
};
|
|
127
|
-
const { entry, html } = collectEntry();
|
|
128
|
-
config = mergeConfig(config, {
|
|
129
|
-
entry: createTempFile(entry),
|
|
130
|
-
plugins: html.map((h) => new HtmlPlugin(h))
|
|
131
|
-
});
|
|
132
|
-
return config;
|
|
133
|
-
};
|
|
134
|
-
export {
|
|
135
|
-
applyMpaConfig
|
|
107
|
+
return config;
|
|
136
108
|
};
|
|
109
|
+
export { applyMpaConfig };
|