@sepveneto/plugin-mp-router-view 0.3.3 → 0.3.4

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.
@@ -37041,19 +37041,19 @@ function countRouterView(code) {
37041
37041
  return;
37042
37042
  if (node2.children && node2.children.length > 0) {
37043
37043
  node2.children.forEach((ele) => {
37044
- traverse(ele);
37044
+ const res = traverse(ele);
37045
+ if (res) {
37046
+ const start = ele.loc.start.offset - node2.loc.start.offset;
37047
+ const end = ele.loc.end.offset - node2.loc.start.offset;
37048
+ before += node2.loc.source.substring(0, start);
37049
+ after += node2.loc.source.substring(end);
37050
+ }
37045
37051
  });
37046
37052
  return;
37047
37053
  }
37048
37054
  if (node2.tag === "router-view") {
37049
37055
  ++count;
37050
37056
  return true;
37051
- } else {
37052
- if (count) {
37053
- after += node2.loc.source;
37054
- } else {
37055
- before += node2.loc.source;
37056
- }
37057
37057
  }
37058
37058
  }
37059
37059
  traverse(ast);
@@ -37153,7 +37153,7 @@ function transform2(path4, code, entryPages, level) {
37153
37153
 
37154
37154
  // src/index.ts
37155
37155
  var NAME = "unplugin-mp-router-view";
37156
- var src_default = createUnplugin((options) => {
37156
+ var unpluginFactory = (options) => {
37157
37157
  var _a, _b;
37158
37158
  const log3 = (_a = options == null ? void 0 : options.log) != null ? _a : "error";
37159
37159
  const entryPages = getPages((_b = options == null ? void 0 : options.collect) != null ? _b : true);
@@ -37169,12 +37169,14 @@ var src_default = createUnplugin((options) => {
37169
37169
  return res;
37170
37170
  }
37171
37171
  };
37172
- });
37172
+ };
37173
+ var unplugin = /* @__PURE__ */ createUnplugin(unpluginFactory);
37174
+ var src_default = unplugin;
37173
37175
 
37174
37176
  export {
37175
- getPages,
37176
- transform2 as transform,
37177
37177
  NAME,
37178
+ unpluginFactory,
37179
+ unplugin,
37178
37180
  src_default
37179
37181
  };
37180
37182
  /*!
package/dist/esbuild.cjs CHANGED
@@ -58,6 +58,7 @@ __export(esbuild_exports, {
58
58
  default: () => esbuild_default
59
59
  });
60
60
  module.exports = __toCommonJS(esbuild_exports);
61
+ var import_unplugin2 = require("unplugin");
61
62
 
62
63
  // src/index.ts
63
64
  var import_node_path2 = __toESM(require("path"), 1);
@@ -37070,19 +37071,19 @@ function countRouterView(code) {
37070
37071
  return;
37071
37072
  if (node2.children && node2.children.length > 0) {
37072
37073
  node2.children.forEach((ele) => {
37073
- traverse(ele);
37074
+ const res = traverse(ele);
37075
+ if (res) {
37076
+ const start = ele.loc.start.offset - node2.loc.start.offset;
37077
+ const end = ele.loc.end.offset - node2.loc.start.offset;
37078
+ before += node2.loc.source.substring(0, start);
37079
+ after += node2.loc.source.substring(end);
37080
+ }
37074
37081
  });
37075
37082
  return;
37076
37083
  }
37077
37084
  if (node2.tag === "router-view") {
37078
37085
  ++count;
37079
37086
  return true;
37080
- } else {
37081
- if (count) {
37082
- after += node2.loc.source;
37083
- } else {
37084
- before += node2.loc.source;
37085
- }
37086
37087
  }
37087
37088
  }
37088
37089
  traverse(ast);
@@ -37182,7 +37183,7 @@ function transform2(path4, code, entryPages, level) {
37182
37183
 
37183
37184
  // src/index.ts
37184
37185
  var NAME = "unplugin-mp-router-view";
37185
- var src_default = (0, import_unplugin.createUnplugin)((options) => {
37186
+ var unpluginFactory = (options) => {
37186
37187
  var _a, _b;
37187
37188
  const log3 = (_a = options == null ? void 0 : options.log) != null ? _a : "error";
37188
37189
  const entryPages = getPages((_b = options == null ? void 0 : options.collect) != null ? _b : true);
@@ -37198,10 +37199,10 @@ var src_default = (0, import_unplugin.createUnplugin)((options) => {
37198
37199
  return res;
37199
37200
  }
37200
37201
  };
37201
- });
37202
+ };
37202
37203
 
37203
37204
  // src/esbuild.ts
37204
- var esbuild_default = src_default.esbuild;
37205
+ var esbuild_default = (0, import_unplugin2.createEsbuildPlugin)(unpluginFactory);
37205
37206
  // Annotate the CommonJS export names for ESM import in node:
37206
37207
  0 && (module.exports = {});
37207
37208
  /*!
@@ -37212,4 +37213,4 @@ var esbuild_default = src_default.esbuild;
37212
37213
  */
37213
37214
  /*! https://mths.be/cssesc v3.0.0 by @mathias */
37214
37215
  /*! https://mths.be/punycode v1.4.1 by @mathias */
37215
- exports.default = module.exports;
37216
+ if (module.exports.default) module.exports = module.exports.default;
package/dist/esbuild.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import {
2
- src_default
3
- } from "./chunk-673IL366.js";
2
+ unpluginFactory
3
+ } from "./chunk-TUTSLW5Q.js";
4
4
 
