1 | "use strict";
|
2 | Object.defineProperty(exports, "__esModule", { value: true });
|
3 | const types_1 = require("@babel/types");
|
4 | const types_2 = require("./types");
|
5 | const paths_1 = require("./paths");
|
6 | const compact_1 = require("./compact");
|
7 | const stringImportSpecifier = (fragmentName) => importSpecifierWithIdentifier(types_2.stringIdentifier(fragmentName));
|
8 | const importSpecifierWithIdentifier = (identifier) => types_1.importSpecifier(identifier, identifier);
|
9 | const importDeclarationForFragmentDependency = (fragmentDependency, context, filePath) => types_1.importDeclaration(compact_1.default(fragmentDependency.importType &&
|
10 | importSpecifierWithIdentifier(types_1.identifier(fragmentDependency.name)), fragmentDependency.importString &&
|
11 | stringImportSpecifier(fragmentDependency.name), fragmentDependency.importType &&
|
12 | !fragmentDependency.importString &&
|
13 | importSpecifierWithIdentifier(types_1.identifier(`is${fragmentDependency.name}`))), types_1.stringLiteral(paths_1.relativePath(filePath, paths_1.outputPath(fragmentDependency.name, context.fragments[fragmentDependency.name].filePath))));
|
14 | const importDeclarationForGlobalDependencies = (dependencies, relativeGlobalSourcePath) => types_1.importDeclaration(dependencies.map(dependency => importSpecifierWithIdentifier(types_1.identifier(dependency))), types_1.stringLiteral(relativeGlobalSourcePath));
|
15 | exports.default = (dependencies, outputPath, globalSourcePath, context) => compact_1.default(dependencies.global.length > 0 &&
|
16 | importDeclarationForGlobalDependencies(dependencies.global, paths_1.relativePath(outputPath, globalSourcePath)), ...dependencies.fragments.map(fragmentDependency => importDeclarationForFragmentDependency(fragmentDependency, context, outputPath)));
|
17 |
|
\ | No newline at end of file |