diff --git a/index.ts b/index.ts index 4821260..37c3d78 100644 --- a/index.ts +++ b/index.ts @@ -406,9 +406,6 @@ export default function generate(options: Options): Promise { if (moduleId.charAt(0) === '.') { return filenameToMid(pathUtil.join(pathUtil.dirname(sourceModuleId), moduleId)); } - else if (!isDeclaredExternalModule) { - return options.name ? (options.name + '/' + moduleId) : (moduleId); - } } /* For some reason, SourceFile.externalModuleIndicator is missing from 1.6+, so having * to use a sledgehammer on the nut */ diff --git a/tests/support/foo-resolve-module-id/NonRelative.ts b/tests/support/foo-resolve-module-id/NonRelative.ts new file mode 100644 index 0000000..d56fde1 --- /dev/null +++ b/tests/support/foo-resolve-module-id/NonRelative.ts @@ -0,0 +1,5 @@ +export class NonRelative { + public sayHello(s: string): string { + return `Hello $name`; + } +} \ No newline at end of file diff --git a/tests/support/foo-resolve-module-id/index.ts b/tests/support/foo-resolve-module-id/index.ts index af4c79d..53ac52a 100644 --- a/tests/support/foo-resolve-module-id/index.ts +++ b/tests/support/foo-resolve-module-id/index.ts @@ -2,6 +2,7 @@ import { FooImplExportDeclaration } from './FooImplExportDeclaration'; export { ReExport } from './ReExport'; import { ClassInJavaScript } from 'SomethingInJavaScript'; +import { NonRelative } from 'NonRelative'; export function fooImplExportAssignment(): FooImplExportAssignment { return new FooImplExportAssignment(); @@ -13,4 +14,8 @@ export function fooImplExportDeclaration(): FooImplExportDeclaration { export function classInJavaScript(): ClassInJavaScript { return new ClassInJavaScript(); +} + +export function nonRelative(): NonRelative { + return new NonRelative(); } \ No newline at end of file diff --git a/tests/support/foo-resolve-module-id/tsconfig.json b/tests/support/foo-resolve-module-id/tsconfig.json index a426bcd..5aa01eb 100644 --- a/tests/support/foo-resolve-module-id/tsconfig.json +++ b/tests/support/foo-resolve-module-id/tsconfig.json @@ -14,6 +14,7 @@ "./FooInterfaceExportAssignment.ts", "./FooInterfaceExportDeclaration.ts", "./ExternalModuleDeclaration.d.ts", - "./ReExport.ts" + "./ReExport.ts", + "./NonRelative.ts" ] } \ No newline at end of file diff --git a/tests/unit/index.ts b/tests/unit/index.ts index 9b50f09..965372e 100644 --- a/tests/unit/index.ts +++ b/tests/unit/index.ts @@ -148,6 +148,9 @@ registerSuite({ // replaced external module declaration import assert.include(contents, `import { ClassInJavaScript } from 'ReplacedSomethingInJavaScript';`); + // non relative module import, should not be changed + assert.include(contents, `import { NonRelative } from 'NonRelative';`); + // class imports should not be replaced, also assert on them assert.include(contents, `import FooImplExportAssignment = require('foo/FooImplExportAssignment');`); assert.include(contents, `import { FooImplExportDeclaration } from 'foo/FooImplExportDeclaration';`);