@best-shot/preset-mini 0.10.7 → 0.10.9

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.
Files changed (2) hide show
  1. package/index.mjs +31 -25
  2. package/package.json +3 -3
package/index.mjs CHANGED
@@ -2,25 +2,30 @@ export function apply({
2
2
  config: { mini: { type } = {}, output: { module: Module } = {} },
3
3
  }) {
4
4
  return async (chain) => {
5
- chain.output.publicPath('/').iife(false).asyncChunks(false);
5
+ chain.output
6
+ .publicPath('/')
7
+ .iife(false)
8
+ .asyncChunks(false)
9
+ .filename('[name].js')
10
+ .globalObject('globalThis')
11
+ .strictModuleErrorHandling(true)
12
+ .environment({
13
+ document: false,
14
+ dynamicImport: false,
15
+ globalThis: true,
16
+ });
6
17
 
7
18
  if (Module) {
8
19
  chain.output.merge({
9
20
  module: true,
10
21
  chunkFormat: 'module',
11
22
  chunkLoading: 'import',
12
- library: {
13
- type: 'module',
14
- },
15
23
  });
16
24
  } else {
17
25
  chain.output.merge({
18
26
  module: false,
19
27
  chunkFormat: 'commonjs',
20
28
  chunkLoading: 'require',
21
- library: {
22
- type: 'commonjs2',
23
- },
24
29
  });
25
30
  }
26
31
 
@@ -61,7 +66,7 @@ export function apply({
61
66
  modules: false,
62
67
  }));
63
68
 
64
- chain.experiments.set('layers', true);
69
+ chain.experiments.layers(true);
65
70
 
66
71
  const rule = chain.module.rule('babel');
67
72
 
@@ -77,21 +82,25 @@ export function apply({
77
82
 
78
83
  const presets = ['vendor', 'common', 'shim', 'vue-mini', 'vue', 'react'];
79
84
 
80
- chain.optimization.splitChunks.cacheGroups(
81
- Object.fromEntries(
82
- Object.entries(chain.optimization.splitChunks.get('cacheGroups')).map(
83
- ([key, value]) => [
84
- key,
85
- {
86
- ...value,
87
- name: presets.includes(value.name)
88
- ? ['share', value.name].join('/')
89
- : value.name,
90
- },
91
- ],
85
+ chain.optimization.avoidEntryIife(true);
86
+
87
+ if (chain.optimization.splitChunks.get('cacheGroups')) {
88
+ chain.optimization.splitChunks.cacheGroups(
89
+ Object.fromEntries(
90
+ Object.entries(chain.optimization.splitChunks.get('cacheGroups')).map(
91
+ ([key, value]) => [
92
+ key,
93
+ {
94
+ ...value,
95
+ name: presets.includes(value.name)
96
+ ? ['share', value.name].join('/')
97
+ : value.name,
98
+ },
99
+ ],
100
+ ),
92
101
  ),
93
- ),
94
- );
102
+ );
103
+ }
95
104
  };
96
105
  }
97
106
 
@@ -122,9 +131,6 @@ export const schema = {
122
131
  keep: 'miniprogram_npm',
123
132
  },
124
133
  },
125
- publicPath: {
126
- default: '/',
127
- },
128
134
  cssFilename: {
129
135
  default: '.wxss',
130
136
  },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@best-shot/preset-mini",
3
- "version": "0.10.7",
3
+ "version": "0.10.9",
4
4
  "description": "A `best-shot` preset for mini program project",
5
5
  "license": "MIT",
6
6
  "author": {
@@ -29,10 +29,10 @@
29
29
  "type": "module",
30
30
  "dependencies": {
31
31
  "yaml": "^2.7.1",
32
- "@best-shot/sfc-split-plugin": "~0.13.11"
32
+ "@best-shot/sfc-split-plugin": "~0.13.15"
33
33
  },
34
34
  "peerDependencies": {
35
- "@best-shot/core": "~0.12.9",
35
+ "@best-shot/core": "~0.12.10",
36
36
  "@best-shot/preset-babel": "~0.17.6",
37
37
  "@best-shot/preset-style": "~0.15.5"
38
38
  },