UNPKG

1.79 kBJavaScriptView Raw
1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3const types_1 = require("@babel/types");
4const types_2 = require("./types");
5const paths_1 = require("./paths");
6const compact_1 = require("./compact");
7const stringImportSpecifier = (fragmentName) => importSpecifierWithIdentifier(types_2.stringIdentifier(fragmentName));
8const importSpecifierWithIdentifier = (identifier) => types_1.importSpecifier(identifier, identifier);
9const 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))));
14const importDeclarationForGlobalDependencies = (dependencies, relativeGlobalSourcePath) => types_1.importDeclaration(dependencies.map(dependency => importSpecifierWithIdentifier(types_1.identifier(dependency))), types_1.stringLiteral(relativeGlobalSourcePath));
15exports.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//# sourceMappingURL=dependencyImports.js.map
\No newline at end of file