5
5
  // src/esbuild.ts
6
- var esbuild_default = src_default.esbuild;
6
+ import { createEsbuildPlugin } from "unplugin";
7
+ var esbuild_default = createEsbuildPlugin(unpluginFactory);
7
8
  export {
8
9
  esbuild_default as default
9
10
  };
package/dist/index.cjs CHANGED
@@ -56,7 +56,9 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
56
56
  var src_exports = {};
57
57
  __export(src_exports, {
58
58
  NAME: () => NAME,
59
- default: () => src_default
59
+ default: () => src_default,
60
+ unplugin: () => unplugin,
61
+ unpluginFactory: () => unpluginFactory
60
62
  });
61
63
  module.exports = __toCommonJS(src_exports);
62
64
  var import_node_path2 = __toESM(require("path"), 1);
@@ -37069,19 +37071,19 @@ function countRouterView(code) {
37069
37071
  return;
37070
37072
  if (node2.children && node2.children.length > 0) {
37071
37073
  node2.children.forEach((ele) => {
37072
- traverse(ele);
37074
+ const res = traverse(ele);
37075
+ if (res) {
37076
+ const start = ele.loc.start.offset - node2.loc.start.offset;
37077
+ const end = ele.loc.end.offset - node2.loc.start.offset;
37078
+ before += node2.loc.source.substring(0, start);
37079
+ after += node2.loc.source.substring(end);
37080
+ }
37073
37081
  });
37074
37082
  return;
37075
37083
  }
37076
37084
  if (node2.tag === "router-view") {
37077
37085
  ++count;
37078
37086
  return true;
37079
- } else {
37080
- if (count) {
37081
- after += node2.loc.source;
37082
- } else {
37083
- before += node2.loc.source;
37084
- }
37085
37087
  }
37086
37088
  }
37087
37089
  traverse(ast);
