@uni-helper/vite-plugin-uni-pages 0.0.7 → 0.1.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/index.cjs CHANGED
@@ -1,293 +1,392 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
22
- mod
23
- ));
24
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
1
+ 'use strict';
25
2
 
26
- // src/index.ts
27
- var src_exports = {};
28
- __export(src_exports, {
29
- VitePluginUniPages: () => VitePluginUniPages,
30
- default: () => src_default,
31
- definePages: () => definePages
32
- });
33
- module.exports = __toCommonJS(src_exports);
34
- var import_vite3 = require("vite");
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const path = require('path');
6
+ const MagicString = require('magic-string');
7
+ const chokidar = require('chokidar');
8
+ const vite = require('vite');
9
+ const unconfig = require('unconfig');
10
+ const Debug = require('debug');
11
+ const lodashEs = require('lodash-es');
12
+ const fg = require('fast-glob');
13
+ const fs = require('fs');
14
+ const JSON5 = require('json5');
15
+ const yaml = require('yaml');
16
+ const compilerSfc = require('@vue/compiler-sfc');
17
+
18
+ function slash(str) {
19
+ return str.replace(/\\/g, "/");
20
+ }
35
21
 
36
- // src/utils.ts
37
- var import_path = require("path");
38
- var import_vite = require("vite");
39
- var import_consola = __toESM(require("consola"), 1);
40
- var isPagePath = (path, options) => {
41
- const dirPath = (0, import_path.resolve)(process.cwd(), options.pagesDir);
42
- const filter = (0, import_vite.createFilter)(
43
- dirPath + "/**/*.(vue|nvue|uvue)",
44
- options.exclude
45
- );
46
- return filter(path);
22
+ const MODULE_ID_VIRTUAL = "virtual:uni-pages";
23
+ const RESOLVED_MODULE_ID_VIRTUAL = `\0${MODULE_ID_VIRTUAL}`;
24
+ const OUTPUT_NAME = "pages.json";
25
+ const FILE_EXTENSIONS = ["vue", "nvue", "uvue"];
26
+
27
+ function invalidatePagesModule(server) {
28
+ const { moduleGraph } = server;
29
+ const mods = moduleGraph.getModulesByFile(RESOLVED_MODULE_ID_VIRTUAL);
30
+ if (mods) {
31
+ const seen = /* @__PURE__ */ new Set();
32
+ mods.forEach((mod) => {
33
+ moduleGraph.invalidateModule(mod, seen);
34
+ });
35
+ }
36
+ }
37
+ const debug = {
38
+ hmr: Debug("vite-plugin-uni-pages:hmr"),
39
+ routeBlock: Debug("vite-plugin-uni-pages:routeBlock"),
40
+ options: Debug("vite-plugin-uni-pages:options"),
41
+ pages: Debug("vite-plugin-uni-pages:pages"),
42
+ error: Debug("vite-plugin-uni-pages:error")
47
43
  };
48
- var logger = import_consola.default.create({
49
- defaults: {
50
- tag: "vite-plugin-uni-pages"
44
+ function extsToGlob(extensions) {
45
+ return extensions.length > 1 ? `{${extensions.join(",")}}` : extensions[0] || "";
46
+ }
47
+ function isTargetFile(path) {
48
+ const ext = path.split(".").pop();
49
+ return FILE_EXTENSIONS.includes(ext);
50
+ }
51
+ function isConfigFile(path) {
52
+ return path.includes("pages.config");
53
+ }
54
+ function mergePageMetaDataArray(pageMetaData) {
55
+ const pageMetaDataObj = lodashEs.groupBy(pageMetaData, "path");
56
+ const result = [];
57
+ for (const path in pageMetaDataObj) {
58
+ const _pageMetaData = pageMetaDataObj[path];
59
+ const options = _pageMetaData[0];
60
+ for (const page of _pageMetaData) {
61
+ options.style = Object.assign(options.style ?? {}, page.style ?? {});
62
+ Object.assign(options, page);
63
+ }
64
+ result.push(options);
51
65
  }
52
- });
66
+ return result;
67
+ }
68
+
69
+ function resolveOptions(userOptions, viteRoot) {
70
+ const {
71
+ mergePages = true,
72
+ dir = "src/pages",
73
+ outDir = "src",
74
+ exclude = ["node_modules", ".git", "**/__*__/**"],
75
+ routeBlockLang = "json5",
76
+ onBeforeLoadUserConfig = () => {
77
+ },
78
+ onAfterLoadUserConfig = () => {
79
+ },
80
+ onBeforeScanPages = () => {
81
+ },
82
+ onAfterScanPages = () => {
83
+ },
84
+ onBeforeMergePageMetaData = () => {
85
+ },
86
+ onAfterMergePageMetaData = () => {
87
+ },
88
+ onBeforeWriteFile = () => {
89
+ },
90
+ onAfterWriteFile = () => {
91
+ }
92
+ } = userOptions;
93
+ const root = viteRoot || slash(process.cwd());
94
+ const resolvedDirs = resolvePageDirs(dir, root, exclude);
95
+ const resolvedOptions = {
96
+ mergePages,
97
+ dirs: resolvedDirs,
98
+ outDir,
99
+ exclude,
100
+ routeBlockLang,
101
+ root,
102
+ onBeforeLoadUserConfig,
103
+ onAfterLoadUserConfig,
104
+ onBeforeScanPages,
105
+ onAfterScanPages,
106
+ onBeforeMergePageMetaData,
107
+ onAfterMergePageMetaData,
108
+ onBeforeWriteFile,
109
+ onAfterWriteFile
110
+ };
111
+ return resolvedOptions;
112
+ }
113
+ function resolvePageDirs(dir, root, exclude) {
114
+ const dirs = fg.sync(slash(dir), {
115
+ ignore: exclude,
116
+ onlyDirectories: true,
117
+ dot: true,
118
+ unique: true,
119
+ cwd: root
120
+ });
121
+ return dirs;
122
+ }
53
123
 
54
- // src/constant.ts
55
- var virtualModuleId = "virtual:uni-pages";
56
- var resolvedVirtualModuleId = "\0" + virtualModuleId;
124
+ function getPageFiles(path, options) {
125
+ const { exclude } = options;
126
+ const ext = extsToGlob(FILE_EXTENSIONS);
127
+ const files = fg.sync(`**/*.${ext}`, {
128
+ ignore: exclude,
129
+ onlyFiles: true,
130
+ cwd: path
131
+ });
132
+ return files;
133
+ }
134
+ function checkPagesJsonFile(path) {
135
+ if (!fs.existsSync(path))
136
+ writeFileSync(path, JSON.stringify({ pages: [{ path: "" }] }, null, 2));
137
+ }
138
+ function writeFileSync(path, content) {
139
+ fs.writeFileSync(path, content, { encoding: "utf-8" });
140
+ }
57
141
 
58
- // src/context/index.ts
59
- var import_path2 = require("path");
60
- var import_unconfig = require("unconfig");
61
- var import_vite2 = require("vite");
62
- var import_fast_glob = __toESM(require("fast-glob"), 1);
63
- var import_jsonc_parser = require("jsonc-parser");
64
- var import_compiler_dom = require("@vue/compiler-dom");
65
- var import_fs = __toESM(require("fs"), 1);
66
- var import_defu = require("defu");
67
- var Context = class {
68
- constructor(options) {
69
- this.pagesPathInfo = [];
70
- this.pagesMeta = [];
71
- this.options = options;
72
- this.createOrUpdatePagesJSON();
142
+ async function parseSFC(code) {
143
+ try {
144
+ return compilerSfc.parse(code, {
145
+ pad: "space"
146
+ }).descriptor || compilerSfc.parse({
147
+ source: code
148
+ });
149
+ } catch {
150
+ throw new Error(
151
+ `[vite-plugin-uni-pages] Vue3's "@vue/compiler-sfc" is required.`
152
+ );
153
+ }
154
+ }
155
+ function parseCustomBlock(block, filePath, options) {
156
+ const lang = block.lang ?? options.routeBlockLang;
157
+ debug.routeBlock(`use ${lang} parser`);
158
+ if (lang === "json5") {
159
+ try {
160
+ return JSON5.parse(block.content);
161
+ } catch (err) {
162
+ throw new Error(
163
+ `Invalid JSON5 format of <${block.type}> content in ${filePath}
164
+ ${err.message}`
165
+ );
166
+ }
167
+ } else if (lang === "json") {
168
+ try {
169
+ return JSON.parse(block.content);
170
+ } catch (err) {
171
+ throw new Error(
172
+ `Invalid JSON format of <${block.type}> content in ${filePath}
173
+ ${err.message}`
174
+ );
175
+ }
176
+ } else if (lang === "yaml" || lang === "yml") {
177
+ try {
178
+ return yaml.parse(block.content);
179
+ } catch (err) {
180
+ throw new Error(
181
+ `Invalid YAML format of <${block.type}> content in ${filePath}
182
+ ${err.message}`
183
+ );
184
+ }
185
+ }
186
+ }
187
+ async function getRouteBlock(path, options) {
188
+ const content = fs.readFileSync(path, "utf8");
189
+ const parsedSFC = await parseSFC(content);
190
+ const blockStr = parsedSFC?.customBlocks.find((b) => b.type === "route");
191
+ if (!blockStr)
192
+ return;
193
+ const result = parseCustomBlock(blockStr, path, options);
194
+ return result;
195
+ }
196
+
197
+ class PageContext {
198
+ constructor(userOptions, viteRoot = process.cwd()) {
199
+ this.pagesPath = [];
200
+ this.pageMetaData = [];
201
+ this.resolvedPagesJSONPath = "";
202
+ this.rawOptions = userOptions;
203
+ this.root = slash(viteRoot);
204
+ debug.options("root", this.root);
205
+ this.options = resolveOptions(userOptions, this.root);
206
+ this.resolvedPagesJSONPath = path.join(this.root, this.options.outDir, OUTPUT_NAME);
207
+ debug.options(this.options);
208
+ }
209
+ setLogger(logger) {
210
+ this.logger = logger;
73
211
  }
74
212
  async loadUserPagesConfig() {
75
- const { config } = await (0, import_unconfig.loadConfig)({
76
- sources: [
77
- {
78
- files: "pages.config"
79
- }
80
- ],
81
- merge: false
82
- });
213
+ const { config } = await unconfig.loadConfig({ sources: [{ files: "pages.config" }] });
83
214
  if (!config) {
84
- logger.error(
85
- "Can't found pages.config, please create pages.config.(ts|mts|cts|js|cjs|mjs|json)"
86
- );
215
+ this.logger?.warn("Can't found pages.config, please create pages.config.(ts|mts|cts|js|cjs|mjs|json)");
87
216
  process.exit(-1);
88
217
  }
89
- logger.debug("Loaded user pages config", config);
90
- this.pagesConfig = config;
218
+ this.pagesGlobConfig = config;
219
+ debug.options(config);
91
220
  }
92
221
  async scanPages() {
93
- const files = await (0, import_fast_glob.default)("**/*.(vue|nvue|uvue)", {
94
- ignore: ["node_modules", ".git", "**/__*__/*", ...this.options.exclude],
95
- onlyFiles: true,
96
- cwd: (0, import_path2.resolve)(process.cwd(), this.options.pagesDir)
222
+ const pageDirFiles = this.options.dirs.map((dir) => {
223
+ const pagesDirPath = slash(path.resolve(this.options.root, dir));
224
+ const basePath = slash(path.join(this.options.root, this.options.outDir));
225
+ const files = getPageFiles(pagesDirPath, this.options);
226
+ debug.pages(dir, files);
227
+ const pagePaths = files.map((file) => slash(file)).map((file) => ({
228
+ relativePath: path.relative(basePath, slash(path.resolve(pagesDirPath, file))),
229
+ absolutePath: slash(path.resolve(pagesDirPath, file))
230
+ }));
231
+ return { dir, files: pagePaths };
97
232
  });
98
- const basePath = (0, import_path2.relative)(
99
- (0, import_path2.resolve)(process.cwd(), this.options.outDir),
100
- this.options.pagesDir
101
- );
102
- this.pagesPathInfo = files.map((file) => {
103
- return {
104
- relative: (0, import_vite2.normalizePath)((0, import_path2.join)(basePath, file)),
105
- absolute: (0, import_vite2.normalizePath)(
106
- (0, import_path2.resolve)(process.cwd(), this.options.pagesDir, file)
107
- )
108
- };
109
- });
110
- logger.debug("Scanned pages dir", this.pagesPathInfo);
233
+ this.pagesPath = pageDirFiles.map((page) => page.files).flat();
234
+ debug.pages(this.pagesPath);
235
+ }
236
+ setupViteServer(server) {
237
+ if (this._server === server)
238
+ return;
239
+ this._server = server;
240
+ this.setupWatcher(server.watcher);
111
241
  }
112
- async parsePage({ relative: relative2, absolute }) {
113
- const code = await import_fs.default.promises.readFile(absolute, {
114
- encoding: "utf-8"
242
+ setupWatcher(watcher) {
243
+ watcher.on("add", async (path2) => {
244
+ path2 = slash(path2);
245
+ if (!isTargetFile(path2))
246
+ return;
247
+ debug.pages(`File added: ${path2}`);
248
+ this.updatePagesJSON();
249
+ this.onUpdate();
115
250
  });
116
- const t = (0, import_compiler_dom.parse)(code);
117
- const path = relative2.replace((0, import_path2.extname)(relative2), "");
118
- let pageMeta = {
119
- path,
120
- type: "page"
121
- };
122
- t == null ? void 0 : t.children.forEach((v) => {
123
- var _a;
124
- if (v.type !== 1) {
251
+ watcher.on("change", async (path2) => {
252
+ path2 = slash(path2);
253
+ if (!isTargetFile(path2) && !isConfigFile(path2))
125
254
  return;
126
- }
127
- if (v.tag === "route") {
128
- v.props.forEach((prop) => {
129
- var _a2;
130
- if (prop.type === 6 && prop.name === "type") {
131
- pageMeta.type = ((_a2 = prop.value) == null ? void 0 : _a2.content) ?? pageMeta.type;
132
- }
133
- });
134
- const astContent = (_a = v.children) == null ? void 0 : _a[0];
135
- if (astContent && astContent.type === 2) {
136
- const _pageMeta = (0, import_jsonc_parser.parse)(astContent.content);
137
- Object.keys(_pageMeta).forEach((key) => {
138
- pageMeta[key] = _pageMeta[key];
139
- });
140
- pageMeta["path"] = path;
141
- }
142
- }
255
+ debug.pages(`File changed: ${path2}`);
256
+ this.updatePagesJSON();
257
+ this.onUpdate();
258
+ });
259
+ watcher.on("unlink", async (path2) => {
260
+ path2 = slash(path2);
261
+ if (!isTargetFile(path2))
262
+ return;
263
+ debug.pages(`File removed: ${path2}`);
264
+ this.updatePagesJSON();
265
+ this.onUpdate();
143
266
  });
144
- return pageMeta;
145
267
  }
146
- async mergePagesMeta() {
147
- var _a;
148
- const pagesMeta = await Promise.all(
149
- (_a = this.pagesPathInfo) == null ? void 0 : _a.map(async (page) => await this.parsePage(page))
150
- );
151
- const pages = Object.values((0, import_defu.defu)({}, pagesMeta, this.pagesConfig.pages));
152
- pages.sort((a) => a.type === "home" ? -1 : 0);
153
- this.pagesMeta = pages;
154
- logger.debug("merged pages", this.pagesMeta);
268
+ onUpdate() {
269
+ if (!this._server)
270
+ return;
271
+ invalidatePagesModule(this._server);
272
+ debug.hmr("Reload generated pages.");
273
+ this._server.ws.send({
274
+ type: "full-reload"
275
+ });
276
+ }
277
+ async parsePage(page) {
278
+ const { relativePath, absolutePath } = page;
279
+ const routeBlock = await getRouteBlock(absolutePath, this.options);
280
+ const relativePathWithFileName = relativePath.replace(path.extname(relativePath), "");
281
+ const pageMetaDatum = { path: vite.normalizePath(relativePathWithFileName), type: "page" };
282
+ if (routeBlock)
283
+ Object.assign(pageMetaDatum, routeBlock);
284
+ return pageMetaDatum;
155
285
  }
156
- async createOrUpdatePagesJSON() {
157
- const outputName = "pages.json";
158
- const resolvedOutput = (0, import_vite2.normalizePath)(
159
- (0, import_path2.resolve)(process.cwd(), this.options.outDir, outputName)
286
+ async mergePageMetaData() {
287
+ const generatedPageMetaData = await Promise.all(
288
+ this.pagesPath.map(async (page) => await this.parsePage(page))
160
289
  );
161
- if (!import_fs.default.existsSync(resolvedOutput)) {
162
- import_fs.default.writeFileSync(resolvedOutput, `{"pages": [{"path": ""}]}`, {
163
- encoding: "utf-8"
164
- });
290
+ const customPageMetaData = this.pagesGlobConfig?.pages || [];
291
+ if (!this.options.mergePages) {
292
+ this.pageMetaData = customPageMetaData;
293
+ } else {
294
+ if (this.pagesGlobConfig?.pages)
295
+ this.pageMetaData = mergePageMetaDataArray(generatedPageMetaData.concat(customPageMetaData));
296
+ else
297
+ this.pageMetaData = generatedPageMetaData;
165
298
  }
299
+ debug.pages(generatedPageMetaData);
300
+ }
301
+ async updatePagesJSON() {
302
+ checkPagesJsonFile(this.resolvedPagesJSONPath);
166
303
  this.options.onBeforeLoadUserConfig(this);
167
304
  await this.loadUserPagesConfig();
168
305
  this.options.onAfterLoadUserConfig(this);
169
- this.options.onBeforeScanPages(this);
170
- await this.scanPages();
171
- this.options.onAfterScanPages(this);
172
- this.options.onBeforeMergePagesMeta(this);
173
- await this.mergePagesMeta();
174
- this.options.onAfterMergePagesMeta(this);
306
+ if (this.options.mergePages) {
307
+ this.options.onBeforeScanPages(this);
308
+ await this.scanPages();
309
+ this.options.onAfterScanPages(this);
310
+ }
311
+ this.options.onBeforeMergePageMetaData(this);
312
+ await this.mergePageMetaData();
313
+ this.options.onAfterMergePageMetaData(this);
175
314
  this.options.onBeforeWriteFile(this);
176
- import_fs.default.writeFileSync(resolvedOutput, this.pagesJson, {
177
- encoding: "utf-8"
178
- });
315
+ const pagesJson = JSON.stringify({ ...this.pagesGlobConfig, pages: this.pageMetaData }, null, 2);
316
+ writeFileSync(this.resolvedPagesJSONPath, pagesJson);
179
317
  this.options.onAfterWriteFile(this);
180
318
  }
181
319
  async virtualModule() {
182
- return `export const pages = ${JSON.stringify(this.pagesMeta)};`;
320
+ return `export const pages = ${this.resolveRoutes()};`;
183
321
  }
184
- async pagesConfigSourcePaths() {
185
- return await (0, import_fast_glob.default)("pages.config.(ts|mts|cts|js|cjs|mjs|json)", {
186
- deep: 0,
187
- onlyFiles: true,
188
- absolute: true
189
- });
322
+ resolveRoutes() {
323
+ return JSON.stringify(this.pageMetaData, null, 2);
190
324
  }
191
- get pagesJson() {
192
- return JSON.stringify({
193
- ...this.pagesConfig,
194
- pages: this.pagesMeta
195
- });
196
- }
197
- };
325
+ }
198
326
 
199
- // src/config/index.ts
200
- function definePages(config) {
327
+ function defineUniPages(config) {
201
328
  return config;
202
329
  }
203
330
 
204
- // src/index.ts
205
- function resolveOptions(userOptions) {
206
- return {
207
- pagesDir: "src/pages",
208
- outDir: "src",
209
- exclude: [],
210
- onBeforeLoadUserConfig: () => {
211
- },
212
- onAfterLoadUserConfig: () => {
213
- },
214
- onBeforeScanPages: () => {
215
- },
216
- onAfterScanPages: () => {
217
- },
218
- onBeforeMergePagesMeta: () => {
219
- },
220
- onAfterMergePagesMeta: () => {
221
- },
222
- onBeforeWriteFile: () => {
223
- },
224
- onAfterWriteFile: () => {
225
- },
226
- ...userOptions
227
- };
228
- }
229
- var VitePluginUniPages = async (userOptions = {}) => {
230
- const options = resolveOptions(userOptions);
231
- logger.debug("Create uni-pages context with", options);
232
- const ctx = new Context(options);
331
+ const VitePluginUniPages = (userOptions = {}) => {
332
+ let ctx;
333
+ const resolvedPagesJSONPath = path.join(process.cwd(), userOptions.outDir ?? "src", OUTPUT_NAME);
334
+ checkPagesJsonFile(resolvedPagesJSONPath);
233
335
  return {
234
336
  name: "vite-plugin-uni-pages",
235
337
  enforce: "pre",
236
- async configureServer({ watcher, moduleGraph, ws }) {
237
- const pagesConfigSourcePaths = await ctx.pagesConfigSourcePaths();
238
- logger.debug("Add watcher", pagesConfigSourcePaths);
239
- watcher.add(pagesConfigSourcePaths);
240
- const reloadModule = (module2, path = "*") => {
241
- if (module2) {
242
- moduleGraph.invalidateModule(module2);
243
- if (ws) {
244
- ws.send({
245
- path,
246
- type: "full-reload"
247
- });
248
- }
249
- }
250
- };
251
- const updateVirtualModule = () => {
252
- logger.debug("Update virtualModule");
253
- const module2 = moduleGraph.getModuleById(resolvedVirtualModuleId);
254
- reloadModule(module2);
255
- };
256
- watcher.on("change", async (path) => {
257
- if (pagesConfigSourcePaths.includes((0, import_vite3.normalizePath)(path)) || isPagePath(path, options)) {
258
- await ctx.createOrUpdatePagesJSON();
259
- updateVirtualModule();
260
- }
261
- });
262
- watcher.on("add", async (path) => {
263
- if (isPagePath(path, options)) {
264
- await ctx.createOrUpdatePagesJSON();
265
- updateVirtualModule();
266
- }
267
- });
268
- watcher.on("unlink", async (path) => {
269
- if (isPagePath(path, options)) {
270
- await ctx.createOrUpdatePagesJSON();
271
- updateVirtualModule();
272
- }
273
- });
338
+ async configResolved(config) {
339
+ ctx = new PageContext(userOptions, config.root);
340
+ ctx.setLogger(config.logger);
341
+ ctx.updatePagesJSON();
342
+ if (config.build.watch && config.command === "build")
343
+ ctx.setupWatcher(chokidar.watch(ctx.options.dirs));
274
344
  },
275
- resolveId(id) {
276
- if (id === virtualModuleId) {
277
- return resolvedVirtualModuleId;
345
+ async transform(code, id) {
346
+ if (!/\.vue$/.test(id))
347
+ return null;
348
+ const s = new MagicString(code.toString());
349
+ const routeBlockMatches = s.original.matchAll(/<route[^>]*>([\s\S]*?)<\/route>/g);
350
+ for (const match of routeBlockMatches) {
351
+ const index = match.index;
352
+ const length = match[0].length;
353
+ s.remove(index, index + length);
278
354
  }
355
+ return s.toString();
356
+ },
357
+ configureServer(server) {
358
+ ctx.setupViteServer(server);
359
+ },
360
+ resolveId(id) {
361
+ if (id === MODULE_ID_VIRTUAL)
362
+ return RESOLVED_MODULE_ID_VIRTUAL;
279
363
  },
280
364
  load(id) {
281
- if (id === resolvedVirtualModuleId) {
365
+ if (id === RESOLVED_MODULE_ID_VIRTUAL)
282
366
  return ctx.virtualModule();
283
- }
284
367
  }
285
368
  };
286
369
  };
287
- var src_default = VitePluginUniPages;
288
- // Annotate the CommonJS export names for ESM import in node:
289
- 0 && (module.exports = {
290
- VitePluginUniPages,
291
- definePages
292
- });
293
- //# sourceMappingURL=index.cjs.map
370
+
371
+ exports.FILE_EXTENSIONS = FILE_EXTENSIONS;
372
+ exports.MODULE_ID_VIRTUAL = MODULE_ID_VIRTUAL;
373
+ exports.OUTPUT_NAME = OUTPUT_NAME;
374
+ exports.PageContext = PageContext;
375
+ exports.RESOLVED_MODULE_ID_VIRTUAL = RESOLVED_MODULE_ID_VIRTUAL;
376
+ exports.VitePluginUniPages = VitePluginUniPages;
377
+ exports.checkPagesJsonFile = checkPagesJsonFile;
378
+ exports.debug = debug;
379
+ exports.default = VitePluginUniPages;
380
+ exports.defineUniPages = defineUniPages;
381
+ exports.extsToGlob = extsToGlob;
382
+ exports.getPageFiles = getPageFiles;
383
+ exports.getRouteBlock = getRouteBlock;
384
+ exports.invalidatePagesModule = invalidatePagesModule;
385
+ exports.isConfigFile = isConfigFile;
386
+ exports.isTargetFile = isTargetFile;
387
+ exports.mergePageMetaDataArray = mergePageMetaDataArray;
388
+ exports.parseCustomBlock = parseCustomBlock;
389
+ exports.parseSFC = parseSFC;
390
+ exports.resolveOptions = resolveOptions;
391
+ exports.resolvePageDirs = resolvePageDirs;
392
+ exports.writeFileSync = writeFileSync;