mirror of
https://github.com/microsoft/TypeScript.git
synced 2026-05-20 05:17:43 -05:00
in declaration emit, handle = require (again)
This commit is contained in:
@@ -680,7 +680,7 @@ namespace ts {
|
||||
}
|
||||
else {
|
||||
write("require(");
|
||||
writeTextOfNode(currentText, getExternalModuleImportEqualsDeclarationExpression(node));
|
||||
emitExternalModuleSpecifier(getExternalModuleImportEqualsDeclarationExpression(node));
|
||||
write(");");
|
||||
}
|
||||
writer.writeLine();
|
||||
|
||||
@@ -6804,7 +6804,13 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
}
|
||||
}
|
||||
|
||||
function getExternalModuleNameText(importNode: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration): string {
|
||||
function getExternalModuleNameText(importNode: ImportDeclaration | ExportDeclaration | ImportEqualsDeclaration, emitRelativePathAsModuleName: boolean): string {
|
||||
if (emitRelativePathAsModuleName) {
|
||||
const name = getExternalModuleNameFromDeclaration(host, resolver, importNode);
|
||||
if (name) {
|
||||
return `"${name}"`;
|
||||
}
|
||||
}
|
||||
const moduleName = getExternalModuleName(importNode);
|
||||
if (moduleName.kind === SyntaxKind.StringLiteral) {
|
||||
return tryRenameExternalModule(<LiteralExpression>moduleName) || getLiteralText(<LiteralExpression>moduleName);
|
||||
@@ -7364,7 +7370,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
const dependencyGroups: DependencyGroup[] = [];
|
||||
|
||||
for (let i = 0; i < externalImports.length; ++i) {
|
||||
let text = getExternalModuleNameText(externalImports[i]);
|
||||
const text = getExternalModuleNameText(externalImports[i], emitRelativePathAsModuleName);
|
||||
if (hasProperty(groupIndices, text)) {
|
||||
// deduplicate/group entries in dependency list by the dependency name
|
||||
const groupIndex = groupIndices[text];
|
||||
@@ -7380,12 +7386,6 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
write(", ");
|
||||
}
|
||||
|
||||
if (emitRelativePathAsModuleName) {
|
||||
const name = getExternalModuleNameFromDeclaration(host, resolver, externalImports[i]);
|
||||
if (name) {
|
||||
text = `"${name}"`;
|
||||
}
|
||||
}
|
||||
write(text);
|
||||
}
|
||||
write(`], function(${exportFunctionForFile}) {`);
|
||||
@@ -7428,14 +7428,7 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, Promi
|
||||
|
||||
for (const importNode of externalImports) {
|
||||
// Find the name of the external module
|
||||
let externalModuleName = getExternalModuleNameText(importNode);
|
||||
|
||||
if (emitRelativePathAsModuleName) {
|
||||
const name = getExternalModuleNameFromDeclaration(host, resolver, importNode);
|
||||
if (name) {
|
||||
externalModuleName = `"${name}"`;
|
||||
}
|
||||
}
|
||||
const externalModuleName = getExternalModuleNameText(importNode, emitRelativePathAsModuleName);
|
||||
|
||||
// Find the name of the module alias, if there is one
|
||||
const importAliasName = getLocalNameForExternalImport(importNode);
|
||||
|
||||
Reference in New Issue
Block a user