|
1 | 1 | import * as d from '../../declarations'; |
2 | 2 |
|
3 | 3 |
|
4 | | -export function getBuildFeatures(cmps: d.ComponentCompilerMeta[]) { |
| 4 | +export function getBuildFeatures(moduleMap: d.ModuleMap, cmps: d.ComponentCompilerMeta[]) { |
| 5 | + cmps.forEach(cmp => { |
| 6 | + const importedModules = getModuleImports(moduleMap, cmp.sourceFilePath, []); |
| 7 | + importedModules.forEach(importedModule => { |
| 8 | + // if the component already has a boolean true value it'll keep it |
| 9 | + // otherwise we get the boolean value from the imported module |
| 10 | + cmp.hasVdomAttribute = cmp.hasVdomAttribute || importedModule.hasVdomAttribute; |
| 11 | + cmp.hasVdomClass = cmp.hasVdomClass || importedModule.hasVdomClass; |
| 12 | + cmp.hasVdomFunctional = cmp.hasVdomFunctional || importedModule.hasVdomFunctional; |
| 13 | + cmp.hasVdomKey = cmp.hasVdomKey || importedModule.hasVdomKey; |
| 14 | + cmp.hasVdomListener = cmp.hasVdomListener || importedModule.hasVdomListener; |
| 15 | + cmp.hasVdomRef = cmp.hasVdomRef || importedModule.hasVdomRef; |
| 16 | + cmp.hasVdomRender = cmp.hasVdomRender || importedModule.hasVdomRender; |
| 17 | + cmp.hasVdomStyle = cmp.hasVdomStyle || importedModule.hasVdomStyle; |
| 18 | + cmp.hasVdomText = cmp.hasVdomText || importedModule.hasVdomText; |
| 19 | + cmp.htmlAttrNames.push(...importedModule.htmlAttrNames); |
| 20 | + cmp.htmlTagNames.push(...importedModule.htmlTagNames); |
| 21 | + cmp.potentialCmpRefs.push(...importedModule.potentialCmpRefs); |
| 22 | + }); |
| 23 | + }); |
| 24 | + |
5 | 25 | const slot = cmps.some(c => c.htmlTagNames.includes('slot')); |
6 | 26 | const f: d.BuildFeatures = { |
7 | 27 | allRenderFn: cmps.every(c => c.hasRenderFn), |
@@ -58,6 +78,29 @@ export function getBuildFeatures(cmps: d.ComponentCompilerMeta[]) { |
58 | 78 | } |
59 | 79 |
|
60 | 80 |
|
| 81 | +function getModuleImports(moduleMap: d.ModuleMap, filePath: string, importedModules: d.Module[]) { |
| 82 | + let moduleFile = moduleMap.get(filePath); |
| 83 | + if (moduleFile == null) { |
| 84 | + moduleFile = moduleMap.get(filePath + '.tsx'); |
| 85 | + if (moduleFile == null) { |
| 86 | + moduleFile = moduleMap.get(filePath + '.ts'); |
| 87 | + if (moduleFile == null) { |
| 88 | + moduleFile = moduleMap.get(filePath + '.js'); |
| 89 | + } |
| 90 | + } |
| 91 | + } |
| 92 | + |
| 93 | + if (moduleFile && !importedModules.some(m => m.sourceFilePath === moduleFile.sourceFilePath)) { |
| 94 | + importedModules.push(moduleFile); |
| 95 | + |
| 96 | + moduleFile.localImports.forEach(localImport => { |
| 97 | + getModuleImports(moduleMap, localImport, importedModules); |
| 98 | + }); |
| 99 | + } |
| 100 | + return importedModules; |
| 101 | +} |
| 102 | + |
| 103 | + |
61 | 104 | export function updateBuildConditionals(config: d.Config, b: d.Build) { |
62 | 105 | b.isDebug = (config.logLevel === 'debug'); |
63 | 106 | b.isDev = !!config.devMode; |
|
0 commit comments