create-packer 1.24.29 → 1.24.31

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "create-packer",
3
- "version": "1.24.29",
3
+ "version": "1.24.31",
4
4
  "main": "index.js",
5
5
  "repository": "https://github.com/kevily/create-packer",
6
6
  "author": "1k <bug_zero@163.com>",
@@ -0,0 +1,26 @@
1
+ import { concat, forEach, isArray, isRegExp, keys, remove, size } from 'lodash-es'
2
+ import pkg from '../package.json'
3
+
4
+ export function createChunks(chunks: { [key: string]: Array<string | RegExp> }) {
5
+ const result: { [key: string]: string[] } = {
6
+ vendor: keys(pkg.dependencies)
7
+ }
8
+
9
+ forEach(chunks, (values, key) => {
10
+ if (!isArray(result[key])) {
11
+ result[key] = []
12
+ }
13
+ forEach(values, value => {
14
+ let modules: string[] = []
15
+ if (isRegExp(value)) {
16
+ modules = remove(result.vendor, name => value.test(name))
17
+ } else {
18
+ modules = remove(result.vendor, name => name === value)
19
+ }
20
+ if (size(modules) > 0) {
21
+ result[key] = concat(result[key], modules)
22
+ }
23
+ })
24
+ })
25
+ return result
26
+ }
@@ -0,0 +1 @@
1
+ export * from './createChunks'
@@ -1,9 +1,10 @@
1
1
  {
2
- "compilerOptions": {
3
- "composite": true,
4
- "module": "ESNext",
5
- "moduleResolution": "Node",
6
- "allowSyntheticDefaultImports": true
7
- },
8
- "include": ["vite.config.ts"]
2
+ "compilerOptions": {
3
+ "composite": true,
4
+ "module": "ESNext",
5
+ "moduleResolution": "Node",
6
+ "allowSyntheticDefaultImports": true,
7
+ "resolveJsonModule": true
8
+ },
9
+ "include": ["scripts", "vite.config.ts", "package.json"]
9
10
  }
@@ -3,6 +3,7 @@ import react from '@vitejs/plugin-react'
3
3
  import svgr from 'vite-plugin-svgr'
4
4
  import mockDevServer from 'vite-plugin-mock-dev-server'
5
5
  import checker from 'vite-plugin-checker'
6
+ import { createChunks } from './scripts'
6
7
 
7
8
  // https://vitejs.dev/config/
