fix(compiler): support `.` in import statements. (#20634)

fix #20363

PR Close #20634
This commit is contained in:
Mark Levy 2017-11-26 19:04:46 +01:00 committed by Misko Hevery
parent 39af314e29
commit d8f7b293d7
2 changed files with 6 additions and 1 deletions

View File

@ -18,7 +18,7 @@ import {CompilerHost, CompilerOptions, LibrarySummary} from './api';
import {MetadataReaderHost, createMetadataReaderCache, readMetadata} from './metadata_reader';
import {DTS, GENERATED_FILES, isInRootDir, relativeToRootDirs} from './util';
const NODE_MODULES_PACKAGE_NAME = /node_modules\/((\w|-)+|(@(\w|-)+\/(\w|-)+))/;
const NODE_MODULES_PACKAGE_NAME = /node_modules\/((\w|-|\.)+|(@(\w|-|\.)+\/(\w|-|\.)+))/;
const EXT = /(\.ts|\.d\.ts|\.js|\.jsx|\.tsx)$/;
export function createCompilerHost(

View File

@ -65,6 +65,11 @@ describe('NgCompilerHost', () => {
.toBe('@angular/core');
});
it('should allow an import o a package whose name contains dot (e.g. @angular.io)', () => {
expect(host.fileNameToModuleName('/tmp/node_modules/@angular.io/core.d.ts', '/tmp/main.ts'))
.toBe('@angular.io/core');
});
it('should use a package import when accessing a package from another package', () => {
expect(host.fileNameToModuleName(
'/tmp/node_modules/mod1/index.d.ts', '/tmp/node_modules/mod2/index.d.ts'))