@codelet/cli-service 0.0.13 → 0.0.15

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/config.js CHANGED
@@ -18,7 +18,11 @@ function getDefaultConfig(options) {
18
18
  pageIndex: '',
19
19
  publicDir: 'public',
20
20
  entryPath: './src',
21
- source: ['app.(js|ts)', 'pages/**/*.(js|ts)', 'components/**/*.(js|ts)'],
21
+ source: [
22
+ 'app.(js|ts)',
23
+ '(pages|components)/**/index.(js|ts)',
24
+ 'packages/*/(pages|components)/**/index.(js|ts)',
25
+ ],
22
26
  }, options);
23
27
  // 模式
24
28
  const mode = isDev ? 'development' : 'production';
@@ -46,12 +50,52 @@ function getDefaultConfig(options) {
46
50
  plugins.push(new hmr_webpack_plugin_1.default());
47
51
  }
48
52
  // 优化
53
+ const packageRootPattern = /[\\/]src[\\/]packages[\\/]([^\\/]+)[\\/]/;
54
+ const getPackageBundleName = (name) => {
55
+ const normalizedName = name.replace(/\\/g, '/');
56
+ if (normalizedName.startsWith('packages/')) {
57
+ const [, packageName] = normalizedName.split('/');
58
+ if (packageName) {
59
+ return `packages/${packageName}/bundle`;
60
+ }
61
+ }
62
+ return null;
63
+ };
64
+ const getModuleResource = (module) => {
65
+ if (!module || typeof module !== 'object') {
66
+ return '';
67
+ }
68
+ return 'resource' in module && typeof module.resource === 'string' ? module.resource : '';
69
+ };
49
70
  const optimization = {
50
71
  splitChunks: {
51
72
  chunks: 'all',
52
73
  minChunks: 2,
53
74
  minSize: 0,
54
75
  cacheGroups: {
76
+ subpackage: {
77
+ test(module) {
78
+ return Boolean(getModuleResource(module).match(packageRootPattern));
79
+ },
80
+ name(module, chunks) {
81
+ const match = getModuleResource(module).match(packageRootPattern);
82
+ if (!match) {
83
+ return 'bundle';
84
+ }
85
+ const packageBundleName = `packages/${match[1]}/bundle`;
86
+ const bundleNames = new Set(chunks
87
+ .map((chunk) => chunk.name)
88
+ .filter((name) => typeof name === 'string' && Boolean(name))
89
+ .map((name) => getPackageBundleName(name))
90
+ .filter((name) => typeof name === 'string' && Boolean(name)));
91
+ return bundleNames.size <= 1 && bundleNames.has(packageBundleName)
92
+ ? packageBundleName
93
+ : 'bundle';
94
+ },
95
+ priority: 10,
96
+ minChunks: 2,
97
+ chunks: 'all',
98
+ },
55
99
  main: {
56
100
  name: 'bundle',
57
101
  minChunks: 2,
package/dist/utils.js CHANGED
@@ -23,7 +23,7 @@ const parseDir = (entryPath, source) => {
23
23
  const { dir, name } = path_1.default.parse(relPath);
24
24
  res[path_1.default.join(dir, name)] = {
25
25
  import: filepath,
26
- runtime: 'bundle',
26
+ runtime: 'runtime',
27
27
  };
28
28
  return res;
29
29
  }, {});
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codelet/cli-service",
3
- "version": "0.0.13",
3
+ "version": "0.0.15",
4
4
  "description": "cli-service",
5
5
  "bin": {
6
6
  "codelet-cli-service": "./bin/codelet-cli-service.js"
@@ -41,15 +41,19 @@
41
41
  "webpack": "5.89.0",
42
42
  "webpack-merge": "^5.10.0",
43
43
  "webpackbar": "^6.0.0",
44
- "@codelet/inject-chunk-webpack-plugin": "^0.0.7",
45
- "@codelet/app-json-webpack-plugin": "^0.0.7",
46
- "@codelet/hmr-webpack-plugin": "^0.0.2",
44
+ "@codelet/inject-chunk-webpack-plugin": "^0.0.8",
45
+ "@codelet/hmr-webpack-plugin": "^0.0.3",
47
46
  "@codelet/copy-loader": "^0.0.7",
47
+ "@codelet/app-json-webpack-plugin": "^0.0.8",
48
48
  "@codelet/wxml-loader": "^0.0.9"
49
49
  },
50
50
  "devDependencies": {
51
+ "@daysnap/utils": "^0.1.29",
51
52
  "rimraf": "^5.0.5"
52
53
  },
54
+ "peerDependencies": {
55
+ "@daysnap/utils": ">=0.1.29"
56
+ },
53
57
  "scripts": {
54
58
  "build": "npm run clean && tsc -p ./tsconfig.lib.json",
55
59
  "clean": "rimraf ./dist",