dts-bundle-generator
Advanced tools
Comparing version 1.2.2 to 1.3.0
@@ -51,3 +51,3 @@ #!/usr/bin/env node | ||
'Used types will be imported by "import { First, Second } from \'library-name\';".\n' + | ||
'By default all libraries will be imported (except inlined)', | ||
'By default all libraries will be imported (except inlined and libraries from @types)', | ||
coerce: toStringsArray, | ||
@@ -54,0 +54,0 @@ }) |
@@ -72,3 +72,4 @@ "use strict"; | ||
var prevStatementsCount = collectionResult.statements.length; | ||
updateResult(__assign({}, updateResultCommonParams, { currentModule: module_info_1.getModuleInfo(sourceFile.fileName, criteria), statements: sourceFile.statements }), collectionResult); | ||
var updateFn = sourceFile === rootSourceFile ? updateResultForRootSourceFile : updateResult; | ||
updateFn(__assign({}, updateResultCommonParams, { currentModule: module_info_1.getModuleInfo(sourceFile.fileName, criteria), statements: sourceFile.statements }), collectionResult); | ||
if (collectionResult.statements.length === prevStatementsCount) { | ||
@@ -84,9 +85,2 @@ logger_1.verboseLog("No output for file: " + sourceFile.fileName); | ||
} | ||
for (var _a = 0, _b = rootSourceFile.statements; _a < _b.length; _a++) { | ||
var statement = _b[_a]; | ||
// add skipped by `updateResult` `export default` from root file if present | ||
if (ts.isExportAssignment(statement) && !statement.isExportEquals) { | ||
collectionResult.statements.push(statement); | ||
} | ||
} | ||
return generate_output_1.generateOutput(__assign({}, collectionResult, { needStripDefaultKeywordForStatement: function (statement) { return statement.getSourceFile() !== rootSourceFile; }, shouldStatementHasExportKeyword: function (statement) { | ||
@@ -102,3 +96,3 @@ var result = true; | ||
} | ||
else if (typescript_helpers_1.isDeclareGlobalStatement(statement)) { | ||
else if (typescript_helpers_1.isDeclareGlobalStatement(statement) || ts.isExportDeclaration(statement)) { | ||
result = false; | ||
@@ -158,2 +152,21 @@ } | ||
} | ||
function updateResultForRootSourceFile(params, result) { | ||
function isReExportFromImportableModule(statement) { | ||
if (!ts.isExportDeclaration(statement) || statement.moduleSpecifier === undefined || !ts.isStringLiteral(statement.moduleSpecifier)) { | ||
return false; | ||
} | ||
var moduleFileName = resolveModuleFileName(statement.getSourceFile().fileName, statement.moduleSpecifier.text); | ||
return params.getModuleInfo(moduleFileName).type === 2 /* ShouldBeImported */; | ||
} | ||
updateResult(params, result); | ||
// add skipped by `updateResult` exports | ||
for (var _i = 0, _a = params.statements; _i < _a.length; _i++) { | ||
var statement = _a[_i]; | ||
var isExportDefault = ts.isExportAssignment(statement) && !statement.isExportEquals; | ||
var isReExportFromImportable = isReExportFromImportableModule(statement); | ||
if (isExportDefault || isReExportFromImportable) { | ||
result.statements.push(statement); | ||
} | ||
} | ||
} | ||
function updateResultForImportedEqExportAssignment(exportAssignment, params, result) { | ||
@@ -160,0 +173,0 @@ var moduleDeclarations = params.getDeclarationsForExportedAssignment(exportAssignment) |
@@ -38,3 +38,3 @@ "use strict"; | ||
if (shouldLibraryBeImported(npmLibraryName, typesLibraryName, criteria.importedLibraries)) { | ||
return { type: 2 /* ShouldBeImported */, fileName: originalFileName, libraryName: npmLibraryName, isExternal: true }; | ||
return { type: 2 /* ShouldBeImported */, fileName: originalFileName, libraryName: typesLibraryName || npmLibraryName, isExternal: true }; | ||
} | ||
@@ -41,0 +41,0 @@ if (typesLibraryName !== null && isLibraryAllowed(typesLibraryName, criteria.allowedTypesLibraries)) { |
{ | ||
"name": "dts-bundle-generator", | ||
"version": "1.2.2", | ||
"version": "1.3.0", | ||
"description": "DTS Bundle Generator", | ||
@@ -5,0 +5,0 @@ "main": "bundle-generator.js", |
@@ -76,3 +76,3 @@ [![npm version](https://badge.fury.io/js/dts-bundle-generator.svg)](https://badge.fury.io/js/dts-bundle-generator) [![Build Status](https://travis-ci.org/timocov/dts-bundle-generator.svg?branch=master)](https://travis-ci.org/timocov/dts-bundle-generator) | ||
By default all libraries will be imported (except | ||
inlined) [array] | ||
inlined and libraries from @types) [array] | ||
--external-types Array of the package names from @types to import | ||
@@ -79,0 +79,0 @@ typings from it via triple-slash reference directive. |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
47932
880