minista 2.3.0 → 2.3.1
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/build.js +12 -8
- package/dist/user.js +4 -1
- package/dist/vite.js +1 -2
- package/package.json +1 -1
package/dist/build.js
CHANGED
|
@@ -33,10 +33,10 @@ import { slashEnd } from "./utils.js";
|
|
|
33
33
|
const __filename = url.fileURLToPath(import.meta.url);
|
|
34
34
|
const __dirname = path.dirname(__filename);
|
|
35
35
|
async function buildTempPages(entryPoints, buildOptions) {
|
|
36
|
-
const
|
|
37
|
-
const
|
|
38
|
-
const
|
|
39
|
-
const userPkg = JSON.parse(fs.readFileSync(
|
|
36
|
+
const ministaPkg = JSON.parse(fs.readFileSync("../package.json", "utf8"));
|
|
37
|
+
const userPkgPath = path.resolve("package.json");
|
|
38
|
+
const userPkgFilePath = path.relative(process.cwd(), userPkgPath);
|
|
39
|
+
const userPkg = JSON.parse(fs.readFileSync(userPkgFilePath, "utf8"));
|
|
40
40
|
const esbuildExternal = [
|
|
41
41
|
...Object.keys(ministaPkg.dependencies || {}),
|
|
42
42
|
...Object.keys(ministaPkg.devDependencies || {}),
|
|
@@ -73,10 +73,11 @@ async function buildTempPages(entryPoints, buildOptions) {
|
|
|
73
73
|
}
|
|
74
74
|
async function buildStaticPages(entryPoints, tempRootFilePath, buildOptions, assetsTagStr) {
|
|
75
75
|
const rootStaticContent = await buildRootEsmContent(tempRootFilePath);
|
|
76
|
+
const winOutBase = buildOptions.outBase.replaceAll("/", "\\");
|
|
76
77
|
await Promise.all(entryPoints.map(async (entryPoint) => {
|
|
77
78
|
const extname = path.extname(entryPoint);
|
|
78
79
|
const basename = path.basename(entryPoint, extname);
|
|
79
|
-
const dirname = path.dirname(entryPoint).replace(buildOptions.outBase, buildOptions.outDir);
|
|
80
|
+
const dirname = path.dirname(entryPoint).replace(buildOptions.outBase, buildOptions.outDir).replace(winOutBase, buildOptions.outDir);
|
|
80
81
|
const filename = path.join(dirname, basename + ".html");
|
|
81
82
|
await buildStaticPage(entryPoint, filename, rootStaticContent, assetsTagStr, buildOptions.outDir);
|
|
82
83
|
}));
|
|
@@ -89,7 +90,8 @@ async function buildRootEsmContent(tempRootFilePath) {
|
|
|
89
90
|
if (!tempRootFilePath) {
|
|
90
91
|
return defaultRootEsmContent;
|
|
91
92
|
} else {
|
|
92
|
-
const
|
|
93
|
+
const targetFilePath = url.pathToFileURL(tempRootFilePath).href;
|
|
94
|
+
const rootEsmContent = await import(targetFilePath);
|
|
93
95
|
const rootJsxContent = rootEsmContent.default ? rootEsmContent.default : Fragment;
|
|
94
96
|
const staticData = rootEsmContent.getStaticData ? await buildGlobalStaticData(rootEsmContent.getStaticData) : { props: {} };
|
|
95
97
|
return { component: rootJsxContent, staticData };
|
|
@@ -100,7 +102,8 @@ async function buildGlobalStaticData(getGlobalStaticData) {
|
|
|
100
102
|
return response;
|
|
101
103
|
}
|
|
102
104
|
async function buildStaticPage(entryPoint, outFile, rootStaticContent, assetsTagStr, outDir) {
|
|
103
|
-
const
|
|
105
|
+
const targetFilePath = url.pathToFileURL(entryPoint).href;
|
|
106
|
+
const pageEsmContent = await import(targetFilePath);
|
|
104
107
|
const pageJsxContent = pageEsmContent.default;
|
|
105
108
|
const frontmatter = pageEsmContent.frontmatter ? pageEsmContent.frontmatter : void 0;
|
|
106
109
|
const defaultStaticDataItem = { props: {}, paths: {} };
|
|
@@ -217,8 +220,9 @@ async function buildTempAssets(viteConfig, buildOptions) {
|
|
|
217
220
|
}
|
|
218
221
|
}
|
|
219
222
|
async function buildAssetsTagStr(entryPoints, buildOptions) {
|
|
223
|
+
const winOutBase = buildOptions.outBase.replaceAll("/", "\\");
|
|
220
224
|
const assetsTags = entryPoints.map((entryPoint) => {
|
|
221
|
-
const assetPath = entryPoint.replace(buildOptions.outBase, buildOptions.outDir);
|
|
225
|
+
const assetPath = entryPoint.replace(buildOptions.outBase, buildOptions.outDir).replace(winOutBase, buildOptions.outDir);
|
|
222
226
|
if (assetPath.endsWith(".css")) {
|
|
223
227
|
return `<link rel="stylesheet" href="${assetPath}">`;
|
|
224
228
|
} else if (assetPath.endsWith(".js")) {
|
package/dist/user.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import path from "path";
|
|
3
|
+
import url from "url";
|
|
3
4
|
import { build as esBuild } from "esbuild";
|
|
4
5
|
import { systemConfig } from "./system.js";
|
|
5
6
|
import { getSameFilePaths } from "./path.js";
|
|
@@ -22,7 +23,9 @@ async function getUserConfig(cofigPath = ".") {
|
|
|
22
23
|
format: "esm",
|
|
23
24
|
platform: "node"
|
|
24
25
|
}).catch(() => process.exit(1));
|
|
25
|
-
const
|
|
26
|
+
const userConfigPath = path.resolve(`${systemConfig.temp.config.outDir}/minista.config.mjs`);
|
|
27
|
+
const userConfigFilePath = url.pathToFileURL(userConfigPath).href;
|
|
28
|
+
const { default: userConfig } = await import(userConfigFilePath);
|
|
26
29
|
return userConfig || {};
|
|
27
30
|
} else {
|
|
28
31
|
return {};
|
package/dist/vite.js
CHANGED
|
@@ -153,8 +153,7 @@ function vitePluginMinistaVirtualHtml() {
|
|
|
153
153
|
configureServer(server) {
|
|
154
154
|
return () => {
|
|
155
155
|
var _a, _b;
|
|
156
|
-
const
|
|
157
|
-
const ministaHtml = fs.readFileSync(ministaHtmlURL, "utf8");
|
|
156
|
+
const ministaHtml = fs.readFileSync("../lib/index.html", "utf8");
|
|
158
157
|
const assetTagStr = getAssetsTagStr((_b = (_a = server.config.inlineConfig.build) == null ? void 0 : _a.rollupOptions) == null ? void 0 : _b.input);
|
|
159
158
|
const ministaReplacedHtml = ministaHtml.replace("<!-- VIRTUAL_HTML_ASSETS_TAG -->", assetTagStr);
|
|
160
159
|
server.middlewares.use((req, res, next) => {
|