@@ -37181,7 +37183,7 @@ function transform2(path4, code, entryPages, level) {
37181
37183
 
37182
37184
  // src/index.ts
37183
37185
  var NAME = "unplugin-mp-router-view";
37184
- var src_default = (0, import_unplugin.createUnplugin)((options) => {
37186
+ var unpluginFactory = (options) => {
37185
37187
  var _a, _b;
37186
37188
  const log3 = (_a = options == null ? void 0 : options.log) != null ? _a : "error";
37187
37189
  const entryPages = getPages((_b = options == null ? void 0 : options.collect) != null ? _b : true);
@@ -37197,10 +37199,14 @@ var src_default = (0, import_unplugin.createUnplugin)((options) => {
37197
37199
  return res;
37198
37200
  }
37199
37201
  };
37200
- });
37202
+ };
37203
+ var unplugin = /* @__PURE__ */ (0, import_unplugin.createUnplugin)(unpluginFactory);
37204
+ var src_default = unplugin;
37201
37205
  // Annotate the CommonJS export names for ESM import in node:
37202
37206
  0 && (module.exports = {
37203
- NAME
37207
+ NAME,
37208
+ unplugin,
37209
+ unpluginFactory
37204
37210
  });
37205
37211
  /*!
37206
37212
  * The buffer module from node.js, for the browser.
@@ -37210,4 +37216,4 @@ var src_default = (0, import_unplugin.createUnplugin)((options) => {
37210
37216
  */
37211
37217
  /*! https://mths.be/cssesc v3.0.0 by @mathias */
37212
37218
  /*! https://mths.be/punycode v1.4.1 by @mathias */
37213
- exports.default = module.exports;
37219
+ if (module.exports.default) module.exports = module.exports.default;
package/dist/index.d.ts CHANGED
@@ -1,7 +1,9 @@
1
- import * as unplugin from 'unplugin';
1
+ import * as _unplugin from 'unplugin';
2
+ import { UnpluginFactory } from 'unplugin';
2
3
  import { Options } from './types.js';
3
4
 
4
5
  declare const NAME = "unplugin-mp-router-view";
5
- declare const _default: unplugin.UnpluginInstance<Options | undefined, boolean>;
6
+ declare const unpluginFactory: UnpluginFactory<Options | undefined>;
7
+ declare const unplugin: _unplugin.UnpluginInstance<Options | undefined, boolean>;
6
8
 
7
- export { NAME, _default as default };
9
+ export { NAME, unplugin as default, unplugin, unpluginFactory };
package/dist/index.js CHANGED
@@ -1,8 +1,12 @@
1
1
  import {
2
2
  NAME,
3
- src_default
4
- } from "./chunk-673IL366.js";
3
+ src_default,
4
+ unplugin,
5
+ unpluginFactory
6
+ } from "./chunk-TUTSLW5Q.js";
5
7
  export {
6
8
  NAME,
7
- src_default as default
9
+ src_default as default,
10
+ unplugin,
11
+ unpluginFactory
8
12
  };
package/dist/rollup.cjs CHANGED
@@ -58,6 +58,7 @@ __export(rollup_exports, {
58
58
  default: () => rollup_default
59
59
  });
60
60
  module.exports = __toCommonJS(rollup_exports);
61
+ var import_unplugin2 = require("unplugin");
61
62
 
62
63
  // src/index.ts
63
64
  var import_node_path2 = __toESM(require("path"), 1);
@@ -37070,19 +37071,19 @@ function countRouterView(code) {
37070
37071
  return;
37071
37072
  if (node2.children && node2.children.length > 0) {
37072
37073
  node2.children.forEach((ele) => {
37073
- traverse(ele);
37074
+ const res = traverse(ele);
37075
+ if (res) {
37076
+ const start = ele.loc.start.offset - node2.loc.start.offset;
37077
+ const end = ele.loc.end.offset - node2.loc.start.offset;
37078
+ before += node2.loc.source.substring(0, start);
37079
+ after += node2.loc.source.substring(end);
37080
+ }
37074
37081
  });
37075
37082
  return;
37076
37083
  }
37077
37084
  if (node2.tag === "router-view") {
37078
37085
  ++count;
37079
37086
  return true;
37080
- } else {
37081
- if (count) {
37082
- after += node2.loc.source;
37083
- } else {
37084
- before += node2.loc.source;
37085
- }
37086
37087
  }
37087
37088
  }
37088
37089
  traverse(ast);
