minista 2.2.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/client.d.ts +9 -0
- package/dist/build.js +12 -8
- package/dist/cli.js +29 -6
- package/dist/types.d.ts +16 -1
- package/dist/user.js +4 -1
- package/dist/vite.d.ts +2 -2
- package/dist/vite.js +5 -6
- package/package.json +3 -1
package/client.d.ts
CHANGED
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
declare module "*.mdx" {
|
|
2
|
+
import { MDXProps } from "mdx/types"
|
|
3
|
+
export default function MDXContent(props: MDXProps): JSX.Element
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
declare module "*.md" {
|
|
7
|
+
export { default } from "*.mdx"
|
|
8
|
+
}
|
|
9
|
+
|
|
1
10
|
declare module "*.svg" {
|
|
2
11
|
import * as React from "react"
|
|
3
12
|
|
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/cli.js
CHANGED
|
@@ -1,3 +1,19 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
3
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
4
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
6
|
+
var __spreadValues = (a, b) => {
|
|
7
|
+
for (var prop in b || (b = {}))
|
|
8
|
+
if (__hasOwnProp.call(b, prop))
|
|
9
|
+
__defNormalProp(a, prop, b[prop]);
|
|
10
|
+
if (__getOwnPropSymbols)
|
|
11
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
12
|
+
if (__propIsEnum.call(b, prop))
|
|
13
|
+
__defNormalProp(a, prop, b[prop]);
|
|
14
|
+
}
|
|
15
|
+
return a;
|
|
16
|
+
};
|
|
1
17
|
import React from "react";
|
|
2
18
|
import fs from "fs-extra";
|
|
3
19
|
import { cac } from "cac";
|
|
@@ -20,19 +36,25 @@ import {
|
|
|
20
36
|
generateDownload,
|
|
21
37
|
generateBeautify
|
|
22
38
|
} from "./generate.js";
|
|
39
|
+
const cli = cac("minista");
|
|
40
|
+
function cleanOptions(options) {
|
|
41
|
+
const ret = __spreadValues({}, options);
|
|
42
|
+
delete ret["--"];
|
|
43
|
+
return ret;
|
|
44
|
+
}
|
|
23
45
|
function printVersion() {
|
|
24
46
|
const pkgURL = new URL("../package.json", import.meta.url);
|
|
25
47
|
const pkg = JSON.parse(fs.readFileSync(pkgURL, "utf8"));
|
|
26
48
|
const pkgVersion = pkg.version;
|
|
27
49
|
return pkgVersion;
|
|
28
50
|
}
|
|
29
|
-
|
|
30
|
-
cli.command("[root]").alias("dev").action(async () => {
|
|
51
|
+
cli.command("[root]", "start dev server").alias("dev").option("--host [host]", `[string] specify hostname`).option("--port <port>", `[number] specify port`).option("--strictPort", `[boolean] exit if specified port is already in use`).option("--https", `[boolean] use TLS + HTTP/2`).option("--open [path]", `[boolean | string] open browser on startup`).option("--cors", `[boolean] enable CORS`).action(async (root, options) => {
|
|
31
52
|
try {
|
|
53
|
+
const cliOptions = cleanOptions(options);
|
|
32
54
|
const userConfig = await getUserConfig();
|
|
33
55
|
const config = await getConfig(userConfig);
|
|
34
56
|
const mdxConfig = await getMdxConfig(config);
|
|
35
|
-
const viteConfig = await getViteConfig(config, mdxConfig);
|
|
57
|
+
const viteConfig = await getViteConfig(config, mdxConfig, cliOptions);
|
|
36
58
|
await Promise.all([
|
|
37
59
|
emptyResolveDir(systemConfig.temp.viteImporter.outDir),
|
|
38
60
|
emptyResolveDir(systemConfig.temp.icons.outDir)
|
|
@@ -44,7 +66,7 @@ cli.command("[root]").alias("dev").action(async () => {
|
|
|
44
66
|
process.exit(1);
|
|
45
67
|
}
|
|
46
68
|
});
|
|
47
|
-
cli.command("build [root]").action(async () => {
|
|
69
|
+
cli.command("build [root]", "build for production").action(async () => {
|
|
48
70
|
try {
|
|
49
71
|
const userConfig = await getUserConfig();
|
|
50
72
|
const config = await getConfig(userConfig);
|
|
@@ -76,12 +98,13 @@ cli.command("build [root]").action(async () => {
|
|
|
76
98
|
process.exit(1);
|
|
77
99
|
}
|
|
78
100
|
});
|
|
79
|
-
cli.command("preview [root]").action(async () => {
|
|
101
|
+
cli.command("preview [root]", "locally preview production build").option("--host [host]", `[string] specify hostname`).option("--port <port>", `[number] specify port`).option("--strictPort", `[boolean] exit if specified port is already in use`).option("--https", `[boolean] use TLS + HTTP/2`).option("--open [path]", `[boolean | string] open browser on startup`).action(async (root, options) => {
|
|
80
102
|
try {
|
|
103
|
+
const cliOptions = cleanOptions(options);
|
|
81
104
|
const userConfig = await getUserConfig();
|
|
82
105
|
const config = await getConfig(userConfig);
|
|
83
106
|
const mdxConfig = await getMdxConfig(config);
|
|
84
|
-
const viteConfig = await getViteConfig(config, mdxConfig);
|
|
107
|
+
const viteConfig = await getViteConfig(config, mdxConfig, cliOptions);
|
|
85
108
|
await previewLocal(viteConfig);
|
|
86
109
|
} catch (err) {
|
|
87
110
|
console.log(err);
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { ExoticComponent } from "react";
|
|
2
|
-
import type { UserConfig as ViteUserConfig } from "vite";
|
|
2
|
+
import type { UserConfig as ViteUserConfig, CorsOptions as ViteCorsOptions } from "vite";
|
|
3
3
|
import type { Config as SvgrOptions } from "@svgr/core";
|
|
4
4
|
import type { Options as HighlightOptions } from "rehype-highlight";
|
|
5
5
|
import type { Options as MdxOptions } from "@mdx-js/esbuild";
|
|
@@ -177,6 +177,21 @@ export declare type MinistaSystemConfig = {
|
|
|
177
177
|
};
|
|
178
178
|
};
|
|
179
179
|
};
|
|
180
|
+
export declare type MinistaCliDevOptions = {
|
|
181
|
+
host?: string | boolean;
|
|
182
|
+
port?: number;
|
|
183
|
+
strictPort?: boolean;
|
|
184
|
+
https?: boolean;
|
|
185
|
+
open?: boolean | string;
|
|
186
|
+
cors?: boolean | ViteCorsOptions;
|
|
187
|
+
};
|
|
188
|
+
export declare type MinistaCliPreviewOptions = {
|
|
189
|
+
host?: string | boolean;
|
|
190
|
+
port?: number;
|
|
191
|
+
strictPort?: boolean;
|
|
192
|
+
https?: boolean;
|
|
193
|
+
open?: boolean | string;
|
|
194
|
+
};
|
|
180
195
|
export declare type MinistaLocation = {
|
|
181
196
|
pathname: string;
|
|
182
197
|
};
|
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.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import type { UserConfig as ViteConfig, Plugin } from "vite";
|
|
2
2
|
import type { Config as SvgrOptions } from "@svgr/core";
|
|
3
3
|
import type { Options as MdxOptions } from "@mdx-js/esbuild";
|
|
4
|
-
import type { MinistaResolveConfig, MinistaSvgstoreOptions } from "./types.js";
|
|
5
|
-
export declare function getViteConfig(config: MinistaResolveConfig, mdxConfig: MdxOptions): Promise<ViteConfig>;
|
|
4
|
+
import type { MinistaResolveConfig, MinistaSvgstoreOptions, MinistaCliDevOptions, MinistaCliPreviewOptions } from "./types.js";
|
|
5
|
+
export declare function getViteConfig(config: MinistaResolveConfig, mdxConfig: MdxOptions, cliOptions?: MinistaCliDevOptions | MinistaCliPreviewOptions): Promise<ViteConfig>;
|
|
6
6
|
export declare function resolveEntry(entry: string | string[] | {}): {};
|
|
7
7
|
export declare function vitePluginMinistaVirtualHtml(): Plugin;
|
|
8
8
|
/*! Fork: vite-plugin-svgr | https://github.com/pd4d10/vite-plugin-svgr */
|
package/dist/vite.js
CHANGED
|
@@ -18,11 +18,11 @@ import { getFilePaths } from "./path.js";
|
|
|
18
18
|
import { getFilename, getFilenameObject } from "./utils.js";
|
|
19
19
|
const __filename = url.fileURLToPath(import.meta.url);
|
|
20
20
|
const __dirname = path.dirname(__filename);
|
|
21
|
-
async function getViteConfig(config, mdxConfig) {
|
|
21
|
+
async function getViteConfig(config, mdxConfig, cliOptions) {
|
|
22
22
|
var _a, _b, _c, _d, _e;
|
|
23
23
|
const imgExt = ["jpg", "jpeg", "gif", "png", "webp", "svg"];
|
|
24
24
|
const fontExt = ["woff", "woff2", "eot", "ttf", "otf"];
|
|
25
|
-
const
|
|
25
|
+
const defaultViteConfig = defineViteConfig({
|
|
26
26
|
base: config.base || "/",
|
|
27
27
|
publicDir: config.public || "public",
|
|
28
28
|
build: {
|
|
@@ -90,7 +90,7 @@ async function getViteConfig(config, mdxConfig) {
|
|
|
90
90
|
},
|
|
91
91
|
customLogger: createLogger("info", { prefix: "[minista]" })
|
|
92
92
|
});
|
|
93
|
-
const mergedViteConfig = mergeViteConfig(
|
|
93
|
+
const mergedViteConfig = mergeViteConfig(defaultViteConfig, config.vite);
|
|
94
94
|
const svgrPlugin = vitePluginMinistaSvgr(config.assets.svgr.svgrOptions);
|
|
95
95
|
mergedViteConfig.plugins.push(svgrPlugin);
|
|
96
96
|
if (config.assets.icons.useSprite) {
|
|
@@ -104,7 +104,7 @@ async function getViteConfig(config, mdxConfig) {
|
|
|
104
104
|
}
|
|
105
105
|
const mdxPlugin = mdx(mdxConfig);
|
|
106
106
|
mergedViteConfig.plugins.push(mdxPlugin);
|
|
107
|
-
return mergedViteConfig;
|
|
107
|
+
return cliOptions ? mergeViteConfig(mergedViteConfig, { server: cliOptions }) : mergedViteConfig;
|
|
108
108
|
}
|
|
109
109
|
function resolveEntry(entry) {
|
|
110
110
|
const result1 = typeof entry === "object" ? entry : typeof entry === "string" ? { [getFilename(entry)]: entry } : Array.isArray(entry) ? getFilenameObject(entry) : {};
|
|
@@ -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) => {
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "minista",
|
|
3
3
|
"description": "Next.js Like Development with 100% Static Generate",
|
|
4
|
-
"version": "2.
|
|
4
|
+
"version": "2.3.1",
|
|
5
5
|
"bin": {
|
|
6
6
|
"minista": "./bin/minista.js"
|
|
7
7
|
},
|
|
@@ -51,8 +51,10 @@
|
|
|
51
51
|
"test:dev": "vitest watch",
|
|
52
52
|
"user": "cd ./user && npx minista",
|
|
53
53
|
"user:dev": "cd ./user && npx minista",
|
|
54
|
+
"user:dev-h": "cd ./user && npx minista --host",
|
|
54
55
|
"user:build": "cd ./user && npx minista build",
|
|
55
56
|
"user:preview": "cd ./user && npx minista preview",
|
|
57
|
+
"user:preview-h": "cd ./user && npx minista preview --host",
|
|
56
58
|
"user:v": "cd ./user && npx minista -v",
|
|
57
59
|
"user:h": "cd ./user && npx minista -h",
|
|
58
60
|
"prepublishOnly": "npm run clean:dist && npm run build:all",
|