@tarojs/webpack5-runner 4.1.12-beta.5 → 4.1.12-beta.51

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.
@@ -0,0 +1,918 @@
1
+ "use strict";
2
+ var __importDefault = (this && this.__importDefault) || function (mod) {
3
+ return (mod && mod.__esModule) ? mod : { "default": mod };
4
+ };
5
+ Object.defineProperty(exports, "__esModule", { value: true });
6
+ exports.subPackageIndieCustomWrapperRootsKey = void 0;
7
+ const node_path_1 = __importDefault(require("node:path"));
8
+ const helper_1 = require("@tarojs/helper");
9
+ const loader_utils_1 = require("loader-utils");
10
+ const component_1 = require("../utils/component");
11
+ const webpack_1 = require("../utils/webpack");
12
+ const MiniPlugin_1 = require("./MiniPlugin");
13
+ exports.subPackageIndieCustomWrapperRootsKey = '__taroSubPackageIndieCustomWrapperRoots';
14
+ const PLUGIN_NAME = 'TaroSubPackageIndiePlugin';
15
+ class SubPackageIndiePlugin {
16
+ constructor(miniPlugin) {
17
+ this.moduleRequestMap = new Map();
18
+ this.subPackageIndieConfigsCache = null;
19
+ this.allIndieRootsCache = null;
20
+ this.allMainPackageRootsCache = null;
21
+ this.subPackageIndieMatchCache = new Map();
22
+ this.entriesByRootCache = null;
23
+ this.componentByNameCache = null;
24
+ this.forceCustomWrapperByRootCache = new Map();
25
+ this.scopedComponentConfigByCompilation = new WeakMap();
26
+ this.rootUsingCustomWrapperByCompilation = new WeakMap();
27
+ this.miniPlugin = miniPlugin;
28
+ this.options = miniPlugin.options;
29
+ }
30
+ invalidateRunCache() {
31
+ this.subPackageIndieConfigsCache = null;
32
+ this.allIndieRootsCache = null;
33
+ this.allMainPackageRootsCache = null;
34
+ this.subPackageIndieMatchCache.clear();
35
+ this.entriesByRootCache = null;
36
+ this.componentByNameCache = null;
37
+ this.forceCustomWrapperByRootCache.clear();
38
+ }
39
+ apply() {
40
+ this.miniPlugin.hooks.modifyEntries.tap(PLUGIN_NAME, entries => {
41
+ const shouldSkipRootEntries = this.hasSubPackageIndieMainPackageRoot() && this.options.newBlended;
42
+ if (!shouldSkipRootEntries)
43
+ return entries;
44
+ return Object.assign(Object.assign({}, entries), { skipRootComp: true, skipRootWrapper: true });
45
+ });
46
+ this.miniPlugin.hooks.afterResolveModule.tap(PLUGIN_NAME, (resolveData) => {
47
+ var _a, _b;
48
+ if (!this.options.newBlended)
49
+ return;
50
+ const issuer = (_a = resolveData.contextInfo) === null || _a === void 0 ? void 0 : _a.issuer;
51
+ const request = resolveData.request;
52
+ const resource = ((_b = resolveData.createData) === null || _b === void 0 ? void 0 : _b.resource) || resolveData.resource;
53
+ if (issuer && request && resource) {
54
+ this.setResolvedRequestResource(issuer, request, resource);
55
+ }
56
+ if (resolveData.request !== helper_1.taroJsComponents)
57
+ return;
58
+ if (!issuer || !issuer.startsWith(this.options.sourceDir))
59
+ return;
60
+ const componentName = this.miniPlugin.getComponentName(issuer);
61
+ const root = this.isInSubPackageIndieRoot(componentName);
62
+ if (!root)
63
+ return;
64
+ resolveData.dependencies.forEach((dependency) => {
65
+ var _a;
66
+ if (((_a = dependency.ids) === null || _a === void 0 ? void 0 : _a.length) > 0) {
67
+ dependency.ids.forEach((id) => {
68
+ const dashedName = this.toDashedComponentName(id);
69
+ if (!component_1.componentConfig.scopedIncludes.has(root)) {
70
+ component_1.componentConfig.scopedIncludes.set(root, new Set());
71
+ }
72
+ component_1.componentConfig.scopedIncludes.get(root).add(dashedName);
73
+ });
74
+ }
75
+ });
76
+ });
77
+ this.miniPlugin.hooks.modifyChunkRequire.tap(PLUGIN_NAME, (result, chunkId, miniType) => {
78
+ if (!this.options.newBlended)
79
+ return result;
80
+ if (this.miniPlugin.nativeComponents.has(chunkId) || miniType === helper_1.META_TYPE.STATIC) {
81
+ const isSubPackageIndie = this.isInSubPackageIndieRoot(chunkId);
82
+ if (isSubPackageIndie) {
83
+ return {
84
+ source: result.source,
85
+ handled: true,
86
+ };
87
+ }
88
+ }
89
+ else if (miniType === helper_1.META_TYPE.PAGE) {
90
+ const subPackageIndieRoot = this.isInSubPackageIndieRoot(chunkId);
91
+ if (subPackageIndieRoot) {
92
+ return {
93
+ source: (0, webpack_1.addRequireToSource)(chunkId, result.source, [{ name: `${subPackageIndieRoot}/app` }]),
94
+ handled: true,
95
+ };
96
+ }
97
+ }
98
+ return result;
99
+ });
100
+ this.miniPlugin.hooks.modifySkipRootTemplates.tap(PLUGIN_NAME, skip => {
101
+ return skip || (this.hasSubPackageIndieMainPackageRoot() && this.options.newBlended);
102
+ });
103
+ this.miniPlugin.hooks.generateExtraFiles.tap(PLUGIN_NAME, (customWrapperRoots, compilation, compiler) => {
104
+ if (!this.options.newBlended)
105
+ return customWrapperRoots;
106
+ if (!this.getSubPackageIndieConfigs().length)
107
+ return customWrapperRoots;
108
+ const roots = this.generateSubPackageIndieFiles(compilation, compiler, this.options.template, 'base');
109
+ compilation[exports.subPackageIndieCustomWrapperRootsKey] = roots;
110
+ return roots;
111
+ });
112
+ this.miniPlugin.hooks.modifyComponentConfig.tap(PLUGIN_NAME, ({ config, component }, customWrapperRoots) => {
113
+ const indieMatch = this.getSubPackageIndieMatch(component.name);
114
+ if (!indieMatch || component.isNative)
115
+ return;
116
+ const importBaseCompPath = this.getRootRelativePath(component.path, indieMatch.root, this.miniPlugin.getTargetFilePath(MiniPlugin_1.baseCompName, ''));
117
+ const importCustomWrapperPath = this.getRootRelativePath(component.path, indieMatch.root, this.miniPlugin.getTargetFilePath(MiniPlugin_1.customWrapperName, ''));
118
+ config.content.usingComponents = Object.assign({}, config.content.usingComponents);
119
+ const isRootUsingCustomWrapper = customWrapperRoots.has(indieMatch.root);
120
+ const isRootRecursiveDisabled = this.isRecursiveComponentDisabledForRoot(indieMatch.root);
121
+ if (isRootUsingCustomWrapper && !isRootRecursiveDisabled && !config.content.usingComponents[MiniPlugin_1.customWrapperName]) {
122
+ config.content.usingComponents[MiniPlugin_1.customWrapperName] = importCustomWrapperPath;
123
+ }
124
+ if (!this.options.template.isSupportRecursive && !isRootRecursiveDisabled && !config.content.usingComponents[MiniPlugin_1.baseCompName]) {
125
+ config.content.usingComponents[MiniPlugin_1.baseCompName] = importBaseCompPath;
126
+ }
127
+ });
128
+ this.miniPlugin.hooks.modifyPageConfig.tap(PLUGIN_NAME, (context, page, customWrapperRoots) => {
129
+ const subPackageIndieRoot = this.isInSubPackageIndieRoot(page.name);
130
+ if (!subPackageIndieRoot)
131
+ return context;
132
+ const isPageRecursiveDisabled = this.isRecursiveComponentDisabledForRoot(subPackageIndieRoot);
133
+ const shouldUseCustomWrapper = customWrapperRoots.has(subPackageIndieRoot) && !isPageRecursiveDisabled;
134
+ return Object.assign(Object.assign({}, context), { importBaseTemplatePath: this.getRootRelativePath(page.path, subPackageIndieRoot, this.miniPlugin.getTemplatePath('base')), importBaseCompPath: this.getRootRelativePath(page.path, subPackageIndieRoot, this.miniPlugin.getTargetFilePath(MiniPlugin_1.baseCompName, '')), importCustomWrapperPath: this.getRootRelativePath(page.path, subPackageIndieRoot, this.miniPlugin.getTargetFilePath(MiniPlugin_1.customWrapperName, '')), shouldUseCustomWrapper,
135
+ isPageRecursiveDisabled });
136
+ });
137
+ this.miniPlugin.hooks.afterGenerateFiles.tap(PLUGIN_NAME, (compilation, compiler) => {
138
+ if (this.hasSubPackageIndieMainPackageRoot() && this.options.newBlended) {
139
+ this.generateMainPackageRuntimeFiles(compilation, compiler);
140
+ }
141
+ });
142
+ this.miniPlugin.hooks.optimizeAssets.tap(PLUGIN_NAME, compilation => {
143
+ if (!this.options.newBlended)
144
+ return;
145
+ const hasSubPackageIndieCustomWrapperRoots = compilation[exports.subPackageIndieCustomWrapperRootsKey] instanceof Set;
146
+ const subPackageIndieCustomWrapperRoots = hasSubPackageIndieCustomWrapperRoots
147
+ ? compilation[exports.subPackageIndieCustomWrapperRootsKey]
148
+ : new Set();
149
+ this.getAllIndieRoots().forEach(root => {
150
+ if (this.isRecursiveComponentDisabledForRoot(root)) {
151
+ delete compilation.assets[`${root}/${MiniPlugin_1.baseCompName}.js`];
152
+ delete compilation.assets[`${root}/${MiniPlugin_1.baseCompName}${this.options.fileType.config}`];
153
+ delete compilation.assets[`${root}/${MiniPlugin_1.baseCompName}${this.options.fileType.templ}`];
154
+ delete compilation.assets[`${root}/${MiniPlugin_1.customWrapperName}.js`];
155
+ delete compilation.assets[`${root}/${MiniPlugin_1.customWrapperName}${this.options.fileType.config}`];
156
+ delete compilation.assets[`${root}/${MiniPlugin_1.customWrapperName}${this.options.fileType.templ}`];
157
+ return;
158
+ }
159
+ const isRootUsingCustomWrapper = hasSubPackageIndieCustomWrapperRoots
160
+ ? subPackageIndieCustomWrapperRoots.has(root)
161
+ : this.isSubPackageIndieRootUsingCustomWrapper(compilation, root, this.getScopedSubPackageIndieComponentConfig(compilation, root).thirdPartyComponents);
162
+ if (isRootUsingCustomWrapper)
163
+ return;
164
+ delete compilation.assets[`${root}/${MiniPlugin_1.customWrapperName}.js`];
165
+ delete compilation.assets[`${root}/${MiniPlugin_1.customWrapperName}${this.options.fileType.config}`];
166
+ delete compilation.assets[`${root}/${MiniPlugin_1.customWrapperName}${this.options.fileType.templ}`];
167
+ });
168
+ if (this.hasSubPackageIndieMainPackageRoot()) {
169
+ const styleExt = this.options.fileType.style;
170
+ const runtimeChunks = ['app', ...this.options.commonChunks];
171
+ runtimeChunks.forEach(chunkName => {
172
+ delete compilation.assets[`${chunkName}.js`];
173
+ delete compilation.assets[`${chunkName}${styleExt}`];
174
+ });
175
+ delete compilation.assets[`app-origin${styleExt}`];
176
+ delete compilation.assets[`${MiniPlugin_1.baseCompName}.js`];
177
+ delete compilation.assets[`${MiniPlugin_1.customWrapperName}.js`];
178
+ }
179
+ });
180
+ this.miniPlugin.hooks.modifyConfig.tap(PLUGIN_NAME, (config, componentName) => {
181
+ const subPackageIndieRoot = this.isInSubPackageIndieRoot(componentName);
182
+ if (subPackageIndieRoot && this.miniPlugin.nativeComponents.has(componentName)) {
183
+ const styleIsolation = this.options.template.isSupportRecursive
184
+ ? MiniPlugin_1.STYLE_ISOLATION_APPLY_SHARED
185
+ : MiniPlugin_1.STYLE_ISOLATION_SHARED;
186
+ config.styleIsolation = config.styleIsolation || styleIsolation;
187
+ config.isNewBlended = true;
188
+ }
189
+ return config;
190
+ });
191
+ this.miniPlugin.hooks.modifyShouldProcessStyles.tap(PLUGIN_NAME, shouldProcess => {
192
+ const hasMainPackageRoot = this.hasSubPackageIndieMainPackageRoot() && this.options.newBlended;
193
+ return shouldProcess || hasMainPackageRoot;
194
+ });
195
+ this.miniPlugin.hooks.modifyStyleImport.tap(PLUGIN_NAME, (context, page) => {
196
+ if (!this.options.newBlended)
197
+ return context;
198
+ const indieMatch = this.getSubPackageIndieMatch(page.name);
199
+ if (!indieMatch)
200
+ return context;
201
+ if (this.miniPlugin.nativeComponents.has(page.name)) {
202
+ if (indieMatch.isMainPackageRoot) {
203
+ return Object.assign(Object.assign({}, context), { importStatement: `@import ${JSON.stringify((0, loader_utils_1.urlToRequest)('./app' + this.options.fileType.style))};\n`, shouldSkip: false, isMainPackageRoot: true });
204
+ }
205
+ return Object.assign(Object.assign({}, context), { importStatement: '', shouldSkip: true, isMainPackageRoot: false });
206
+ }
207
+ if (indieMatch.isMainPackageRoot) {
208
+ return Object.assign(Object.assign({}, context), { importStatement: `@import ${JSON.stringify((0, loader_utils_1.urlToRequest)('./app' + this.options.fileType.style))};\n`, shouldSkip: false, isMainPackageRoot: true });
209
+ }
210
+ return context;
211
+ });
212
+ }
213
+ getRootRelativePath(fromPath, root, targetPath) {
214
+ return (0, helper_1.promoteRelativePath)(node_path_1.default.relative(fromPath, node_path_1.default.join(this.options.sourceDir, root, targetPath)));
215
+ }
216
+ normalizeIndieRoot(root) {
217
+ if (root.endsWith('/index')) {
218
+ return node_path_1.default.dirname(root);
219
+ }
220
+ return root;
221
+ }
222
+ parseIndieRootConfig(rootConfig) {
223
+ if (typeof rootConfig === 'string') {
224
+ return { path: this.normalizeIndieRoot(rootConfig), disableRecursiveComponent: false };
225
+ }
226
+ return {
227
+ path: this.normalizeIndieRoot(rootConfig.path),
228
+ disableRecursiveComponent: !!rootConfig.disableRecursiveComponent,
229
+ };
230
+ }
231
+ getSubPackageIndieConfigs() {
232
+ var _a;
233
+ if (this.subPackageIndieConfigsCache)
234
+ return this.subPackageIndieConfigsCache;
235
+ const subPackageIndie = (_a = this.miniPlugin.appConfig) === null || _a === void 0 ? void 0 : _a.subPackageIndie;
236
+ if (!Array.isArray(subPackageIndie)) {
237
+ this.subPackageIndieConfigsCache = [];
238
+ return this.subPackageIndieConfigsCache;
239
+ }
240
+ this.subPackageIndieConfigsCache = subPackageIndie.map(({ mainPackageRoot, subPackageRoots = [] }) => {
241
+ const mainParsed = this.parseIndieRootConfig(mainPackageRoot);
242
+ const subParsedList = subPackageRoots.map(root => this.parseIndieRootConfig(root));
243
+ const disableRecursiveComponentRoots = new Set();
244
+ if (mainParsed.disableRecursiveComponent) {
245
+ disableRecursiveComponentRoots.add(mainParsed.path);
246
+ }
247
+ subParsedList.forEach(sub => {
248
+ if (sub.disableRecursiveComponent) {
249
+ disableRecursiveComponentRoots.add(sub.path);
250
+ }
251
+ });
252
+ return {
253
+ mainPackageRoot: mainParsed.path,
254
+ subPackageRoots: Array.from(new Set(subParsedList.map(sub => sub.path))),
255
+ disableRecursiveComponentRoots,
256
+ };
257
+ });
258
+ return this.subPackageIndieConfigsCache;
259
+ }
260
+ getAllIndieRoots() {
261
+ if (!this.allIndieRootsCache) {
262
+ this.allIndieRootsCache = Array.from(new Set(this.getSubPackageIndieConfigs().flatMap(({ mainPackageRoot, subPackageRoots }) => [mainPackageRoot, ...subPackageRoots])));
263
+ }
264
+ return this.allIndieRootsCache;
265
+ }
266
+ getAllMainPackageRoots() {
267
+ if (!this.allMainPackageRootsCache) {
268
+ this.allMainPackageRootsCache = Array.from(new Set(this.getSubPackageIndieConfigs().map(item => item.mainPackageRoot)));
269
+ }
270
+ return this.allMainPackageRootsCache;
271
+ }
272
+ hasSubPackageIndieMainPackageRoot() {
273
+ return this.getAllMainPackageRoots().length > 0;
274
+ }
275
+ isRecursiveComponentDisabledForRoot(root) {
276
+ return this.getSubPackageIndieConfigs().some(config => config.disableRecursiveComponentRoots.has(root));
277
+ }
278
+ getSubPackageIndieMatch(pageName) {
279
+ if (!this.options.newBlended)
280
+ return null;
281
+ if (this.subPackageIndieMatchCache.has(pageName)) {
282
+ return this.subPackageIndieMatchCache.get(pageName) || null;
283
+ }
284
+ const configs = this.getSubPackageIndieConfigs();
285
+ for (const config of configs) {
286
+ if (pageName.startsWith(config.mainPackageRoot + '/') || pageName === config.mainPackageRoot) {
287
+ const match = {
288
+ config,
289
+ root: config.mainPackageRoot,
290
+ isMainPackageRoot: true,
291
+ };
292
+ this.subPackageIndieMatchCache.set(pageName, match);
293
+ return match;
294
+ }
295
+ for (const root of config.subPackageRoots) {
296
+ if (pageName.startsWith(root + '/') || pageName === root) {
297
+ const match = {
298
+ config,
299
+ root,
300
+ isMainPackageRoot: false,
301
+ };
302
+ this.subPackageIndieMatchCache.set(pageName, match);
303
+ return match;
304
+ }
305
+ }
306
+ }
307
+ this.subPackageIndieMatchCache.set(pageName, null);
308
+ return null;
309
+ }
310
+ isInSubPackageIndieRoot(pageName) {
311
+ var _a;
312
+ return ((_a = this.getSubPackageIndieMatch(pageName)) === null || _a === void 0 ? void 0 : _a.root) || null;
313
+ }
314
+ getModuleSourceContent(module) {
315
+ var _a;
316
+ try {
317
+ const source = (_a = module === null || module === void 0 ? void 0 : module.originalSource) === null || _a === void 0 ? void 0 : _a.call(module);
318
+ if (!source || typeof source.source !== 'function')
319
+ return '';
320
+ return String(source.source() || '');
321
+ }
322
+ catch (_err) {
323
+ return '';
324
+ }
325
+ }
326
+ getModuleResource(module) {
327
+ var _a;
328
+ const resource = (module === null || module === void 0 ? void 0 : module.resource) || ((_a = module === null || module === void 0 ? void 0 : module.rootModule) === null || _a === void 0 ? void 0 : _a.resource);
329
+ return typeof resource === 'string' ? resource : undefined;
330
+ }
331
+ collectFlattenedModules(module, collected, visited = new Set()) {
332
+ if (!module || visited.has(module))
333
+ return;
334
+ visited.add(module);
335
+ collected.add(module);
336
+ const nestedModuleCollections = [module.rootModule, module.modules, module._modules];
337
+ nestedModuleCollections.forEach(item => {
338
+ if (!item)
339
+ return;
340
+ if (item && typeof item[Symbol.iterator] === 'function') {
341
+ for (const nested of item) {
342
+ this.collectFlattenedModules(nested, collected, visited);
343
+ }
344
+ }
345
+ else {
346
+ this.collectFlattenedModules(item, collected, visited);
347
+ }
348
+ });
349
+ }
350
+ getCompilationModuleResourceMap(compilation) {
351
+ const moduleMap = new Map();
352
+ for (const module of compilation.modules) {
353
+ const flattenedModules = new Set();
354
+ this.collectFlattenedModules(module, flattenedModules);
355
+ flattenedModules.forEach(flattenedModule => {
356
+ const resource = this.getModuleResource(flattenedModule);
357
+ if (resource) {
358
+ moduleMap.set(resource, flattenedModule);
359
+ }
360
+ });
361
+ }
362
+ return moduleMap;
363
+ }
364
+ getChunksBySubPackageIndieRoot(compilation, root) {
365
+ const chunks = new Set();
366
+ this.getSubPackageIndieEntriesByRoot(root).forEach(({ name }) => {
367
+ const entryChunk = Array.from(compilation.chunks).find(chunk => chunk.name === name);
368
+ if (!entryChunk)
369
+ return;
370
+ chunks.add(entryChunk);
371
+ entryChunk.groupsIterable.forEach(group => {
372
+ group.chunks.forEach(chunk => chunks.add(chunk));
373
+ });
374
+ });
375
+ return chunks;
376
+ }
377
+ getSubPackageIndieModules(compilation, root) {
378
+ const modules = new Set();
379
+ this.getChunksBySubPackageIndieRoot(compilation, root).forEach(chunk => {
380
+ for (const module of compilation.chunkGraph.getChunkModulesIterable(chunk)) {
381
+ this.collectFlattenedModules(module, modules);
382
+ }
383
+ });
384
+ return modules;
385
+ }
386
+ normalizeModuleRequestMapKey(resource) {
387
+ if (!resource || typeof resource !== 'string')
388
+ return null;
389
+ const resourceWithoutLoader = resource.split('!').pop();
390
+ if (!resourceWithoutLoader)
391
+ return null;
392
+ const resourcePath = resourceWithoutLoader.split('?')[0];
393
+ if (!resourcePath)
394
+ return null;
395
+ return node_path_1.default.normalize(resourcePath);
396
+ }
397
+ getModuleRequestMapKeys(resource) {
398
+ const keys = new Set();
399
+ if (resource && typeof resource === 'string') {
400
+ keys.add(resource);
401
+ }
402
+ const normalizedResource = this.normalizeModuleRequestMapKey(resource);
403
+ if (normalizedResource) {
404
+ keys.add(normalizedResource);
405
+ }
406
+ return Array.from(keys);
407
+ }
408
+ setResolvedRequestResource(issuer, request, resource) {
409
+ this.getModuleRequestMapKeys(issuer).forEach(key => {
410
+ if (!this.moduleRequestMap.has(key)) {
411
+ this.moduleRequestMap.set(key, new Map());
412
+ }
413
+ this.moduleRequestMap.get(key).set(request, resource);
414
+ });
415
+ }
416
+ getResolvedRequestResource(issuerResource, request) {
417
+ var _a;
418
+ for (const key of this.getModuleRequestMapKeys(issuerResource)) {
419
+ const resolvedResource = (_a = this.moduleRequestMap.get(key)) === null || _a === void 0 ? void 0 : _a.get(request);
420
+ if (resolvedResource)
421
+ return resolvedResource;
422
+ }
423
+ }
424
+ getResolvedModuleByResource(moduleResourceMap, resource) {
425
+ const exactModule = moduleResourceMap.get(resource);
426
+ if (exactModule)
427
+ return exactModule;
428
+ const normalizedResource = this.normalizeModuleRequestMapKey(resource);
429
+ if (!normalizedResource)
430
+ return null;
431
+ const normalizedModule = moduleResourceMap.get(normalizedResource);
432
+ if (normalizedModule)
433
+ return normalizedModule;
434
+ for (const [moduleResource, module] of moduleResourceMap.entries()) {
435
+ if (this.normalizeModuleRequestMapKey(moduleResource) === normalizedResource) {
436
+ return module;
437
+ }
438
+ }
439
+ return null;
440
+ }
441
+ resolveRequestedModule(moduleResourceMap, issuerModule, request) {
442
+ const issuerResource = this.getModuleResource(issuerModule);
443
+ const resolvedResource = this.getResolvedRequestResource(issuerResource, request);
444
+ if (resolvedResource) {
445
+ const resolvedModule = this.getResolvedModuleByResource(moduleResourceMap, resolvedResource);
446
+ if (resolvedModule)
447
+ return resolvedModule;
448
+ }
449
+ if (issuerResource && /^[.\\/]/.test(request)) {
450
+ const requestPath = node_path_1.default.resolve(node_path_1.default.dirname(issuerResource), request);
451
+ const resolvedPath = (0, helper_1.resolveMainFilePath)(requestPath);
452
+ const requestModule = this.getResolvedModuleByResource(moduleResourceMap, resolvedPath);
453
+ if (requestModule)
454
+ return requestModule;
455
+ }
456
+ for (const module of moduleResourceMap.values()) {
457
+ if (!module)
458
+ continue;
459
+ if (module.rawRequest === request || module.userRequest === request || module.request === request) {
460
+ return module;
461
+ }
462
+ }
463
+ return null;
464
+ }
465
+ resolveImportBindingToTaroComponentName(moduleResourceMap, issuerModule, binding, propertyName, visited = new Set()) {
466
+ if (!(binding === null || binding === void 0 ? void 0 : binding.source))
467
+ return null;
468
+ if (binding.kind === 'namespace') {
469
+ if (!propertyName)
470
+ return null;
471
+ if (binding.source === helper_1.taroJsComponents) {
472
+ return propertyName;
473
+ }
474
+ const targetModule = this.resolveRequestedModule(moduleResourceMap, issuerModule, binding.source);
475
+ if (!targetModule) {
476
+ if (!/^[.\\/]/.test(binding.source)) {
477
+ return propertyName;
478
+ }
479
+ return null;
480
+ }
481
+ return this.resolveModuleExportToTaroComponentName(moduleResourceMap, targetModule, propertyName, visited);
482
+ }
483
+ const importedName = binding.imported || propertyName;
484
+ if (!importedName || importedName === 'default')
485
+ return null;
486
+ if (binding.source === helper_1.taroJsComponents) {
487
+ return importedName;
488
+ }
489
+ const targetModule = this.resolveRequestedModule(moduleResourceMap, issuerModule, binding.source);
490
+ if (!targetModule) {
491
+ if (!/^[.\\/]/.test(binding.source)) {
492
+ return importedName;
493
+ }
494
+ return null;
495
+ }
496
+ return this.resolveModuleExportToTaroComponentName(moduleResourceMap, targetModule, importedName, visited);
497
+ }
498
+ resolveModuleExportToTaroComponentName(moduleResourceMap, module, exportName, visited = new Set()) {
499
+ var _a, _b;
500
+ const moduleResource = this.getModuleResource(module);
501
+ if (!moduleResource)
502
+ return null;
503
+ const visitKey = `${moduleResource}::${exportName}`;
504
+ if (visited.has(visitKey))
505
+ return null;
506
+ visited.add(visitKey);
507
+ const exportBinding = (_a = module === null || module === void 0 ? void 0 : module.exportBindings) === null || _a === void 0 ? void 0 : _a[exportName];
508
+ if (exportBinding) {
509
+ if (exportBinding.kind === 'reexport' && exportBinding.source) {
510
+ if (exportBinding.source === helper_1.taroJsComponents) {
511
+ return exportBinding.imported || exportName;
512
+ }
513
+ const targetModule = this.resolveRequestedModule(moduleResourceMap, module, exportBinding.source);
514
+ if (targetModule) {
515
+ const resolvedName = this.resolveModuleExportToTaroComponentName(moduleResourceMap, targetModule, exportBinding.imported || exportName, visited);
516
+ if (resolvedName)
517
+ return resolvedName;
518
+ }
519
+ }
520
+ if (exportBinding.kind === 'local' && exportBinding.local) {
521
+ const importedBinding = (_b = module === null || module === void 0 ? void 0 : module.importedBindings) === null || _b === void 0 ? void 0 : _b[exportBinding.local];
522
+ if (importedBinding) {
523
+ const resolvedName = this.resolveImportBindingToTaroComponentName(moduleResourceMap, module, importedBinding, undefined, visited);
524
+ if (resolvedName)
525
+ return resolvedName;
526
+ }
527
+ }
528
+ }
529
+ for (const source of (module === null || module === void 0 ? void 0 : module.exportAllSources) || []) {
530
+ if (source === helper_1.taroJsComponents) {
531
+ return exportName;
532
+ }
533
+ const targetModule = this.resolveRequestedModule(moduleResourceMap, module, source);
534
+ if (!targetModule)
535
+ continue;
536
+ const resolvedName = this.resolveModuleExportToTaroComponentName(moduleResourceMap, targetModule, exportName, visited);
537
+ if (resolvedName)
538
+ return resolvedName;
539
+ }
540
+ return null;
541
+ }
542
+ resolveUsedComponentRefToTaroComponentName(moduleResourceMap, module, componentRef) {
543
+ var _a, _b;
544
+ if (!componentRef)
545
+ return null;
546
+ if (componentRef.kind === 'identifier') {
547
+ const binding = (_a = module === null || module === void 0 ? void 0 : module.importedBindings) === null || _a === void 0 ? void 0 : _a[componentRef.name];
548
+ if (!binding) {
549
+ return componentRef.name;
550
+ }
551
+ const resolvedName = this.resolveImportBindingToTaroComponentName(moduleResourceMap, module, binding);
552
+ return resolvedName || componentRef.name;
553
+ }
554
+ if (componentRef.kind === 'member') {
555
+ const binding = (_b = module === null || module === void 0 ? void 0 : module.importedBindings) === null || _b === void 0 ? void 0 : _b[componentRef.object];
556
+ if (!binding) {
557
+ return componentRef.property || null;
558
+ }
559
+ const resolvedName = this.resolveImportBindingToTaroComponentName(moduleResourceMap, module, binding, componentRef.property);
560
+ return resolvedName || componentRef.property || null;
561
+ }
562
+ return null;
563
+ }
564
+ shouldSkipSubPackageIndieModule(module, root) {
565
+ const resource = this.getModuleResource(module);
566
+ if (typeof resource !== 'string' || !resource.startsWith(this.options.sourceDir)) {
567
+ return false;
568
+ }
569
+ const componentName = this.miniPlugin.getComponentName(resource);
570
+ const targetRoot = this.isInSubPackageIndieRoot(componentName);
571
+ return !!targetRoot && targetRoot !== root;
572
+ }
573
+ collectModuleResolvedComponentIncludes(compilation, root) {
574
+ const includes = new Set();
575
+ const moduleResourceMap = this.getCompilationModuleResourceMap(compilation);
576
+ for (const module of this.getSubPackageIndieModules(compilation, root)) {
577
+ if (this.shouldSkipSubPackageIndieModule(module, root))
578
+ continue;
579
+ for (const elementName of (module === null || module === void 0 ? void 0 : module.elementNameSet) || []) {
580
+ if (!component_1.componentConfig.thirdPartyComponents.has(elementName)) {
581
+ includes.add(elementName);
582
+ }
583
+ }
584
+ for (const binding of Object.values((module === null || module === void 0 ? void 0 : module.importedBindings) || {})) {
585
+ const resolvedComponentName = this.resolveImportBindingToTaroComponentName(moduleResourceMap, module, binding);
586
+ if (!resolvedComponentName)
587
+ continue;
588
+ const dashedName = this.toDashedComponentName(resolvedComponentName);
589
+ if (!component_1.componentConfig.thirdPartyComponents.has(dashedName)) {
590
+ includes.add(dashedName);
591
+ }
592
+ }
593
+ for (const componentRef of (module === null || module === void 0 ? void 0 : module.usedComponentRefs) || []) {
594
+ const resolvedComponentName = this.resolveUsedComponentRefToTaroComponentName(moduleResourceMap, module, componentRef);
595
+ if (!resolvedComponentName)
596
+ continue;
597
+ const dashedName = this.toDashedComponentName(resolvedComponentName);
598
+ if (!component_1.componentConfig.thirdPartyComponents.has(dashedName)) {
599
+ includes.add(dashedName);
600
+ }
601
+ }
602
+ }
603
+ return includes;
604
+ }
605
+ expandScopedIncludes(includes) {
606
+ const scopedIncludes = new Set(includes);
607
+ if (scopedIncludes.has('view')) {
608
+ scopedIncludes.add('catch-view');
609
+ scopedIncludes.add('static-view');
610
+ scopedIncludes.add('pure-view');
611
+ scopedIncludes.add('click-view');
612
+ }
613
+ if (scopedIncludes.has('image')) {
614
+ scopedIncludes.add('static-image');
615
+ }
616
+ if (scopedIncludes.has('text')) {
617
+ scopedIncludes.add('static-text');
618
+ }
619
+ return scopedIncludes;
620
+ }
621
+ toDashedComponentName(componentName) {
622
+ return componentName.replace(/[A-Z]/g, (match, offset) => `${offset === 0 ? '' : '-'}${match.toLowerCase()}`);
623
+ }
624
+ collectScopedInnerComponents(compilation, root) {
625
+ const includes = new Set();
626
+ const scopedIncludes = component_1.componentConfig.scopedIncludes.get(root);
627
+ if (scopedIncludes && scopedIncludes.size > 0) {
628
+ scopedIncludes.forEach(name => includes.add(name));
629
+ }
630
+ this.collectModuleResolvedComponentIncludes(compilation, root).forEach(name => includes.add(name));
631
+ const finalIncludes = includes.size > 0
632
+ ? includes
633
+ : new Set(component_1.componentConfig.includes);
634
+ return this.expandScopedIncludes(finalIncludes);
635
+ }
636
+ isSubPackageIndieRootUsingCustomWrapperByModules(compilation, root) {
637
+ const moduleResourceMap = this.getCompilationModuleResourceMap(compilation);
638
+ for (const module of this.getSubPackageIndieModules(compilation, root)) {
639
+ if (this.shouldSkipSubPackageIndieModule(module, root))
640
+ continue;
641
+ for (const componentRef of (module === null || module === void 0 ? void 0 : module.usedComponentRefs) || []) {
642
+ const resolvedComponentName = this.resolveUsedComponentRefToTaroComponentName(moduleResourceMap, module, componentRef);
643
+ if (resolvedComponentName === 'CustomWrapper') {
644
+ return true;
645
+ }
646
+ }
647
+ }
648
+ return false;
649
+ }
650
+ isSubPackageIndieRootUsingCustomWrapper(compilation, root, scopedThirdPartyComponents) {
651
+ if (scopedThirdPartyComponents === null || scopedThirdPartyComponents === void 0 ? void 0 : scopedThirdPartyComponents.has(MiniPlugin_1.customWrapperName)) {
652
+ return true;
653
+ }
654
+ let cache = this.rootUsingCustomWrapperByCompilation.get(compilation);
655
+ if (!cache) {
656
+ cache = new Map();
657
+ this.rootUsingCustomWrapperByCompilation.set(compilation, cache);
658
+ }
659
+ if (cache.has(root)) {
660
+ return cache.get(root) || false;
661
+ }
662
+ const usingCustomWrapper = this.isSubPackageIndieRootUsingCustomWrapperByModules(compilation, root);
663
+ cache.set(root, usingCustomWrapper);
664
+ return usingCustomWrapper;
665
+ }
666
+ resolveUsingComponentTarget(filePath, componentPath) {
667
+ if (componentPath.startsWith('plugin://'))
668
+ return null;
669
+ let sourcePath = componentPath;
670
+ if (node_path_1.default.isAbsolute(componentPath)) {
671
+ sourcePath = helper_1.fs.existsSync(componentPath)
672
+ ? componentPath
673
+ : node_path_1.default.resolve(this.options.sourceDir, `.${componentPath}`);
674
+ }
675
+ else {
676
+ const isRelativePath = /^[.\\/]/;
677
+ if (!isRelativePath.test(componentPath))
678
+ return null;
679
+ sourcePath = node_path_1.default.resolve(node_path_1.default.dirname(filePath), componentPath);
680
+ }
681
+ const targetPath = (0, helper_1.resolveMainFilePath)(sourcePath);
682
+ const targetName = this.miniPlugin.getComponentName(targetPath);
683
+ return {
684
+ path: targetPath,
685
+ name: targetName,
686
+ root: this.isInSubPackageIndieRoot(targetName),
687
+ };
688
+ }
689
+ cloneThirdPartyComponent(thirdPartyComponents, componentName) {
690
+ const attrs = component_1.componentConfig.thirdPartyComponents.get(componentName);
691
+ if (!attrs || thirdPartyComponents.has(componentName))
692
+ return;
693
+ thirdPartyComponents.set(componentName, new Set(attrs));
694
+ }
695
+ getSubPackageIndieEntriesByRoot(root) {
696
+ if (!this.entriesByRootCache) {
697
+ const entriesByRoot = new Map();
698
+ [...this.miniPlugin.pages, ...this.miniPlugin.components].forEach(item => {
699
+ const indieRoot = this.isInSubPackageIndieRoot(item.name);
700
+ if (!indieRoot)
701
+ return;
702
+ if (!entriesByRoot.has(indieRoot)) {
703
+ entriesByRoot.set(indieRoot, new Map());
704
+ }
705
+ entriesByRoot.get(indieRoot).set(item.name, item);
706
+ });
707
+ this.entriesByRootCache = new Map();
708
+ entriesByRoot.forEach((entries, indieRoot) => {
709
+ this.entriesByRootCache.set(indieRoot, Array.from(entries.values()));
710
+ });
711
+ }
712
+ return this.entriesByRootCache.get(root) || [];
713
+ }
714
+ isForceCustomWrapperEnabledForRoot(root) {
715
+ var _a;
716
+ if (this.options.template.isSupportRecursive)
717
+ return false;
718
+ if (this.forceCustomWrapperByRootCache.has(root)) {
719
+ return this.forceCustomWrapperByRootCache.get(root) || false;
720
+ }
721
+ const entries = this.getSubPackageIndieEntriesByRoot(root);
722
+ for (const entry of entries) {
723
+ if (entry === null || entry === void 0 ? void 0 : entry.isNative)
724
+ continue;
725
+ const content = (_a = this.miniPlugin.filesConfig[this.miniPlugin.getConfigFilePath(entry.name)]) === null || _a === void 0 ? void 0 : _a.content;
726
+ if (content === null || content === void 0 ? void 0 : content.forceCustomWrapper) {
727
+ this.forceCustomWrapperByRootCache.set(root, true);
728
+ return true;
729
+ }
730
+ }
731
+ this.forceCustomWrapperByRootCache.set(root, false);
732
+ return false;
733
+ }
734
+ getComponentByName(componentName) {
735
+ if (!this.componentByNameCache) {
736
+ this.componentByNameCache = new Map();
737
+ [...this.miniPlugin.pages, ...this.miniPlugin.components].forEach(item => {
738
+ this.componentByNameCache.set(item.name, item);
739
+ });
740
+ }
741
+ return this.componentByNameCache.get(componentName);
742
+ }
743
+ getScopedSubPackageIndieComponentConfig(compilation, root) {
744
+ var _a;
745
+ let cache = this.scopedComponentConfigByCompilation.get(compilation);
746
+ if (!cache) {
747
+ cache = new Map();
748
+ this.scopedComponentConfigByCompilation.set(compilation, cache);
749
+ }
750
+ if (cache.has(root)) {
751
+ return cache.get(root);
752
+ }
753
+ const thirdPartyComponents = new Map();
754
+ const queue = [...this.getSubPackageIndieEntriesByRoot(root)];
755
+ const visited = new Set();
756
+ while (queue.length) {
757
+ const current = queue.shift();
758
+ if (!current || visited.has(current.name))
759
+ continue;
760
+ visited.add(current.name);
761
+ const fileConfig = (_a = this.miniPlugin.filesConfig[this.miniPlugin.getConfigFilePath(current.name)]) === null || _a === void 0 ? void 0 : _a.content;
762
+ const usingComponents = fileConfig === null || fileConfig === void 0 ? void 0 : fileConfig.usingComponents;
763
+ if (!usingComponents)
764
+ continue;
765
+ for (const [componentName, componentValue] of Object.entries(usingComponents)) {
766
+ if (componentName === MiniPlugin_1.customWrapperName) {
767
+ this.cloneThirdPartyComponent(thirdPartyComponents, componentName);
768
+ continue;
769
+ }
770
+ if (!component_1.componentConfig.thirdPartyComponents.has(componentName))
771
+ continue;
772
+ const componentPath = componentValue instanceof Array ? componentValue[0] : componentValue;
773
+ const target = this.resolveUsingComponentTarget(current.path, componentPath);
774
+ this.cloneThirdPartyComponent(thirdPartyComponents, componentName);
775
+ if (!target)
776
+ continue;
777
+ const targetComponent = this.getComponentByName(target.name);
778
+ if (targetComponent && (!target.root || target.root === root) && !visited.has(targetComponent.name)) {
779
+ queue.push(targetComponent);
780
+ }
781
+ }
782
+ }
783
+ const scopedComponentConfig = {
784
+ includes: this.collectScopedInnerComponents(compilation, root),
785
+ exclude: new Set(component_1.componentConfig.exclude),
786
+ thirdPartyComponents,
787
+ includeAll: false,
788
+ skipRecursiveComponent: false,
789
+ };
790
+ cache.set(root, scopedComponentConfig);
791
+ return scopedComponentConfig;
792
+ }
793
+ generateSubPackageIndieScriptFile(compilation, compiler, filePath, content) {
794
+ const { RawSource } = compiler.webpack.sources;
795
+ compilation.assets[this.miniPlugin.getTargetFilePath(filePath, '.js')] = new RawSource(content);
796
+ }
797
+ createRecursiveComponentWrapperSource(componentName, forceCustomWrapper = false) {
798
+ const args = [];
799
+ if (componentName) {
800
+ args.push(JSON.stringify(componentName));
801
+ }
802
+ else if (forceCustomWrapper) {
803
+ args.push('undefined');
804
+ }
805
+ if (forceCustomWrapper) {
806
+ args.push('true');
807
+ }
808
+ return `const registerRecursiveComponent = globalThis.__taroRegisterRecursiveComponent
809
+
810
+ if (typeof registerRecursiveComponent !== 'function') {
811
+ throw new Error('globalThis.__taroRegisterRecursiveComponent is not a function')
812
+ }
813
+
814
+ registerRecursiveComponent(${args.join(', ')})
815
+ `;
816
+ }
817
+ generateSubPackageIndieFiles(compilation, compiler, template, baseTemplateName) {
818
+ const customWrapperRoots = new Set();
819
+ if (!this.getSubPackageIndieConfigs().length)
820
+ return customWrapperRoots;
821
+ const allIndieRoots = this.getAllIndieRoots();
822
+ allIndieRoots.forEach(root => {
823
+ const scopedComponentConfig = this.getScopedSubPackageIndieComponentConfig(compilation, root);
824
+ const isRecursiveDisabled = this.isRecursiveComponentDisabledForRoot(root);
825
+ if (isRecursiveDisabled) {
826
+ scopedComponentConfig.skipRecursiveComponent = true;
827
+ }
828
+ const forceCustomWrapperForRoot = isRecursiveDisabled
829
+ ? false
830
+ : this.isForceCustomWrapperEnabledForRoot(root);
831
+ const isRootUsingCustomWrapper = isRecursiveDisabled
832
+ ? false
833
+ : this.isSubPackageIndieRootUsingCustomWrapper(compilation, root, scopedComponentConfig.thirdPartyComponents);
834
+ if (isRootUsingCustomWrapper) {
835
+ customWrapperRoots.add(root);
836
+ if (!scopedComponentConfig.thirdPartyComponents.has(MiniPlugin_1.customWrapperName)) {
837
+ const attrs = component_1.componentConfig.thirdPartyComponents.get(MiniPlugin_1.customWrapperName);
838
+ scopedComponentConfig.thirdPartyComponents.set(MiniPlugin_1.customWrapperName, new Set(attrs || []));
839
+ }
840
+ }
841
+ this.miniPlugin.generateTemplateFile(compilation, compiler, `${root}/${baseTemplateName}`, template.buildTemplate, scopedComponentConfig);
842
+ this.miniPlugin.generateXSFile(compilation, compiler, `${root}/utils`);
843
+ if (!template.isSupportRecursive && !isRecursiveDisabled) {
844
+ this.generateSubPackageIndieScriptFile(compilation, compiler, `${root}/${MiniPlugin_1.baseCompName}`, this.createRecursiveComponentWrapperSource(undefined, forceCustomWrapperForRoot));
845
+ this.miniPlugin.generateTemplateFile(compilation, compiler, `${root}/${MiniPlugin_1.baseCompName}`, template.buildBaseComponentTemplate, this.options.fileType.templ);
846
+ const compConfig = {
847
+ component: true,
848
+ styleIsolation: MiniPlugin_1.STYLE_ISOLATION_APPLY_SHARED,
849
+ usingComponents: {
850
+ [MiniPlugin_1.baseCompName]: `./${MiniPlugin_1.baseCompName}`,
851
+ },
852
+ };
853
+ if (isRootUsingCustomWrapper) {
854
+ compConfig.usingComponents[MiniPlugin_1.customWrapperName] = `./${MiniPlugin_1.customWrapperName}`;
855
+ }
856
+ this.miniPlugin.generateConfigFile(compilation, compiler, `${root}/${MiniPlugin_1.baseCompName}`, compConfig);
857
+ }
858
+ if (isRootUsingCustomWrapper) {
859
+ this.generateSubPackageIndieScriptFile(compilation, compiler, `${root}/${MiniPlugin_1.customWrapperName}`, this.createRecursiveComponentWrapperSource(MiniPlugin_1.customWrapperName, forceCustomWrapperForRoot));
860
+ this.miniPlugin.generateTemplateFile(compilation, compiler, `${root}/${MiniPlugin_1.customWrapperName}`, template.buildCustomComponentTemplate, this.options.fileType.templ);
861
+ this.miniPlugin.generateConfigFile(compilation, compiler, `${root}/${MiniPlugin_1.customWrapperName}`, {
862
+ component: true,
863
+ styleIsolation: MiniPlugin_1.STYLE_ISOLATION_APPLY_SHARED,
864
+ usingComponents: {
865
+ [MiniPlugin_1.baseCompName]: `./${MiniPlugin_1.baseCompName}`,
866
+ [MiniPlugin_1.customWrapperName]: `./${MiniPlugin_1.customWrapperName}`,
867
+ },
868
+ });
869
+ }
870
+ });
871
+ return customWrapperRoots;
872
+ }
873
+ generateMainPackageRuntimeFiles(compilation, compiler) {
874
+ var _a, _b;
875
+ const { commonChunks, fileType } = this.options;
876
+ const mainPackageRoots = this.getAllMainPackageRoots();
877
+ if (!mainPackageRoots.length)
878
+ return;
879
+ const styleExt = fileType.style;
880
+ const runtimeChunks = ['app', ...commonChunks];
881
+ const appJsContent = compilation.assets['app.js'];
882
+ let patchedAppJsContent = appJsContent;
883
+ if (appJsContent) {
884
+ const { RawSource } = compiler.webpack.sources;
885
+ const originalSource = String(((_b = (_a = appJsContent).source) === null || _b === void 0 ? void 0 : _b.call(_a)) || String(appJsContent));
886
+ const registrarExpr = `(typeof globalThis.__taroRegisterRecursiveComponent==="function"||(globalThis.__taroRegisterRecursiveComponent=function(componentName,forceCustomWrapper){const cache=__webpack_require__.c||{};let createRecursiveComponentConfig;for(const key in cache){const exports=cache[key]&&cache[key].exports;if(exports&&typeof exports.createRecursiveComponentConfig==="function"){createRecursiveComponentConfig=exports.createRecursiveComponentConfig;break;}}if(typeof createRecursiveComponentConfig!=="function"){const modules=__webpack_require__.m||{};for(const moduleId in modules){const moduleFactory=modules[moduleId];if(!moduleFactory||typeof moduleFactory!=="function")continue;const source=String(moduleFactory);if(source.indexOf("createRecursiveComponentConfig")===-1)continue;const exports=__webpack_require__(moduleId);if(exports&&typeof exports.createRecursiveComponentConfig==="function"){createRecursiveComponentConfig=exports.createRecursiveComponentConfig;break;}}}if(typeof createRecursiveComponentConfig!=="function"){throw new Error("Cannot find createRecursiveComponentConfig in webpack modules");}Component(createRecursiveComponentConfig(componentName,forceCustomWrapper));}))`;
887
+ let patchedSource = originalSource;
888
+ if (/,\s*exports\.taroApp\s*=/.test(patchedSource)) {
889
+ patchedSource = patchedSource.replace(/,\s*exports\.taroApp\s*=/, `,${registrarExpr},exports.taroApp=`);
890
+ }
891
+ else {
892
+ patchedSource = patchedSource.replace(/exports\.taroApp\s*=/, `;${registrarExpr};exports.taroApp=`);
893
+ }
894
+ patchedAppJsContent = new RawSource(patchedSource);
895
+ }
896
+ mainPackageRoots.forEach(mainPackageRoot => {
897
+ runtimeChunks.forEach(chunkName => {
898
+ const jsFile = `${chunkName}.js`;
899
+ if (compilation.assets[jsFile]) {
900
+ const jsContent = chunkName === 'app'
901
+ ? patchedAppJsContent
902
+ : compilation.assets[jsFile];
903
+ compilation.assets[`${mainPackageRoot}/${jsFile}`] = jsContent;
904
+ }
905
+ const cssFile = `${chunkName}${styleExt}`;
906
+ if (compilation.assets[cssFile]) {
907
+ compilation.assets[`${mainPackageRoot}/${cssFile}`] = compilation.assets[cssFile];
908
+ }
909
+ });
910
+ const appOriginCss = `app-origin${styleExt}`;
911
+ if (compilation.assets[appOriginCss]) {
912
+ compilation.assets[`${mainPackageRoot}/${appOriginCss}`] = compilation.assets[appOriginCss];
913
+ }
914
+ });
915
+ }
916
+ }
917
+ exports.default = SubPackageIndiePlugin;
918
+ //# sourceMappingURL=SubPackageIndiePlugin.js.map