@into-mini/sfc-split-plugin 0.5.12 → 0.6.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.d.mts CHANGED
@@ -1,13 +1,7 @@
1
1
  import type { Compiler, WebpackPluginInstance } from 'webpack';
2
2
  import type { Options } from '@into-mini/sfc-transformer/src/transformer.mts';
3
- export declare const COMPONENT_ROOT = "as-components";
4
- type PluginOptions = Options & {
5
- loaders?: boolean;
6
- };
7
3
  export declare class SfcSplitPlugin implements WebpackPluginInstance {
8
- #private;
9
- options: PluginOptions;
10
- constructor({ type, tagMatcher, preserveTap, loaders, }?: PluginOptions);
4
+ options: Options;
5
+ constructor({ type, tagMatcher, preserveTap }?: Options);
11
6
  apply(compiler: Compiler): void;
12
7
  }
13
- export {};
package/dist/index.mjs CHANGED
@@ -1,92 +1,18 @@
1
- import { fileURLToPath } from 'node:url';
2
1
  import { AddWxsPlugin } from "./plugin/add-wxs.mjs";
3
2
  import { ExposeEntryNamePlugin } from "./plugin/expose-entry.mjs";
4
3
  // import { EntryRenamePlugin } from './plugin/entry-rename.mts';
5
4
  import { MinaRuntimeWebpackPlugin } from "./plugin/mina-runtime.mjs";
6
- import MiniCssExtractPlugin from 'mini-css-extract-plugin';
7
- export const COMPONENT_ROOT = 'as-components';
8
- function reach(path) {
9
- return fileURLToPath(import.meta.resolve(path));
10
- }
11
- const theLoader = reach('@into-mini/sfc-split-loader/dist/index.mjs');
12
5
  export class SfcSplitPlugin {
13
6
  options;
14
- constructor({ type = false, tagMatcher, preserveTap, loaders = true, } = {}) {
7
+ constructor({ type = false, tagMatcher, preserveTap } = {}) {
15
8
  this.options = {
16
9
  type,
17
10
  tagMatcher,
18
11
  preserveTap,
19
- loaders,
20
12
  };
21
13
  }
22
- #applyLoader(compiler) {
23
- compiler.options.module.rules.push({
24
- test: /\.vue$/,
25
- issuer: /\.vue$/,
26
- resourceQuery: /type=script/,
27
- type: 'javascript/esm',
28
- loader: theLoader,
29
- }, {
30
- test: /\.vue$/,
31
- issuer: /\.vue$/,
32
- resourceQuery: /type=template/,
33
- type: 'asset/resource',
34
- generator: {
35
- filename: '[entry].wxml',
36
- },
37
- use: [
38
- {
39
- loader: reach('@into-mini/wxml-loader'),
40
- },
41
- {
42
- loader: theLoader,
43
- },
44
- ],
45
- }, {
46
- test: /\.vue$/,
47
- issuer: /\.vue$/,
48
- resourceQuery: /type=style/,
49
- use: [
50
- { loader: MiniCssExtractPlugin.loader },
51
- { loader: 'css-loader' },
52
- { loader: theLoader },
53
- ],
54
- }, {
55
- test: /\.vue$/,
56
- issuer: /\.vue$/,
57
- resourceQuery: [/type=config&lang=json/],
58
- type: 'asset/resource',
59
- generator: {
60
- filename: '[entry].json',
61
- },
62
- use: [
63
- {
64
- loader: reach('@into-mini/sfc-split-plugin/dist/loader/entry-loader.mjs'),
65
- options: {
66
- componentRoot: COMPONENT_ROOT,
67
- },
68
- },
69
- {
70
- loader: theLoader,
71
- },
72
- ],
73
- }, {
74
- test: /\.vue$/,
75
- resourceQuery: { not: /type=/ },
76
- type: 'javascript/esm',
77
- loader: theLoader,
78
- }, {
79
- test: /\.vue$/,
80
- enforce: 'pre',
81
- loader: reach('@into-mini/sfc-split-loader/dist/next.mjs'),
82
- options: this.options,
83
- });
84
- }
85
14
  apply(compiler) {
86
- const { loaders, type } = this.options;
87
- if (loaders) {
88
- this.#applyLoader(compiler);
89
- }
15
+ const { type } = this.options;
90
16
  if (type) {
91
17
  new AddWxsPlugin().apply(compiler);
92
18
  new MinaRuntimeWebpackPlugin().apply(compiler);
@@ -10,7 +10,8 @@ function createShortHash(input) {
10
10
  function reach(path) {
11
11
  return fileURLToPath(import.meta.resolve(path));
12
12
  }
13
- function handleImport({ toThis, addSmartEntry, componentRoot, context, rootContext, maps, callback, }) {
13
+ const componentRoot = 'as-components';
14
+ function handleImport({ toThis, addSmartEntry, context, rootContext, maps, callback, }) {
14
15
  if (Object.keys(maps).length > 0) {
15
16
  for (const [name, path] of Object.entries(maps)) {
16
17
  if (path.endsWith('.vue') && !path.startsWith('plugin://')) {
@@ -54,9 +55,8 @@ function handleImport({ toThis, addSmartEntry, componentRoot, context, rootConte
54
55
  export default function loader(source) {
55
56
  this.cacheable();
56
57
  const callback = this.async();
57
- const { componentRoot } = this.getOptions();
58
58
  const { entryName: thisEntryName } = this;
59
- const config = JSON.parse(source);
59
+ const config = JSON.parse(source.trim() || '{}');
60
60
  const { rootContext, context } = this;
61
61
  function toThis(entryName) {
62
62
  return slash(relative(`/${thisEntryName}/..`, `/${entryName}`));
@@ -86,7 +86,6 @@ export default function loader(source) {
86
86
  handleImport.bind(this)({
87
87
  toThis,
88
88
  addSmartEntry,
89
- componentRoot,
90
89
  context,
91
90
  rootContext,
92
91
  maps: Object.fromEntries(Object.entries(config.componentGenerics)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@into-mini/sfc-split-plugin",
3
- "version": "0.5.12",
3
+ "version": "0.6.1",
4
4
  "license": "MIT",
5
5
  "keywords": [
6
6
  "loader",
@@ -28,14 +28,12 @@
28
28
  ],
29
29
  "type": "module",
30
30
  "dependencies": {
31
- "mini-css-extract-plugin": "^2.9.4",
32
31
  "slash": "^5.1.0",
33
- "webpack-virtual-modules": "^0.6.2",
34
32
  "yaml": "^2.8.2",
35
- "@into-mini/clsx": "^0.1.0",
36
- "@into-mini/sfc-transformer": "^0.6.2",
33
+ "@into-mini/clsx": "^0.1.1",
34
+ "@into-mini/sfc-split-loader": "^0.2.6",
37
35
  "@into-mini/wxml-loader": "^0.0.0",
38
- "@into-mini/sfc-split-loader": "^0.2.6"
36
+ "@into-mini/sfc-transformer": "^0.6.3"
39
37
  },
40
38
  "peerDependencies": {
41
39
  "webpack": "^5.104.0"