minista 2.6.1 → 2.6.2
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.d.ts +3 -3
- package/dist/build.js +6 -12
- package/dist/config.d.ts +2 -2
- package/dist/css.d.ts +2 -2
- package/dist/css.js +9 -9
- package/dist/esbuild.d.ts +6 -14
- package/dist/esbuild.js +23 -29
- package/dist/types.d.ts +9 -11
- package/package.json +1 -1
package/dist/build.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import type { Options as MdxOptions } from "@mdx-js/esbuild";
|
|
2
2
|
import type { Config as SvgrOptions } from "@svgr/core";
|
|
3
3
|
import type { InlineConfig } from "vite";
|
|
4
|
-
import type { MinistaResolveConfig,
|
|
4
|
+
import type { MinistaResolveConfig, RootStaticContent, RootJsxContent, GlobalStaticData, GetGlobalStaticData, PageJsxContent, StaticData, StaticDataItem, GetStaticData, AliasArray, PartialModules, CssOptions } from "./types.js";
|
|
5
5
|
export declare function buildTempPages(entryPoints: string[], buildOptions: {
|
|
6
6
|
outBase: string;
|
|
7
7
|
outDir: string;
|
|
8
|
-
alias:
|
|
8
|
+
alias: AliasArray;
|
|
9
9
|
mdxConfig: MdxOptions;
|
|
10
10
|
svgrOptions: SvgrOptions;
|
|
11
11
|
cssOptions: CssOptions;
|
|
@@ -44,7 +44,7 @@ export declare function buildPartialStringIndex(partialModules: PartialModules,
|
|
|
44
44
|
}): Promise<void>;
|
|
45
45
|
export declare function buildPartialStringBundle(entryPoint: string, buildOptions: {
|
|
46
46
|
outFile: string;
|
|
47
|
-
alias:
|
|
47
|
+
alias: AliasArray;
|
|
48
48
|
mdxConfig: MdxOptions;
|
|
49
49
|
svgrOptions: SvgrOptions;
|
|
50
50
|
cssOptions: CssOptions;
|
package/dist/build.js
CHANGED
|
@@ -33,16 +33,14 @@ import {
|
|
|
33
33
|
import { systemConfig } from "./system.js";
|
|
34
34
|
import { getFilePath } from "./path.js";
|
|
35
35
|
import {
|
|
36
|
-
getEsbuildAlias,
|
|
37
36
|
resolvePlugin,
|
|
38
|
-
aliasPlugin,
|
|
39
37
|
svgrPlugin,
|
|
40
38
|
rawPlugin,
|
|
41
39
|
partialHydrationPlugin
|
|
42
40
|
} from "./esbuild.js";
|
|
43
41
|
import { renderHtml } from "./render.js";
|
|
44
42
|
import { slashEnd, reactStylesToString } from "./utils.js";
|
|
45
|
-
import {
|
|
43
|
+
import { cssModulePlugin } from "./css.js";
|
|
46
44
|
const __filename = url.fileURLToPath(import.meta.url);
|
|
47
45
|
const __dirname = path.dirname(__filename);
|
|
48
46
|
const ministaPkgUrl = path.resolve(__dirname + "/../package.json");
|
|
@@ -78,7 +76,6 @@ const userPkgHasPreact = [
|
|
|
78
76
|
...Object.keys(userPkg.devDependencies || {})
|
|
79
77
|
].includes("preact");
|
|
80
78
|
async function buildTempPages(entryPoints, buildOptions) {
|
|
81
|
-
const alias = getEsbuildAlias([buildOptions.alias]);
|
|
82
79
|
await esBuild({
|
|
83
80
|
entryPoints,
|
|
84
81
|
outbase: buildOptions.outBase,
|
|
@@ -95,12 +92,11 @@ async function buildTempPages(entryPoints, buildOptions) {
|
|
|
95
92
|
loader: esbuildLoaders,
|
|
96
93
|
plugins: [
|
|
97
94
|
resolvePlugin({ "react/jsx-runtime": "react/jsx-runtime.js" }),
|
|
98
|
-
|
|
99
|
-
CssModulePlugin(buildOptions.cssOptions),
|
|
95
|
+
cssModulePlugin(buildOptions.cssOptions, buildOptions.alias),
|
|
100
96
|
mdx(buildOptions.mdxConfig),
|
|
101
97
|
svgrPlugin(buildOptions.svgrOptions),
|
|
102
|
-
rawPlugin(),
|
|
103
|
-
partialHydrationPlugin()
|
|
98
|
+
rawPlugin(buildOptions.alias),
|
|
99
|
+
partialHydrationPlugin(buildOptions.alias)
|
|
104
100
|
]
|
|
105
101
|
}).catch(() => process.exit(1));
|
|
106
102
|
}
|
|
@@ -422,7 +418,6 @@ export { ${tmpExportsStr} }`;
|
|
|
422
418
|
});
|
|
423
419
|
}
|
|
424
420
|
async function buildPartialStringBundle(entryPoint, buildOptions) {
|
|
425
|
-
const alias = getEsbuildAlias([buildOptions.alias]);
|
|
426
421
|
await esBuild({
|
|
427
422
|
entryPoints: [entryPoint],
|
|
428
423
|
outfile: buildOptions.outFile,
|
|
@@ -436,11 +431,10 @@ async function buildPartialStringBundle(entryPoint, buildOptions) {
|
|
|
436
431
|
loader: esbuildLoaders,
|
|
437
432
|
plugins: [
|
|
438
433
|
resolvePlugin({ "react/jsx-runtime": "react/jsx-runtime.js" }),
|
|
439
|
-
|
|
440
|
-
CssModulePlugin(buildOptions.cssOptions),
|
|
434
|
+
cssModulePlugin(buildOptions.cssOptions, buildOptions.alias),
|
|
441
435
|
mdx(buildOptions.mdxConfig),
|
|
442
436
|
svgrPlugin(buildOptions.svgrOptions),
|
|
443
|
-
rawPlugin()
|
|
437
|
+
rawPlugin(buildOptions.alias)
|
|
444
438
|
]
|
|
445
439
|
}).catch(() => process.exit(1));
|
|
446
440
|
}
|
package/dist/config.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { AliasOptions as ViteAliasOptions } from "vite";
|
|
2
|
-
import type { MinistaConfig, MinistaUserConfig, MinistaResolveConfig, MinistaResolveAliasInput,
|
|
2
|
+
import type { MinistaConfig, MinistaUserConfig, MinistaResolveConfig, MinistaResolveAliasInput, AliasArray } from "./types.js";
|
|
3
3
|
export declare const defaultConfig: MinistaConfig;
|
|
4
4
|
export declare function mergeConfig(userConfig: MinistaUserConfig): Promise<MinistaConfig>;
|
|
5
|
-
export declare function mergeAlias(configAlias: MinistaResolveAliasInput, viteConfigAlias: ViteAliasOptions): Promise<
|
|
5
|
+
export declare function mergeAlias(configAlias: MinistaResolveAliasInput, viteConfigAlias: ViteAliasOptions): Promise<AliasArray>;
|
|
6
6
|
export declare function resolveConfig(config: MinistaConfig): Promise<MinistaResolveConfig>;
|
|
7
7
|
export declare function getConfig(userConfig: MinistaUserConfig): Promise<MinistaResolveConfig>;
|
package/dist/css.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { Plugin } from "esbuild";
|
|
2
|
-
import type { CssOptions } from "./types.js";
|
|
3
|
-
export declare function
|
|
2
|
+
import type { AliasArray, CssOptions } from "./types.js";
|
|
3
|
+
export declare function cssModulePlugin(options: CssOptions, alias: AliasArray): Plugin;
|
package/dist/css.js
CHANGED
|
@@ -19,9 +19,9 @@ var __spreadValues = (a, b) => {
|
|
|
19
19
|
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
20
20
|
import React from "react";
|
|
21
21
|
import fs from "fs-extra";
|
|
22
|
-
import path from "path";
|
|
23
22
|
import postcss from "postcss";
|
|
24
23
|
import postcssModules from "postcss-modules";
|
|
24
|
+
import { getEsbuildResolvePath } from "./esbuild.js";
|
|
25
25
|
var PreprocessLang = /* @__PURE__ */ ((PreprocessLang2) => {
|
|
26
26
|
PreprocessLang2["less"] = "less";
|
|
27
27
|
PreprocessLang2["sass"] = "sass";
|
|
@@ -110,7 +110,7 @@ async function buildJs(filepath, options) {
|
|
|
110
110
|
const classNames = JSON.stringify(cssModulesJSON);
|
|
111
111
|
return `export default ${classNames};`;
|
|
112
112
|
}
|
|
113
|
-
function
|
|
113
|
+
function cssModulePlugin(options, alias) {
|
|
114
114
|
const filter = new RegExp(`\\.module${cssLangs}`);
|
|
115
115
|
return {
|
|
116
116
|
name: PLUGIN,
|
|
@@ -119,19 +119,19 @@ function CssModulePlugin(options) {
|
|
|
119
119
|
build.onResolve({ filter, namespace: "file" }, async (args) => {
|
|
120
120
|
if (!options.modules)
|
|
121
121
|
return args;
|
|
122
|
-
const
|
|
123
|
-
if (results.has(
|
|
124
|
-
return results.get(
|
|
125
|
-
const content = await buildJs(
|
|
122
|
+
const resolvePath = getEsbuildResolvePath(args, alias);
|
|
123
|
+
if (results.has(resolvePath))
|
|
124
|
+
return results.get(resolvePath);
|
|
125
|
+
const content = await buildJs(resolvePath, options);
|
|
126
126
|
const result = {
|
|
127
|
-
path:
|
|
127
|
+
path: resolvePath,
|
|
128
128
|
namespace: PLUGIN,
|
|
129
129
|
pluginData: {
|
|
130
130
|
content
|
|
131
131
|
}
|
|
132
132
|
};
|
|
133
133
|
if (options.modules.cache)
|
|
134
|
-
results.set(
|
|
134
|
+
results.set(resolvePath, result);
|
|
135
135
|
return result;
|
|
136
136
|
});
|
|
137
137
|
build.onLoad({ filter, namespace: PLUGIN }, (args) => {
|
|
@@ -146,5 +146,5 @@ function CssModulePlugin(options) {
|
|
|
146
146
|
};
|
|
147
147
|
}
|
|
148
148
|
export {
|
|
149
|
-
|
|
149
|
+
cssModulePlugin
|
|
150
150
|
};
|
package/dist/esbuild.d.ts
CHANGED
|
@@ -1,19 +1,11 @@
|
|
|
1
|
-
import type { Plugin } from "esbuild";
|
|
1
|
+
import type { Plugin, OnResolveArgs } from "esbuild";
|
|
2
2
|
import type { Config as SvgrOptions } from "@svgr/core";
|
|
3
|
-
import type {
|
|
4
|
-
export declare function
|
|
5
|
-
[key: string]: string;
|
|
6
|
-
};
|
|
3
|
+
import type { AliasObject, AliasArray } from "./types.js";
|
|
4
|
+
export declare function getEsbuildResolvePath(args: OnResolveArgs, alias: AliasArray): string;
|
|
7
5
|
/*! Fork: esbuild-plugin-resolve | https://github.com/markwylde/esbuild-plugin-resolve */
|
|
8
|
-
export declare function resolvePlugin(
|
|
9
|
-
[key: string]: string;
|
|
10
|
-
}): Plugin;
|
|
11
|
-
/*! Fork: esbuild-plugin-alias | https://github.com/igoradamenko/esbuild-plugin-alias */
|
|
12
|
-
export declare function aliasPlugin(options: {
|
|
13
|
-
[key: string]: string;
|
|
14
|
-
}): Plugin;
|
|
6
|
+
export declare function resolvePlugin(alias: AliasObject): Plugin;
|
|
15
7
|
/*! Fork: esbuild-plugin-svgr | https://github.com/kazijawad/esbuild-plugin-svgr */
|
|
16
8
|
export declare function svgrPlugin(options: SvgrOptions): Plugin;
|
|
17
9
|
/*! Fork: esbuild-plugin-resolve | https://github.com/hannoeru/esbuild-plugin-raw */
|
|
18
|
-
export declare function rawPlugin(): Plugin;
|
|
19
|
-
export declare function partialHydrationPlugin(): Plugin;
|
|
10
|
+
export declare function rawPlugin(alias: AliasArray): Plugin;
|
|
11
|
+
export declare function partialHydrationPlugin(alias: AliasArray): Plugin;
|
package/dist/esbuild.js
CHANGED
|
@@ -19,15 +19,24 @@ import fs from "fs-extra";
|
|
|
19
19
|
import path from "path";
|
|
20
20
|
import { v4 as uuidv4 } from "uuid";
|
|
21
21
|
import { systemConfig } from "./system.js";
|
|
22
|
-
function
|
|
23
|
-
const
|
|
24
|
-
const result = Object.assign({}, ...alias.map((item) => ({
|
|
22
|
+
function getEsbuildResolvePath(args, alias) {
|
|
23
|
+
const aliasObject = Object.assign({}, ...alias.map((item) => ({
|
|
25
24
|
[item.find]: item.replacement
|
|
26
25
|
})));
|
|
27
|
-
|
|
26
|
+
function escapeRegExp(find) {
|
|
27
|
+
return find.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
28
|
+
}
|
|
29
|
+
const aliasKeys = Object.keys(aliasObject);
|
|
30
|
+
const aliasReg = new RegExp(`^(${aliasKeys.map((x) => escapeRegExp(x)).join("|")})`);
|
|
31
|
+
const aliasPath = args.path.replace(aliasReg, function(match) {
|
|
32
|
+
return aliasObject[match];
|
|
33
|
+
});
|
|
34
|
+
const absolutePath = path.isAbsolute(aliasPath) ? aliasPath : path.join(args.resolveDir, aliasPath);
|
|
35
|
+
const replacedPath = absolutePath.replaceAll("\\", "/");
|
|
36
|
+
return replacedPath;
|
|
28
37
|
}
|
|
29
38
|
/*! Fork: esbuild-plugin-resolve | https://github.com/markwylde/esbuild-plugin-resolve */
|
|
30
|
-
function resolvePlugin(
|
|
39
|
+
function resolvePlugin(alias) {
|
|
31
40
|
function resolvePluginIntercept(build, moduleName, moduleTarget) {
|
|
32
41
|
const filter = new RegExp("^" + moduleName + "(?:\\/.*)?$");
|
|
33
42
|
build.onResolve({ filter }, async (args) => {
|
|
@@ -54,28 +63,12 @@ function resolvePlugin(options) {
|
|
|
54
63
|
return {
|
|
55
64
|
name: "esbuild-resolve",
|
|
56
65
|
setup: (build) => {
|
|
57
|
-
for (const moduleName of Object.keys(
|
|
58
|
-
resolvePluginIntercept(build, moduleName,
|
|
66
|
+
for (const moduleName of Object.keys(alias)) {
|
|
67
|
+
resolvePluginIntercept(build, moduleName, alias[moduleName]);
|
|
59
68
|
}
|
|
60
69
|
}
|
|
61
70
|
};
|
|
62
71
|
}
|
|
63
|
-
/*! Fork: esbuild-plugin-alias | https://github.com/igoradamenko/esbuild-plugin-alias */
|
|
64
|
-
function aliasPlugin(options) {
|
|
65
|
-
function escapeRegExp(name) {
|
|
66
|
-
return name.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
67
|
-
}
|
|
68
|
-
const aliases = Object.keys(options);
|
|
69
|
-
const re = new RegExp(`^(${aliases.map((x) => escapeRegExp(x)).join("|")})$`);
|
|
70
|
-
return {
|
|
71
|
-
name: "esbuild-alias",
|
|
72
|
-
setup(build) {
|
|
73
|
-
build.onResolve({ filter: re }, (args) => ({
|
|
74
|
-
path: options[args.path]
|
|
75
|
-
}));
|
|
76
|
-
}
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
72
|
/*! Fork: esbuild-plugin-svgr | https://github.com/kazijawad/esbuild-plugin-svgr */
|
|
80
73
|
function svgrPlugin(options) {
|
|
81
74
|
return {
|
|
@@ -94,13 +87,14 @@ function svgrPlugin(options) {
|
|
|
94
87
|
};
|
|
95
88
|
}
|
|
96
89
|
/*! Fork: esbuild-plugin-resolve | https://github.com/hannoeru/esbuild-plugin-raw */
|
|
97
|
-
function rawPlugin() {
|
|
90
|
+
function rawPlugin(alias) {
|
|
98
91
|
return {
|
|
99
92
|
name: "esbuild-raw",
|
|
100
93
|
setup(build) {
|
|
101
94
|
build.onResolve({ filter: /\?raw$/ }, (args) => {
|
|
95
|
+
const resolvePath = getEsbuildResolvePath(args, alias);
|
|
102
96
|
return {
|
|
103
|
-
path:
|
|
97
|
+
path: resolvePath,
|
|
104
98
|
namespace: "raw-loader"
|
|
105
99
|
};
|
|
106
100
|
});
|
|
@@ -113,13 +107,14 @@ function rawPlugin() {
|
|
|
113
107
|
}
|
|
114
108
|
};
|
|
115
109
|
}
|
|
116
|
-
function partialHydrationPlugin() {
|
|
110
|
+
function partialHydrationPlugin(alias) {
|
|
117
111
|
return {
|
|
118
112
|
name: "esbuild-partial-hydration",
|
|
119
113
|
setup(build) {
|
|
120
114
|
build.onResolve({ filter: /\?ph$/ }, (args) => {
|
|
115
|
+
const resolvePath = getEsbuildResolvePath(args, alias);
|
|
121
116
|
return {
|
|
122
|
-
path:
|
|
117
|
+
path: resolvePath,
|
|
123
118
|
namespace: "partial-hydration-loader"
|
|
124
119
|
};
|
|
125
120
|
});
|
|
@@ -143,8 +138,7 @@ function partialHydrationPlugin() {
|
|
|
143
138
|
};
|
|
144
139
|
}
|
|
145
140
|
export {
|
|
146
|
-
|
|
147
|
-
getEsbuildAlias,
|
|
141
|
+
getEsbuildResolvePath,
|
|
148
142
|
partialHydrationPlugin,
|
|
149
143
|
rawPlugin,
|
|
150
144
|
resolvePlugin,
|
package/dist/types.d.ts
CHANGED
|
@@ -166,18 +166,9 @@ export declare type MinistaUserConfig = {
|
|
|
166
166
|
};
|
|
167
167
|
};
|
|
168
168
|
export declare type MinistaResolveConfig = MinistaConfig & MinistaResolveAliasConfig & MinistaResolvePathConfig;
|
|
169
|
-
export declare type MinistaResolveAliasInput =
|
|
170
|
-
[key: string]: string;
|
|
171
|
-
} | {
|
|
172
|
-
find: string;
|
|
173
|
-
replacement: string;
|
|
174
|
-
}[];
|
|
175
|
-
export declare type MinistaResolveAlias = {
|
|
176
|
-
find: string;
|
|
177
|
-
replacement: string;
|
|
178
|
-
}[];
|
|
169
|
+
export declare type MinistaResolveAliasInput = AliasObject | AliasArray;
|
|
179
170
|
export declare type MinistaResolveAliasConfig = {
|
|
180
|
-
alias:
|
|
171
|
+
alias: AliasArray;
|
|
181
172
|
};
|
|
182
173
|
export declare type MinistaResolvePathConfig = {
|
|
183
174
|
rootSrcDir: string;
|
|
@@ -269,6 +260,13 @@ export declare type StaticDataCache = {
|
|
|
269
260
|
key: [StaticDataList];
|
|
270
261
|
} | {};
|
|
271
262
|
export declare type GetStaticData = () => Promise<StaticData>;
|
|
263
|
+
export declare type AliasObject = {
|
|
264
|
+
[key: string]: string;
|
|
265
|
+
};
|
|
266
|
+
export declare type AliasArray = {
|
|
267
|
+
find: string;
|
|
268
|
+
replacement: string;
|
|
269
|
+
}[];
|
|
272
270
|
export declare type PartialModules = {
|
|
273
271
|
id: string;
|
|
274
272
|
phId: string;
|