@@ -37182,7 +37183,7 @@ function transform2(path4, code, entryPages, level) {
37182
37183
 
37183
37184
  // src/index.ts
37184
37185
  var NAME = "unplugin-mp-router-view";
37185
- var src_default = (0, import_unplugin.createUnplugin)((options) => {
37186
+ var unpluginFactory = (options) => {
37186
37187
  var _a, _b;
37187
37188
  const log3 = (_a = options == null ? void 0 : options.log) != null ? _a : "error";
37188
37189
  const entryPages = getPages((_b = options == null ? void 0 : options.collect) != null ? _b : true);
@@ -37198,10 +37199,10 @@ var src_default = (0, import_unplugin.createUnplugin)((options) => {
37198
37199
  return res;
37199
37200
  }
37200
37201
  };
37201
- });
37202
+ };
37202
37203
 
37203
37204
  // src/rollup.ts
37204
- var rollup_default = src_default.rollup;
37205
+ var rollup_default = (0, import_unplugin2.createRollupPlugin)(unpluginFactory);
37205
37206
  // Annotate the CommonJS export names for ESM import in node:
37206
37207
  0 && (module.exports = {});
37207
37208
  /*!
@@ -37212,4 +37213,4 @@ var rollup_default = src_default.rollup;
37212
37213
  */
37213
37214
  /*! https://mths.be/cssesc v3.0.0 by @mathias */
37214
37215
  /*! https://mths.be/punycode v1.4.1 by @mathias */
37215
- exports.default = module.exports;
37216
+ if (module.exports.default) module.exports = module.exports.default;
package/dist/rollup.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import {
2
- src_default
3
- } from "./chunk-673IL366.js";
2
+ unpluginFactory
3
+ } from "./chunk-TUTSLW5Q.js";
4
4
 
5
5
  // src/rollup.ts
6
- var rollup_default = src_default.rollup;
6
+ import { createRollupPlugin } from "unplugin";
7
+ var rollup_default = createRollupPlugin(unpluginFactory);
7
8
  export {
8
9
  rollup_default as default
9
10
  };
package/dist/type.d.cjs CHANGED
@@ -16,4 +16,4 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
16
16
  // src/type.d.ts
17
17
  var type_d_exports = {};
18
18
  module.exports = __toCommonJS(type_d_exports);
19
- exports.default = module.exports;
19
+ if (module.exports.default) module.exports = module.exports.default;
package/dist/types.cjs CHANGED
@@ -16,4 +16,4 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
16
16
  // src/types.ts
17
17
  var types_exports = {};
18
18
  module.exports = __toCommonJS(types_exports);
19
- exports.default = module.exports;
19
+ if (module.exports.default) module.exports = module.exports.default;
package/dist/vite.cjs CHANGED
@@ -58,6 +58,7 @@ __export(vite_exports, {
58
58
  default: () => vite_default
59
59
  });
60
60
  module.exports = __toCommonJS(vite_exports);
61
+ var import_unplugin2 = require("unplugin");
61
62
 
62
63
  // src/index.ts
63
64
  var import_node_path2 = __toESM(require("path"), 1);
@@ -37070,19 +37071,19 @@ function countRouterView(code) {
37070
37071
  return;
37071
37072
  if (node2.children && node2.children.length > 0) {
37072
37073
  node2.children.forEach((ele) => {
37073
- traverse(ele);
37074
+ const res = traverse(ele);
37075
+ if (res) {
37076
+ const start = ele.loc.start.offset - node2.loc.start.offset;
37077
+ const end = ele.loc.end.offset - node2.loc.start.offset;
37078
+ before += node2.loc.source.substring(0, start);
37079
+ after += node2.loc.source.substring(end);
37080
+ }
37074
37081
  });
37075
37082
  return;
37076
37083
  }
37077
37084
  if (node2.tag === "router-view") {
37078
37085
  ++count;
37079
37086
  return true;
37080
- } else {
37081
- if (count) {
37082
- after += node2.loc.source;
37083
- } else {
37084
- before += node2.loc.source;
37085
- }
37086
37087
  }
37087
37088
  }
