@uni-helper/vite-plugin-uni-pages 0.3.12 → 0.3.13

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
@@ -443,9 +443,20 @@ class Page {
443
443
  return this.changed;
444
444
  }
445
445
  async read() {
446
- this.meta = await this.readPageMetaFromFile();
447
- const raw = this.meta ? JSON.stringify(this.meta) : "";
446
+ let meta;
447
+ try {
448
+ meta = await this.readPageMetaFromFile();
449
+ } catch (err) {
450
+ debug.error(err);
451
+ return;
452
+ }
453
+ let raw = "";
454
+ try {
455
+ raw = JSON.stringify(meta);
456
+ } catch {
457
+ }
448
458
  this.changed = this.raw !== raw;
459
+ this.meta = meta;
449
460
  this.raw = raw;
450
461
  }
451
462
  async readPageMetaFromFile() {
@@ -464,19 +475,13 @@ ${err.message}`);
464
475
  }
465
476
  }
466
477
  function parseSFC(code, options) {
467
- try {
468
- return compilerSfc.parse(code, {
469
- pad: "space",
470
- ...options
471
- }).descriptor || compilerSfc.parse({
472
- source: code,
473
- ...options
474
- });
475
- } catch (error) {
476
- throw new Error(`[vite-plugin-uni-pages] Vue3's "@vue/compiler-sfc" is required.
477
- Original error:
478
- ${error}`);
479
- }
478
+ return compilerSfc.parse(code, {
479
+ pad: "space",
480
+ ...options
481
+ }).descriptor || compilerSfc.parse({
482
+ source: code,
483
+ ...options
484
+ });
480
485
  }
481
486
  async function tryPageMetaFromMacro(sfc) {
482
487
  const sfcScript = sfc.scriptSetup || sfc.script;
@@ -510,7 +515,10 @@ async function tryPageMetaFromCustomBlock(sfc, routeBlockLang) {
510
515
  type: routeBlock?.attr.type ?? "page"
511
516
  };
512
517
  if (routeBlock) {
513
- commentJson.assign(pageMeta, routeBlock.content);
518
+ try {
519
+ commentJson.assign(pageMeta, routeBlock.content);
520
+ } catch {
521
+ }
514
522
  }
515
523
  return pageMeta;
516
524
  }
package/dist/index.mjs CHANGED
@@ -409,9 +409,20 @@ class Page {
409
409
  return this.changed;
410
410
  }
411
411
  async read() {
412
- this.meta = await this.readPageMetaFromFile();
413
- const raw = this.meta ? JSON.stringify(this.meta) : "";
412
+ let meta;
413
+ try {
414
+ meta = await this.readPageMetaFromFile();
415
+ } catch (err) {
416
+ debug.error(err);
417
+ return;
418
+ }
419
+ let raw = "";
420
+ try {
421
+ raw = JSON.stringify(meta);
422
+ } catch {
423
+ }
414
424
  this.changed = this.raw !== raw;
425
+ this.meta = meta;
415
426
  this.raw = raw;
416
427
  }
417
428
  async readPageMetaFromFile() {
@@ -430,19 +441,13 @@ ${err.message}`);
430
441
  }
431
442
  }
432
443
  function parseSFC(code, options) {
433
- try {
434
- return parse$2(code, {
435
- pad: "space",
436
- ...options
437
- }).descriptor || parse$2({
438
- source: code,
439
- ...options
440
- });
441
- } catch (error) {
442
- throw new Error(`[vite-plugin-uni-pages] Vue3's "@vue/compiler-sfc" is required.
443
- Original error:
444
- ${error}`);
445
- }
444
+ return parse$2(code, {
445
+ pad: "space",
446
+ ...options
447
+ }).descriptor || parse$2({
448
+ source: code,
449
+ ...options
450
+ });
446
451
  }
447
452
  async function tryPageMetaFromMacro(sfc) {
448
453
  const sfcScript = sfc.scriptSetup || sfc.script;
@@ -476,7 +481,10 @@ async function tryPageMetaFromCustomBlock(sfc, routeBlockLang) {
476
481
  type: routeBlock?.attr.type ?? "page"
477
482
  };
478
483
  if (routeBlock) {
479
- assign(pageMeta, routeBlock.content);
484
+ try {
485
+ assign(pageMeta, routeBlock.content);
486
+ } catch {
487
+ }
480
488
  }
481
489
  return pageMeta;
482
490
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@uni-helper/vite-plugin-uni-pages",
3
3
  "type": "module",
4
- "version": "0.3.12",
4
+ "version": "0.3.13",
5
5
  "description": "File system based routing for uni-app applications using Vite",
6
6
  "author": "KeJun",
7
7
  "maintainers": [