zmp-cli 3.15.1 → 3.15.2-beta.0

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/build/index.js CHANGED
@@ -111,15 +111,42 @@ module.exports = async (options = {}, logger, { exitOnError = true } = {}) => {
111
111
  _.pick(obj, [
112
112
  'fileName',
113
113
  'type',
114
+ 'imports',
114
115
  'isEntry',
115
116
  'isImplicitEntry',
116
117
  'isDynamicEntry',
117
118
  ])
118
119
  );
120
+
121
+ const outputMap = new Map();
122
+ output.forEach((obj) => {
123
+ outputMap.set(obj.fileName, obj);
124
+ });
125
+
126
+ // Entry files, cần đc load sync bằng thẻ script
119
127
  const jsFiles = output.filter((file) => {
120
- if (file.type !== 'chunk') return false;
121
- return file.isEntry || !file.isDynamicEntry;
128
+ return file.type === 'chunk' && file.isEntry;
122
129
  });
130
+
131
+ // Các file cần preload
132
+ const modulePreloadFiles = [];
133
+ const getImportedChunks = (chunk, seen = new Set()) => {
134
+ const chunks = [];
135
+ chunk.imports.forEach((file) => {
136
+ const importee = outputMap.get(file);
137
+ if (importee?.type === 'chunk' && !seen.has(file)) {
138
+ seen.add(file);
139
+ chunks.push(...getImportedChunks(importee, seen));
140
+ chunks.push(importee);
141
+ }
142
+ });
143
+ return chunks;
144
+ };
145
+ jsFiles.forEach((file) => {
146
+ const chunks = getImportedChunks(file);
147
+ modulePreloadFiles.push(...chunks);
148
+ });
149
+
123
150
  const cssFiles = output.filter((file) => {
124
151
  if (file.type !== 'asset' || !file.fileName.endsWith('.css'))
125
152
  return false;
@@ -138,6 +165,7 @@ module.exports = async (options = {}, logger, { exitOnError = true } = {}) => {
138
165
  ...jsFiles.map((f) => f.fileName),
139
166
  ],
140
167
  listAsyncJS: [
168
+ ...modulePreloadFiles.map((f) => f.fileName),
141
169
  ...(Array.isArray(appConfig.listAsyncJS) ? appConfig.listAsyncJS : []),
142
170
  ],
143
171
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zmp-cli",
3
- "version": "3.15.1",
3
+ "version": "3.15.2-beta.0",
4
4
  "description": "ZMP command line utility (CLI)",
5
5
  "main": "index.js",
6
6
  "bin": {
@@ -1,5 +0,0 @@
1
- {
2
- "prettier.trailingComma": "none",
3
- "workbench.colorTheme": "GitHub Dark Default",
4
- "editor.formatOnSave": false
5
- }