37088
37089
  traverse(ast);
@@ -37182,7 +37183,7 @@ function transform2(path4, code, entryPages, level) {
37182
37183
 
37183
37184
  // src/index.ts
37184
37185
  var NAME = "unplugin-mp-router-view";
37185
- var src_default = (0, import_unplugin.createUnplugin)((options) => {
37186
+ var unpluginFactory = (options) => {
37186
37187
  var _a, _b;
37187
37188
  const log3 = (_a = options == null ? void 0 : options.log) != null ? _a : "error";
37188
37189
  const entryPages = getPages((_b = options == null ? void 0 : options.collect) != null ? _b : true);
@@ -37198,10 +37199,10 @@ var src_default = (0, import_unplugin.createUnplugin)((options) => {
37198
37199
  return res;
37199
37200
  }
37200
37201
  };
37201
- });
37202
+ };
37202
37203
 
37203
37204
  // src/vite.ts
37204
- var vite_default = src_default.vite;
37205
+ var vite_default = (0, import_unplugin2.createVitePlugin)(unpluginFactory);
37205
37206
  // Annotate the CommonJS export names for ESM import in node:
37206
37207
  0 && (module.exports = {});
37207
37208
  /*!
@@ -37212,4 +37213,4 @@ var vite_default = src_default.vite;
37212
37213
  */
37213
37214
  /*! https://mths.be/cssesc v3.0.0 by @mathias */
37214
37215
  /*! https://mths.be/punycode v1.4.1 by @mathias */
37215
- exports.default = module.exports;
37216
+ if (module.exports.default) module.exports = module.exports.default;
package/dist/vite.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import {
2
- src_default
3
- } from "./chunk-673IL366.js";
2
+ unpluginFactory
3
+ } from "./chunk-TUTSLW5Q.js";
4
4
 
5
5
  // src/vite.ts
6
- var vite_default = src_default.vite;
6
+ import { createVitePlugin } from "unplugin";
7
+ var vite_default = createVitePlugin(unpluginFactory);
7
8
  export {
8
9
  vite_default as default
9
10
  };
package/dist/webpack.cjs CHANGED
@@ -58,38 +58,19 @@ __export(webpack_exports, {
58
58
  default: () => webpack_default
59
59
  });
60
60
  module.exports = __toCommonJS(webpack_exports);
61
+ var import_unplugin2 = require("unplugin");
62
+
63
+ // src/index.ts
64
+ var import_node_path2 = __toESM(require("path"), 1);
65
+ var import_unplugin = require("unplugin");
61
66
 
62
67
  // src/util/parse.ts
63
68
  var import_node_fs = __toESM(require("fs"), 1);
64
- var import_node_path2 = __toESM(require("path"), 1);
69
+ var import_node_path = __toESM(require("path"), 1);
65
70
  var import_jsonc_parser = require("jsonc-parser");
66
71
 
67
72
  // src/util/error.ts
68
73
  var import_colors = __toESM(require("colors"), 1);
