minista 2.0.1 → 2.2.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/README.md +3 -0
- package/client.d.ts +22 -0
- package/dist/build.d.ts +2 -0
- package/dist/build.js +4 -2
- package/dist/config.js +3 -0
- package/dist/esbuild.d.ts +5 -0
- package/dist/esbuild.js +58 -1
- package/dist/generate.js +4 -2
- package/dist/types.d.ts +7 -0
- package/dist/vite.d.ts +3 -0
- package/dist/vite.js +28 -1
- package/package.json +4 -2
package/README.md
CHANGED
|
@@ -105,6 +105,9 @@ export default defineConfig({
|
|
|
105
105
|
outDir: "assets/fonts", // string
|
|
106
106
|
outName: "[name]", // string
|
|
107
107
|
},
|
|
108
|
+
svgr: {
|
|
109
|
+
svgrOptions: {}, // https://react-svgr.com/docs/options/
|
|
110
|
+
},
|
|
108
111
|
icons: {
|
|
109
112
|
useSprite: true, // boolean
|
|
110
113
|
srcDir: "src/assets/icons", // string
|
package/client.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
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
|
+
|
|
10
|
+
declare module "*.svg" {
|
|
11
|
+
import * as React from "react"
|
|
12
|
+
|
|
13
|
+
const ReactComponent: React.FunctionComponent<
|
|
14
|
+
React.SVGProps<SVGSVGElement> & { title?: string }
|
|
15
|
+
>
|
|
16
|
+
export default ReactComponent
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
declare module "*?raw" {
|
|
20
|
+
const src: string
|
|
21
|
+
export default src
|
|
22
|
+
}
|
package/dist/build.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { Options as MdxOptions } from "@mdx-js/esbuild";
|
|
2
|
+
import type { Config as SvgrOptions } from "@svgr/core";
|
|
2
3
|
import type { InlineConfig } from "vite";
|
|
3
4
|
import type { MinistaResolveConfig, RootStaticContent, RootJsxContent, GlobalStaticData, GetGlobalStaticData, PageJsxContent, StaticData, StaticDataItem, GetStaticData } from "./types.js";
|
|
4
5
|
export declare function buildTempPages(entryPoints: string[], buildOptions: {
|
|
5
6
|
outBase: string;
|
|
6
7
|
outDir: string;
|
|
7
8
|
mdxConfig: MdxOptions;
|
|
9
|
+
svgrOptions: SvgrOptions;
|
|
8
10
|
}): Promise<void>;
|
|
9
11
|
export declare function buildStaticPages(entryPoints: string[], tempRootFilePath: string, buildOptions: {
|
|
10
12
|
outBase: string;
|
package/dist/build.js
CHANGED
|
@@ -27,7 +27,7 @@ import { build as esBuild } from "esbuild";
|
|
|
27
27
|
import mdx from "@mdx-js/esbuild";
|
|
28
28
|
import { build as viteBuild, mergeConfig as mergeViteConfig } from "vite";
|
|
29
29
|
import { systemConfig } from "./system.js";
|
|
30
|
-
import { resolvePlugin } from "./esbuild.js";
|
|
30
|
+
import { resolvePlugin, svgrPlugin, rawPlugin } from "./esbuild.js";
|
|
31
31
|
import { renderHtml } from "./render.js";
|
|
32
32
|
import { slashEnd } from "./utils.js";
|
|
33
33
|
const __filename = url.fileURLToPath(import.meta.url);
|
|
@@ -65,7 +65,9 @@ async function buildTempPages(entryPoints, buildOptions) {
|
|
|
65
65
|
mdx(buildOptions.mdxConfig),
|
|
66
66
|
resolvePlugin({
|
|
67
67
|
"react/jsx-runtime": "react/jsx-runtime.js"
|
|
68
|
-
})
|
|
68
|
+
}),
|
|
69
|
+
svgrPlugin(buildOptions.svgrOptions),
|
|
70
|
+
rawPlugin()
|
|
69
71
|
]
|
|
70
72
|
}).catch(() => process.exit(1));
|
|
71
73
|
}
|
package/dist/config.js
CHANGED
package/dist/esbuild.d.ts
CHANGED
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import type { Plugin } from "esbuild";
|
|
2
|
+
import type { Config as SvgrOptions } from "@svgr/core";
|
|
2
3
|
/*! Fork: esbuild-plugin-resolve | https://github.com/markwylde/esbuild-plugin-resolve */
|
|
3
4
|
export declare function resolvePlugin(options: {
|
|
4
5
|
[key: string]: string;
|
|
5
6
|
}): Plugin;
|
|
7
|
+
/*! Fork: esbuild-plugin-svgr | https://github.com/kazijawad/esbuild-plugin-svgr */
|
|
8
|
+
export declare function svgrPlugin(options: SvgrOptions): Plugin;
|
|
9
|
+
/*! Fork: esbuild-plugin-resolve | https://github.com/hannoeru/esbuild-plugin-raw */
|
|
10
|
+
export declare function rawPlugin(): Plugin;
|
package/dist/esbuild.js
CHANGED
|
@@ -1,4 +1,22 @@
|
|
|
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";
|
|
18
|
+
import fs from "fs-extra";
|
|
19
|
+
import path from "path";
|
|
2
20
|
/*! Fork: esbuild-plugin-resolve | https://github.com/markwylde/esbuild-plugin-resolve */
|
|
3
21
|
function resolvePlugin(options) {
|
|
4
22
|
return {
|
|
@@ -33,6 +51,45 @@ function resolvePluginIntercept(build, moduleName, moduleTarget) {
|
|
|
33
51
|
return { contents: importerCode, resolveDir: args.pluginData.resolveDir };
|
|
34
52
|
});
|
|
35
53
|
}
|
|
54
|
+
/*! Fork: esbuild-plugin-svgr | https://github.com/kazijawad/esbuild-plugin-svgr */
|
|
55
|
+
function svgrPlugin(options) {
|
|
56
|
+
return {
|
|
57
|
+
name: "esbuild-svgr",
|
|
58
|
+
setup(build) {
|
|
59
|
+
build.onLoad({ filter: /\.svg$/ }, async (args) => {
|
|
60
|
+
const { transform: transformSvgr } = await import("@svgr/core");
|
|
61
|
+
const svg = await fs.promises.readFile(args.path, "utf8");
|
|
62
|
+
const contents = await transformSvgr(svg, __spreadValues({}, options), { filePath: args.path });
|
|
63
|
+
return {
|
|
64
|
+
contents,
|
|
65
|
+
loader: options.typescript ? "tsx" : "jsx"
|
|
66
|
+
};
|
|
67
|
+
});
|
|
68
|
+
}
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
/*! Fork: esbuild-plugin-resolve | https://github.com/hannoeru/esbuild-plugin-raw */
|
|
72
|
+
function rawPlugin() {
|
|
73
|
+
return {
|
|
74
|
+
name: "esbuild-raw",
|
|
75
|
+
setup(build) {
|
|
76
|
+
build.onResolve({ filter: /\?raw$/ }, (args) => {
|
|
77
|
+
return {
|
|
78
|
+
path: path.isAbsolute(args.path) ? args.path : path.join(args.resolveDir, args.path),
|
|
79
|
+
namespace: "raw-loader"
|
|
80
|
+
};
|
|
81
|
+
});
|
|
82
|
+
build.onLoad({ filter: /\?raw$/, namespace: "raw-loader" }, async (args) => {
|
|
83
|
+
return {
|
|
84
|
+
contents: await fs.promises.readFile(args.path.replace(/\?raw$/, "")),
|
|
85
|
+
loader: "text"
|
|
86
|
+
};
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
};
|
|
90
|
+
}
|
|
36
91
|
export {
|
|
37
|
-
|
|
92
|
+
rawPlugin,
|
|
93
|
+
resolvePlugin,
|
|
94
|
+
svgrPlugin
|
|
38
95
|
};
|
package/dist/generate.js
CHANGED
|
@@ -35,7 +35,8 @@ async function generateTempRoot(config, mdxConfig) {
|
|
|
35
35
|
await buildTempPages([srcRootFilePaths[0]], {
|
|
36
36
|
outBase: config.rootSrcDir,
|
|
37
37
|
outDir: systemConfig.temp.root.outDir,
|
|
38
|
-
mdxConfig
|
|
38
|
+
mdxConfig,
|
|
39
|
+
svgrOptions: config.assets.svgr.svgrOptions
|
|
39
40
|
});
|
|
40
41
|
}
|
|
41
42
|
}
|
|
@@ -44,7 +45,8 @@ async function generateTempPages(config, mdxConfig) {
|
|
|
44
45
|
await buildTempPages(srcPageFilePaths, {
|
|
45
46
|
outBase: config.pagesSrcDir,
|
|
46
47
|
outDir: systemConfig.temp.pages.outDir,
|
|
47
|
-
mdxConfig
|
|
48
|
+
mdxConfig,
|
|
49
|
+
svgrOptions: config.assets.svgr.svgrOptions
|
|
48
50
|
});
|
|
49
51
|
}
|
|
50
52
|
async function generateAssets(config, viteConfig) {
|
package/dist/types.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { ExoticComponent } from "react";
|
|
2
2
|
import type { UserConfig as ViteUserConfig } from "vite";
|
|
3
|
+
import type { Config as SvgrOptions } from "@svgr/core";
|
|
3
4
|
import type { Options as HighlightOptions } from "rehype-highlight";
|
|
4
5
|
import type { Options as MdxOptions } from "@mdx-js/esbuild";
|
|
5
6
|
import type { HTMLBeautifyOptions, CSSBeautifyOptions, JSBeautifyOptions } from "js-beautify";
|
|
@@ -33,6 +34,9 @@ export declare type MinistaConfig = {
|
|
|
33
34
|
outDir: string;
|
|
34
35
|
outName: string;
|
|
35
36
|
};
|
|
37
|
+
svgr: {
|
|
38
|
+
svgrOptions: SvgrOptions;
|
|
39
|
+
};
|
|
36
40
|
icons: {
|
|
37
41
|
useSprite: boolean;
|
|
38
42
|
srcDir: string;
|
|
@@ -91,6 +95,9 @@ export declare type MinistaUserConfig = {
|
|
|
91
95
|
outDir?: string;
|
|
92
96
|
outName?: string;
|
|
93
97
|
};
|
|
98
|
+
svgr?: {
|
|
99
|
+
svgrOptions?: SvgrOptions;
|
|
100
|
+
};
|
|
94
101
|
icons?: {
|
|
95
102
|
useSprite?: boolean;
|
|
96
103
|
srcDir?: string;
|
package/dist/vite.d.ts
CHANGED
|
@@ -1,7 +1,10 @@
|
|
|
1
1
|
import type { UserConfig as ViteConfig, Plugin } from "vite";
|
|
2
|
+
import type { Config as SvgrOptions } from "@svgr/core";
|
|
2
3
|
import type { Options as MdxOptions } from "@mdx-js/esbuild";
|
|
3
4
|
import type { MinistaResolveConfig, MinistaSvgstoreOptions } from "./types.js";
|
|
4
5
|
export declare function getViteConfig(config: MinistaResolveConfig, mdxConfig: MdxOptions): Promise<ViteConfig>;
|
|
5
6
|
export declare function resolveEntry(entry: string | string[] | {}): {};
|
|
6
7
|
export declare function vitePluginMinistaVirtualHtml(): Plugin;
|
|
8
|
+
/*! Fork: vite-plugin-svgr | https://github.com/pd4d10/vite-plugin-svgr */
|
|
9
|
+
export declare function vitePluginMinistaSvgr(svgrOptions: SvgrOptions): Plugin;
|
|
7
10
|
export declare function vitePluginMinistaSvgSpriteIcons(srcDir: string, options: MinistaSvgstoreOptions | undefined, output: string, tempOutput: string): Plugin;
|
package/dist/vite.js
CHANGED
|
@@ -7,7 +7,8 @@ import {
|
|
|
7
7
|
defineConfig as defineViteConfig,
|
|
8
8
|
searchForWorkspaceRoot,
|
|
9
9
|
createLogger,
|
|
10
|
-
mergeConfig as mergeViteConfig
|
|
10
|
+
mergeConfig as mergeViteConfig,
|
|
11
|
+
transformWithEsbuild
|
|
11
12
|
} from "vite";
|
|
12
13
|
import react from "@vitejs/plugin-react";
|
|
13
14
|
import mdx from "@mdx-js/rollup";
|
|
@@ -90,6 +91,8 @@ async function getViteConfig(config, mdxConfig) {
|
|
|
90
91
|
customLogger: createLogger("info", { prefix: "[minista]" })
|
|
91
92
|
});
|
|
92
93
|
const mergedViteConfig = mergeViteConfig(viteConfig, config.vite);
|
|
94
|
+
const svgrPlugin = vitePluginMinistaSvgr(config.assets.svgr.svgrOptions);
|
|
95
|
+
mergedViteConfig.plugins.push(svgrPlugin);
|
|
93
96
|
if (config.assets.icons.useSprite) {
|
|
94
97
|
const iconsPlugin = vitePluginMinistaSvgSpriteIcons(config.vitePluginSvgSpriteIconsSrcDir, config.assets.icons.svgstoreOptions, config.out + config.vitePluginSvgSpriteIconsOutput, config.vitePluginSvgSpriteIconsTempOutput);
|
|
95
98
|
const iconsResolveAlias = {
|
|
@@ -166,6 +169,29 @@ function vitePluginMinistaVirtualHtml() {
|
|
|
166
169
|
}
|
|
167
170
|
};
|
|
168
171
|
}
|
|
172
|
+
/*! Fork: vite-plugin-svgr | https://github.com/pd4d10/vite-plugin-svgr */
|
|
173
|
+
function vitePluginMinistaSvgr(svgrOptions) {
|
|
174
|
+
return {
|
|
175
|
+
name: "vite-plugin-minista-svgr",
|
|
176
|
+
async transform(code, id) {
|
|
177
|
+
if (id.endsWith(".svg")) {
|
|
178
|
+
const { transform: transformSvgr } = await import("@svgr/core");
|
|
179
|
+
const svgCode = await fs.promises.readFile(id, "utf8");
|
|
180
|
+
const componentCode = await transformSvgr(svgCode, svgrOptions, {
|
|
181
|
+
componentName: "ReactComponent",
|
|
182
|
+
filePath: id
|
|
183
|
+
});
|
|
184
|
+
const res = await transformWithEsbuild(componentCode, id, {
|
|
185
|
+
loader: "jsx"
|
|
186
|
+
});
|
|
187
|
+
return {
|
|
188
|
+
code: res.code,
|
|
189
|
+
map: null
|
|
190
|
+
};
|
|
191
|
+
}
|
|
192
|
+
}
|
|
193
|
+
};
|
|
194
|
+
}
|
|
169
195
|
function vitePluginMinistaSvgSpriteIcons(srcDir, options = {}, output, tempOutput) {
|
|
170
196
|
async function getSvgSpriteFile(spriteOutput) {
|
|
171
197
|
const svgFiles = await getFilePaths(srcDir, "svg");
|
|
@@ -223,5 +249,6 @@ export {
|
|
|
223
249
|
getViteConfig,
|
|
224
250
|
resolveEntry,
|
|
225
251
|
vitePluginMinistaSvgSpriteIcons,
|
|
252
|
+
vitePluginMinistaSvgr,
|
|
226
253
|
vitePluginMinistaVirtualHtml
|
|
227
254
|
};
|
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.2.1",
|
|
5
5
|
"bin": {
|
|
6
6
|
"minista": "./bin/minista.js"
|
|
7
7
|
},
|
|
@@ -10,7 +10,8 @@
|
|
|
10
10
|
"type": "module",
|
|
11
11
|
"files": [
|
|
12
12
|
"dist",
|
|
13
|
-
"lib"
|
|
13
|
+
"lib",
|
|
14
|
+
"client.d.ts"
|
|
14
15
|
],
|
|
15
16
|
"license": "MIT",
|
|
16
17
|
"homepage": "https://github.com/qrac/minista",
|
|
@@ -71,6 +72,7 @@
|
|
|
71
72
|
"@mdx-js/esbuild": "^2.1.1",
|
|
72
73
|
"@mdx-js/react": "^2.1.1",
|
|
73
74
|
"@mdx-js/rollup": "^2.1.1",
|
|
75
|
+
"@svgr/core": "^6.2.1",
|
|
74
76
|
"@vitejs/plugin-react": "^1.3.0",
|
|
75
77
|
"cac": "^6.7.12",
|
|
76
78
|
"deepmerge-ts": "^4.0.2",
|