8
9
  export default defineConfig(({ mode }) => {
@@ -46,9 +47,9 @@ export default defineConfig(({ mode }) => {
46
47
  build: {
47
48
  rollupOptions: {
48
49
  output: {
49
- manualChunks: {
50
+ manualChunks: createChunks({
50
51
  react: ['react', 'react-dom']
51
- }
52
+ })
52
53
  }
53
54
  }
54
55
  },
@@ -30,11 +30,11 @@
30
30
  "zustand": "4.4.1"
31
31
  },
32
32
  "devDependencies": {
33
- "@commitlint/cli": "^17.7.1",
34
- "@commitlint/config-conventional": "^17.7.0",
35
- "@commitlint/cz-commitlint": "^17.7.1",
36
- "@types/lodash-es": "^4.17.8",
37
- "@types/qs": "^6.9.7",
33
+ "@commitlint/cli": "17.7.1",
34
+ "@commitlint/config-conventional": "17.7.0",
35
+ "@commitlint/cz-commitlint": "17.7.1",
36
+ "@types/lodash-es": "4.17.8",
37
+ "@types/qs": "6.9.7",
38
38
  "@types/react": "18.2.21",
39
39
  "@types/react-dom": "18.2.7",
40
40
  "@types/react-redux": "7.1.26",
@@ -42,20 +42,20 @@
42
42
  "@types/react-router-dom": "5.3.3",
43
43
  "@typescript-eslint/eslint-plugin": "6.5.0",
44
44
  "@typescript-eslint/parser": "6.5.0",
45
- "autoprefixer": "^10.4.15",
46
- "commitizen": "^4.3.0",
45
+ "autoprefixer": "10.4.15",
46
+ "commitizen": "4.3.0",
47
47
  "css-loader": "6.8.1",
48
- "cssnano": "^6.0.1",
49
- "dotenv": "^16.3.1",
50
- "esbuild-loader": "^4.0.1",
48
+ "cssnano": "6.0.1",
49
+ "dotenv": "16.3.1",
50
+ "esbuild-loader": "4.0.1",
51
51
  "eslint": "8.48.0",
52
52
  "eslint-import-resolver-typescript": "3.5.5",
53
53
  "eslint-plugin-import": "2.27.5",
54
54
  "eslint-plugin-prettier": "5.0.0",
55
55
  "eslint-plugin-react": "7.32.2",
56
56
  "eslint-plugin-react-hooks": "4.6.0",
57
- "eslint-webpack-plugin": "^4.0.1",
58
- "fork-ts-checker-webpack-plugin": "^8.0.0",
57
+ "eslint-webpack-plugin": "4.0.1",
58
+ "fork-ts-checker-webpack-plugin": "8.0.0",
59
59
  "html-webpack-plugin": "5.5.3",
60
60
  "husky": "8.0.3",
61
61
  "mini-css-extract-plugin": "2.7.6",
@@ -117,6 +117,11 @@ export default function (env) {
117
117
  test: /[\\/](react|react-dom)[\\/]/,
118
118
  chunks: 'all',
119
119
  name: 'react'
120
+ },
121
+ vendor: {
122
+ test: /[\\/](node_modules)[\\/]/,
123
+ chunks: 'all',
124
+ name: 'vendor'
120
125
  }
121
126
  }
122
127
  }
@@ -0,0 +1,26 @@
1
+ import { concat, forEach, isArray, isRegExp, keys, remove, size } from 'lodash-es'
2
+ import pkg from '../package.json'
3
+
4
+ export function createChunks(chunks: { [key: string]: Array<string | RegExp> }) {
5
+ const result: { [key: string]: string[] } = {
6
+ vendor: keys(pkg.dependencies)
7
+ }
8
+
9
+ forEach(chunks, (values, key) => {
10
+ if (!isArray(result[key])) {
11
+ result[key] = []
12
+ }
13
+ forEach(values, value => {
14
+ let modules: string[] = []
15
+ if (isRegExp(value)) {
16
+ modules = remove(result.vendor, name => value.test(name))
17
+ } else {
18
+ modules = remove(result.vendor, name => name === value)
19
+ }
20
+ if (size(modules) > 0) {
21
+ result[key] = concat(result[key], modules)
22
+ }
23
+ })
24
+ })
25
+ return result
26
+ }
@@ -0,0 +1 @@
1
+ export * from './createChunks'
@@ -1,9 +1,10 @@
1
1
  {
2
- "compilerOptions": {
3
- "composite": true,
4
- "module": "ESNext",
5
- "moduleResolution": "Node",
6
- "allowSyntheticDefaultImports": true
7
- },
8
- "include": ["vite.config.ts"]
2
+ "compilerOptions": {
3
+ "composite": true,
4
+ "module": "ESNext",
5
+ "moduleResolution": "Node",
6
+ "allowSyntheticDefaultImports": true,
7
+ "resolveJsonModule": true
8
+ },
9
+ "include": ["scripts", "vite.config.ts", "package.json"]
9
10
  }
@@ -4,6 +4,7 @@ import vueJsx from '@vitejs/plugin-vue-jsx'
4
4
  import svgLoader from 'vite-svg-loader'
5
5
  import mockDevServer from 'vite-plugin-mock-dev-server'
6
6
  import checker from 'vite-plugin-checker'
7
+ import { createChunks } from './scripts'
7
8
 
8
9
  // https://vitejs.dev/config/
9
10
  export default defineConfig(({ mode }) => {
@@ -53,9 +54,9 @@ export default defineConfig(({ mode }) => {
53
54
  build: {
54
55
  rollupOptions: {
55
56
  output: {
56
- manualChunks: {
57
- react: ['vue', 'vue-router']
58
- }
57
+ manualChunks: createChunks({
58
+ vue: ['vue', 'vue-router']
59
+ })
59
60
  }
60
61
  }
61
62
  },