@uni-helper/vite-plugin-uni-pages 0.2.6 → 0.2.7
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 +1 -1
- package/dist/index.cjs +27 -15
- package/dist/index.d.cts +828 -0
- package/dist/index.d.mts +828 -0
- package/dist/index.d.ts +16 -7
- package/dist/index.mjs +27 -15
- package/package.json +14 -9
package/README.md
CHANGED
|
@@ -127,7 +127,7 @@ export interface Options {
|
|
|
127
127
|
|
|
128
128
|
## TODO
|
|
129
129
|
|
|
130
|
-
- [
|
|
130
|
+
- [x] only update the changed page
|
|
131
131
|
- [x] [vite-plugin-uni-middleware](https://github.com/uni-helper/vite-plugin-uni-middleware)
|
|
132
132
|
- [x] pages [type](./src/config/types.ts)
|
|
133
133
|
|
package/dist/index.cjs
CHANGED
|
@@ -147,8 +147,8 @@ function mergePageMetaDataArray(pageMetaData) {
|
|
|
147
147
|
}
|
|
148
148
|
return result;
|
|
149
149
|
}
|
|
150
|
-
async function getPagesConfigSourcePaths() {
|
|
151
|
-
return await fg__default(
|
|
150
|
+
async function getPagesConfigSourcePaths(configSource) {
|
|
151
|
+
return await fg__default(configSource.map((v) => v.files).flat(), {
|
|
152
152
|
deep: 0,
|
|
153
153
|
onlyFiles: true,
|
|
154
154
|
absolute: true
|
|
@@ -178,6 +178,7 @@ function useCachedPages() {
|
|
|
178
178
|
|
|
179
179
|
function resolveOptions(userOptions, viteRoot) {
|
|
180
180
|
const {
|
|
181
|
+
configSource = "pages.config.(ts|mts|cts|js|cjs|mjs|json)",
|
|
181
182
|
homePage = ["pages/index", "pages/index/index"],
|
|
182
183
|
mergePages = true,
|
|
183
184
|
dir = "src/pages",
|
|
@@ -207,9 +208,11 @@ function resolveOptions(userOptions, viteRoot) {
|
|
|
207
208
|
const root = viteRoot || slash(process__default.cwd());
|
|
208
209
|
const resolvedDirs = resolvePageDirs(dir, root, exclude);
|
|
209
210
|
const resolvedSubDirs = subPackages.map((dir2) => slash(dir2));
|
|
210
|
-
const
|
|
211
|
+
const resolvedHomePage = typeof homePage === "string" ? [homePage] : homePage;
|
|
212
|
+
const resolvedConfigSource = typeof configSource === "string" ? [{ files: configSource }] : configSource;
|
|
211
213
|
const resolvedOptions = {
|
|
212
|
-
|
|
214
|
+
configSource: Array.isArray(resolvedConfigSource) ? resolvedConfigSource : [resolvedConfigSource],
|
|
215
|
+
homePage: resolvedHomePage,
|
|
213
216
|
mergePages,
|
|
214
217
|
dirs: resolvedDirs,
|
|
215
218
|
subPackages: resolvedSubDirs,
|
|
@@ -262,15 +265,27 @@ function writeFileSync(path, content) {
|
|
|
262
265
|
fs__default.writeFileSync(path, content, { encoding: "utf-8" });
|
|
263
266
|
}
|
|
264
267
|
|
|
268
|
+
var __defProp = Object.defineProperty;
|
|
269
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
270
|
+
var __publicField = (obj, key, value) => {
|
|
271
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
272
|
+
return value;
|
|
273
|
+
};
|
|
265
274
|
let lsatPagesJson = "";
|
|
266
275
|
const { setCache, hasChanged } = useCachedPages();
|
|
267
276
|
class PageContext {
|
|
268
277
|
constructor(userOptions, viteRoot = process__default.cwd()) {
|
|
269
|
-
this
|
|
270
|
-
this
|
|
271
|
-
this
|
|
272
|
-
this
|
|
273
|
-
this
|
|
278
|
+
__publicField(this, "_server");
|
|
279
|
+
__publicField(this, "pagesGlobConfig");
|
|
280
|
+
__publicField(this, "pagesPath", []);
|
|
281
|
+
__publicField(this, "subPagesPath", {});
|
|
282
|
+
__publicField(this, "pageMetaData", []);
|
|
283
|
+
__publicField(this, "subPageMetaData", []);
|
|
284
|
+
__publicField(this, "resolvedPagesJSONPath", "");
|
|
285
|
+
__publicField(this, "rawOptions");
|
|
286
|
+
__publicField(this, "root");
|
|
287
|
+
__publicField(this, "options");
|
|
288
|
+
__publicField(this, "logger");
|
|
274
289
|
this.rawOptions = userOptions;
|
|
275
290
|
this.root = slash(viteRoot);
|
|
276
291
|
debug.options("root", this.root);
|
|
@@ -288,11 +303,8 @@ class PageContext {
|
|
|
288
303
|
this.logger = logger;
|
|
289
304
|
}
|
|
290
305
|
async loadUserPagesConfig() {
|
|
291
|
-
const
|
|
292
|
-
|
|
293
|
-
this.logger?.warn("Can't found pages.config, please create pages.config.(ts|mts|cts|js|cjs|mjs|json)");
|
|
294
|
-
process__default.exit(-1);
|
|
295
|
-
}
|
|
306
|
+
const sources = this.options.configSource;
|
|
307
|
+
const { config } = await unconfig.loadConfig({ cwd: this.root, sources, defaults: {} });
|
|
296
308
|
this.pagesGlobConfig = config;
|
|
297
309
|
debug.options(config);
|
|
298
310
|
}
|
|
@@ -320,7 +332,7 @@ class PageContext {
|
|
|
320
332
|
}
|
|
321
333
|
async setupWatcher(watcher) {
|
|
322
334
|
if (!uniEnv.isH5) {
|
|
323
|
-
const configs = await getPagesConfigSourcePaths();
|
|
335
|
+
const configs = await getPagesConfigSourcePaths(this.options.configSource);
|
|
324
336
|
watcher.add(configs);
|
|
325
337
|
}
|
|
326
338
|
const targetDirs = [...this.options.dirs, ...this.options.subPackages].map((v) => slash(path__default.resolve(this.root, v)));
|