69
-
70
- // src/index.ts
71
- var import_node_path = __toESM(require("path"), 1);
72
- var import_unplugin = require("unplugin");
73
- var NAME = "unplugin-mp-router-view";
74
- var src_default = (0, import_unplugin.createUnplugin)((options) => {
75
- var _a, _b;
76
- const log3 = (_a = options == null ? void 0 : options.log) != null ? _a : "error";
77
- const entryPages = getPages((_b = options == null ? void 0 : options.collect) != null ? _b : true);
78
- return {
79
- name: NAME,
80
- enforce: "pre",
81
- transformInclude(id2) {
82
- const _id = import_node_path.default.resolve(id2);
83
- return isAppVue(_id) || isEntryPage(_id, entryPages);
84
- },
85
- transform(code, id2) {
86
- const res = transform(import_node_path.default.resolve(id2), code, entryPages, log3);
87
- return res;
88
- }
89
- };
90
- });
91
-
92
- // src/util/error.ts
93
74
  function genError(msg) {
94
75
  return `${import_colors.default.yellow(`
95
76
  [${NAME}]`)} ${import_colors.default.red(`\u2716 ${msg}`)}`;
@@ -14634,7 +14615,7 @@ function createTransformContext(root2, { filename = "", prefixIdentifiers = fals
14634
14615
  }
14635
14616
  return context;
14636
14617
  }
14637
- function transform2(root2, options) {
14618
+ function transform(root2, options) {
14638
14619
  const context = createTransformContext(root2, options);
14639
14620
  traverseNode(root2, context);
14640
14621
  if (options.hoistStatic) {
@@ -19090,7 +19071,7 @@ function baseCompile(template, options = {}) {
19090
19071
  options.expressionPlugins = [...expressionPlugins || [], "typescript"];
19091
19072
  }
19092
19073
  }
19093
- transform2(ast, extend({}, options, {
19074
+ transform(ast, extend({}, options, {
19094
19075
  prefixIdentifiers,
19095
19076
  nodeTransforms: [
19096
19077
  ...nodeTransforms,
@@ -22029,7 +22010,7 @@ var CompilerDOM = /* @__PURE__ */ Object.freeze({
22029
22010
  TRANSITION_GROUP,
22030
22011
  baseCompile,
22031
22012
  baseParse,
22032
- transform: transform2,
22013
+ transform,
22033
22014
  createTransformContext,
22034
22015
  traverseNode,
22035
22016
  createStructuralDirectiveTransform,
@@ -24976,7 +24957,7 @@ function basename(path4, ext) {
24976
24957
  function extname(path4) {
24977
24958
  return splitPath(path4)[3];
24978
24959
  }
24979
- var path2 = {
24960
+ var path = {
24980
24961
  extname,
24981
24962
  basename,
24982
24963
  dirname,
@@ -25017,7 +24998,7 @@ var _polyfillNode_path = /* @__PURE__ */ Object.freeze({
25017
24998
  dirname,
25018
24999
  basename,
25019
25000
  extname,
25020
- "default": path2
25001
+ "default": path
25021
25002
  });
25022
25003
  var maxInt = 2147483647;
25023
25004
  var base = 36;
@@ -26514,7 +26495,7 @@ var transformAssetUrl = (node2, context, options = defaultAssetUrlOptions) => {
26514
26495
  const protocol = base2.protocol || "";
26515
26496
  const host = base2.host ? protocol + "//" + base2.host : "";
26516
26497
  const basePath = base2.path || "/";
26517
- attr.value.content = host + (path2.posix || path2).join(basePath, url.path + (url.hash || ""));
26498
+ attr.value.content = host + (path.posix || path).join(basePath, url.path + (url.hash || ""));
26518
26499
  return;
26519
26500
  }
26520
26501
  const exp = getImportsExpressionExp(url.path, url.hash, attr.loc, context);
@@ -26601,7 +26582,7 @@ var transformSrcset = (node2, context, options = defaultAssetUrlOptions) => {
26601
26582
  let { url, descriptor } = candidate;
26602
26583
  descriptor = descriptor ? ` ${descriptor}` : ``;
26603
26584
  if (url[0] === ".") {
26604
- candidate.url = (path2.posix || path2).join(base2, url);
26585
+ candidate.url = (path.posix || path).join(base2, url);
26605
26586
  set.push(candidate.url + descriptor);
26606
26587
  } else if (shouldProcessUrl(url)) {
26607
26588
  needImportTransform = true;
@@ -27617,7 +27598,7 @@ function compile$1(template, options = {}) {
27617
27598
  });
27618
27599
  const ast = baseParse(template, options);
27619
27600
  rawOptionsMap.set(ast, options);
27620
- transform2(ast, Object.assign(Object.assign({}, options), { hoistStatic: false, nodeTransforms: [
27601
+ transform(ast, Object.assign(Object.assign({}, options), { hoistStatic: false, nodeTransforms: [
27621
27602
  ssrTransformIf,
27622
27603
  ssrTransformFor,
27623
27604
  trackVForSlotScopes,
@@ -27823,7 +27804,7 @@ function resolveTemplateUsageCheckString(sfc) {
27823
27804
  return cached;
27824
27805
  }
27825
27806
  let code = "";
27826
- transform2(createRoot([ast]), {
27807
+ transform(createRoot([ast]), {
27827
27808
  nodeTransforms: [
27828
27809
  (node2) => {
27829
27810
  if (node2.type === 1) {
@@ -37090,19 +37071,19 @@ function countRouterView(code) {
37090
37071
  return;
37091
37072
  if (node2.children && node2.children.length > 0) {
37092
37073
  node2.children.forEach((ele) => {
37093
- traverse(ele);
37074
+ const res = traverse(ele);
37075
+ if (res) {
37076
+ const start = ele.loc.start.offset - node2.loc.start.offset;
37077
+ const end = ele.loc.end.offset - node2.loc.start.offset;
37078
+ before += node2.loc.source.substring(0, start);
37079
+ after += node2.loc.source.substring(end);
37080
+ }
37094
37081
  });
37095
37082
  return;
37096
37083
  }
37097
37084
  if (node2.tag === "router-view") {
37098
37085
  ++count;
37099
37086
  return true;
37100
- } else {
37101
- if (count) {
37102
- after += node2.loc.source;
37103
- } else {
37104
- before += node2.loc.source;
37105
- }
37106
37087
  }
37107
37088
  }
37108
37089
  traverse(ast);
@@ -37143,7 +37124,7 @@ function addToFooter(code, footer2) {
37143
37124
  return code.replace(/(<\/view>)(\s*)(<\/template>)(?!(([\s\S]*)(<\/template>)))/, (p) => footer2 + p);
37144
37125
  }
37145
37126
  function getPages(collectMode) {
37146
- const jsonStr = import_node_fs.default.readFileSync(import_node_path2.default.resolve(INPUT_DIR, "pages.json"), "utf-8");
37127
+ const jsonStr = import_node_fs.default.readFileSync(import_node_path.default.resolve(INPUT_DIR, "pages.json"), "utf-8");
37147
37128
  const pagesJson = parseJson(jsonStr);
37148
37129
  const { pages, subPackages = [] } = pagesJson;
37149
37130
  const entryList = [...collectEntry(collectMode, pages), ...collectEntry(collectMode, subPackages)];
@@ -37159,7 +37140,7 @@ function collectEntry(collectMode, json, root2 = "") {
37159
37140
  if (!collectMode) {
37160
37141
  return;
37161
37142
  }
37162
- const _path2 = import_node_path2.default.resolve(INPUT_DIR, `${root2}${root2 ? "/" : ""}${item.path}`);
37143
+ const _path2 = import_node_path.default.resolve(INPUT_DIR, `${root2}${root2 ? "/" : ""}${item.path}`);
37163
37144
  if (collectMode && typeof collectMode === "boolean" && !item["ROUTER_VIEW_EXCLUDE"]) {
37164
37145
  entryList.push(_path2);
37165
37146
  } else if (typeof collectMode === "string" && item[collectMode]) {
@@ -37179,7 +37160,7 @@ function combineCode(code, header2, footer2) {
37179
37160
  code = addToFooter(code, footer2);
37180
37161
  return code;
37181
37162
  }
37182
- function transform(path4, code, entryPages, level) {
37163
+ function transform2(path4, code, entryPages, level) {
37183
37164
  logLevel = level;
37184
37165
  if (isAppVue(path4)) {
37185
37166
  log(`\u57FA\u4E8E\u5E73\u53F0${process.env.UNI_PLATFORM}, \u5904\u7406App.vue...`, logLevel);
@@ -37200,13 +37181,28 @@ function transform(path4, code, entryPages, level) {
37200
37181
  return code;
37201
37182
  }
37202
37183
 
37203
- // src/webpack.ts
37204
- function webpack_default(code) {
37184
+ // src/index.ts
37185
+ var NAME = "unplugin-mp-router-view";
37186
+ var unpluginFactory = (options) => {
37205
37187
  var _a, _b;
37206
- const { log: log3 = "error", collect = true } = (_b = (_a = this.getOptions) == null ? void 0 : _a.call(this)) != null ? _b : this.query;
37207
- const entryPages = getPages(collect);
37208
- return transform(this.resourcePath, code, entryPages, log3);
37209
- }
37188
+ const log3 = (_a = options == null ? void 0 : options.log) != null ? _a : "error";
37189
+ const entryPages = getPages((_b = options == null ? void 0 : options.collect) != null ? _b : true);
37190
+ return {
37191
+ name: NAME,
37192
+ enforce: "pre",
37193
+ transformInclude(id2) {
37194
+ const _id = import_node_path2.default.resolve(id2);
37195
+ return isAppVue(_id) || isEntryPage(_id, entryPages);
37196
+ },
37197
+ transform(code, id2) {
37198
+ const res = transform2(import_node_path2.default.resolve(id2), code, entryPages, log3);
37199
+ return res;
37200
+ }
37201
+ };
37202
+ };
37203
+
37204
+ // src/webpack.ts
37205
+ var webpack_default = (0, import_unplugin2.createWebpackPlugin)(unpluginFactory);
37210
37206
  // Annotate the CommonJS export names for ESM import in node:
37211
37207
  0 && (module.exports = {});
37212
37208
  /*!
@@ -37217,4 +37213,4 @@ function webpack_default(code) {
37217
37213
  */
37218
37214
  /*! https://mths.be/cssesc v3.0.0 by @mathias */
37219
37215
  /*! https://mths.be/punycode v1.4.1 by @mathias */
37220
- exports.default = module.exports;
37216
+ if (module.exports.default) module.exports = module.exports.default;
package/dist/webpack.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import * as webpack from 'webpack';
2
2
  import { Options } from './types.js';
3
3
 
4
- declare function export_default(this: webpack.LoaderContext<Options>, code: string): string;
4
+ declare const _default: (options?: Options | undefined) => webpack.WebpackPluginInstance;
5
5
 
6
- export { export_default as default };
6
+ export { _default as default };
package/dist/webpack.js CHANGED
@@ -1,15 +1,10 @@
1
1
  import {
2
- getPages,
3
- transform
4
- } from "./chunk-673IL366.js";
2
+ unpluginFactory
3
+ } from "./chunk-TUTSLW5Q.js";
5
4
 
6
5
  // src/webpack.ts
7
- function webpack_default(code) {
8
- var _a, _b;
9
- const { log = "error", collect = true } = (_b = (_a = this.getOptions) == null ? void 0 : _a.call(this)) != null ? _b : this.query;
10
- const entryPages = getPages(collect);
11
- return transform(this.resourcePath, code, entryPages, log);
12
- }
6
+ import { createWebpackPlugin } from "unplugin";
7
+ var webpack_default = createWebpackPlugin(unpluginFactory);
13
8
  export {
14
9
  webpack_default as default
15
10
  };
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sepveneto/plugin-mp-router-view",
3
3
  "type": "module",
4
- "version": "0.3.3",
4
+ "version": "0.3.4",
5
5
  "packageManager": "pnpm@7.1.1",
6
6
  "description": "Register global imports on demand for Vite and Webpack",
7
7
  "license": "MIT",
@@ -69,10 +69,10 @@
69
69
  ],
70
70
  "dependencies": {
71
71
  "colors": "^1.4.0",
72
+ "debug": "^4.3.4",
72
73
  "jsonc-parser": "^3.2.0",
73
74
  "node-html-parser": "^6.1.4",
74
- "debug": "^4.3.4",
75
- "unplugin": "^1.0.1"
75
+ "unplugin": "^1.4.0"
76
76
  },
77
77
  "devDependencies": {
78
78
  "@antfu/eslint-config": "^0.33.1",