1 | export const mergeTwoImportMap = (leftImportMap, rightImportMap) => {
|
2 | return {
|
3 | imports: mergeImports(leftImportMap.imports, rightImportMap.imports),
|
4 | scopes: mergeScopes(leftImportMap.scopes, rightImportMap.scopes),
|
5 | }
|
6 | }
|
7 |
|
8 | const mergeImports = (leftImports = {}, rightImports = {}) => {
|
9 | return { ...leftImports, ...rightImports }
|
10 | }
|
11 |
|
12 | const mergeScopes = (leftScopes = {}, rightScopes = {}) => {
|
13 | const scopes = { ...leftScopes }
|
14 | Object.keys(rightScopes).forEach((pathPattern) => {
|
15 | if (scopes.hasOwnProperty(pathPattern)) {
|
16 | scopes[pathPattern] = { ...scopes[pathPattern], ...rightScopes[pathPattern] }
|
17 | } else {
|
18 | scopes[pathPattern] = { ...rightScopes[pathPattern] }
|
19 | }
|
20 | })
|
21 | return scopes
|
22 | }
|