Remove workaround for .d.ts module name bug
Closes #303
PiperOrigin-RevId: 217945912
diff --git a/internal/tsc_wrapped/index.ts b/internal/tsc_wrapped/index.ts
index d5abad3..dcb322f 100644
--- a/internal/tsc_wrapped/index.ts
+++ b/internal/tsc_wrapped/index.ts
@@ -4,4 +4,3 @@
export * from './file_cache';
export * from './worker';
export * from './manifest';
-export * from './umd_module_declaration_transform';
diff --git a/internal/tsc_wrapped/tsc_wrapped.ts b/internal/tsc_wrapped/tsc_wrapped.ts
index 2e99ccb..0068df4 100644
--- a/internal/tsc_wrapped/tsc_wrapped.ts
+++ b/internal/tsc_wrapped/tsc_wrapped.ts
@@ -9,8 +9,7 @@
import {CachedFileLoader, FileCache, FileLoader, UncachedFileLoader} from './file_cache';
import {wrap} from './perf_trace';
import {PLUGIN as strictDepsPlugin} from './strict_deps';
-import {BazelOptions, parseTsconfig, resolveNormalizedPath} from './tsconfig';
-import {fixUmdModuleDeclarations} from './umd_module_declaration_transform';
+import {parseTsconfig, resolveNormalizedPath} from './tsconfig';
import {debug, log, runAsWorker, runWorkerLoop} from './worker';
export function main(args: string[]) {
@@ -141,8 +140,6 @@
}
const toEmit = program.getSourceFiles().filter(isCompilationTarget);
const emitResults: ts.EmitResult[] = [];
- const afterTransforms = [fixUmdModuleDeclarations(
- (sf: ts.SourceFile) => compilerHost.amdModuleName(sf))];
if (bazelOpts.tsickle) {
// The 'tsickle' import above is only used in type positions, so it won't
@@ -161,20 +158,14 @@
}
for (const sf of toEmit) {
emitResults.push(optTsickle.emitWithTsickle(
- program, compilerHost, compilerHost, options, sf,
- /*writeFile*/ undefined,
- /*cancellationToken*/ undefined, /*emitOnlyDtsFiles*/ undefined,
- {afterTs: afterTransforms}));
+ program, compilerHost, compilerHost, options, sf));
}
diags.push(
...optTsickle.mergeEmitResults(emitResults as tsickle.EmitResult[])
.diagnostics);
} else {
for (const sf of toEmit) {
- emitResults.push(program.emit(
- sf, /*writeFile*/ undefined,
- /*cancellationToken*/ undefined, /*emitOnlyDtsFiles*/ undefined,
- {after: afterTransforms}));
+ emitResults.push(program.emit(sf));
}
for (const d of emitResults) {
diff --git a/internal/tsc_wrapped/umd_module_declaration_transform.ts b/internal/tsc_wrapped/umd_module_declaration_transform.ts
deleted file mode 100644
index 8bb5f2d..0000000
--- a/internal/tsc_wrapped/umd_module_declaration_transform.ts
+++ /dev/null
@@ -1,58 +0,0 @@
-/**
- * @license
- * Copyright 2017 The Bazel Authors. All rights reserved.
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- *
- * You may obtain a copy of the License at
- * http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-import * as ts from 'typescript';
-
-/**
- * @fileoverview
- * Workaround for https://github.com/Microsoft/TypeScript/issues/18454
- * It's fixed at HEAD, so this is needed only until TypeScript 2.6.
- */
-
-/**
- * This transformer finds AMD module definitions of the form
- * define(["require", "exports"], factory);
- * and inserts the moduleName as a first argument:
- * define("moduleName", ["require", "exports"], factory);
- */
-export function fixUmdModuleDeclarations(
- moduleNamer: (sf: ts.SourceFile) =>
- string | undefined): ts.TransformerFactory<ts.SourceFile> {
- return (context: ts.TransformationContext) =>
- (sf: ts.SourceFile): ts.SourceFile => {
- const moduleName = moduleNamer(sf);
- if (!moduleName) return sf;
-
- const visitor = (node: ts.Node): ts.Node => {
- if (node.kind === ts.SyntaxKind.CallExpression) {
- const ce = node as ts.CallExpression;
- if (ce.expression.kind === ts.SyntaxKind.Identifier &&
- (ce.expression as ts.Identifier).text === 'define' &&
- ce.arguments.length === 2 &&
- ce.arguments[1].kind === ts.SyntaxKind.Identifier &&
- (ce.arguments[1] as ts.Identifier).text === 'factory') {
- const newArguments =
- [ts.createLiteral(moduleName), ...ce.arguments];
- return ts.updateCall(
- ce, ce.expression, ce.typeArguments, newArguments);
- }
- }
- return ts.visitEachChild(node, visitor, context);
- };
- return visitor(sf) as ts.SourceFile;
- };
-}
\ No newline at end of file