Skip to content

Commit d8f7b29

Browse files
MarkChrisLevymhevery
authored andcommitted
fix(compiler): support . in import statements. (#20634)
fix #20363 PR Close #20634
1 parent 39af314 commit d8f7b29

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

packages/compiler-cli/src/transformers/compiler_host.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {CompilerHost, CompilerOptions, LibrarySummary} from './api';
1818
import {MetadataReaderHost, createMetadataReaderCache, readMetadata} from './metadata_reader';
1919
import {DTS, GENERATED_FILES, isInRootDir, relativeToRootDirs} from './util';
2020

21-
const NODE_MODULES_PACKAGE_NAME = /node_modules\/((\w|-)+|(@(\w|-)+\/(\w|-)+))/;
21+
const NODE_MODULES_PACKAGE_NAME = /node_modules\/((\w|-|\.)+|(@(\w|-|\.)+\/(\w|-|\.)+))/;
2222
const EXT = /(\.ts|\.d\.ts|\.js|\.jsx|\.tsx)$/;
2323

2424
export function createCompilerHost(

packages/compiler-cli/test/transformers/compiler_host_spec.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ describe('NgCompilerHost', () => {
6565
.toBe('@angular/core');
6666
});
6767

68+
it('should allow an import o a package whose name contains dot (e.g. @angular.io)', () => {
69+
expect(host.fileNameToModuleName('/tmp/node_modules/@angular.io/core.d.ts', '/tmp/main.ts'))
70+
.toBe('@angular.io/core');
71+
});
72+
6873
it('should use a package import when accessing a package from another package', () => {
6974
expect(host.fileNameToModuleName(
7075
'/tmp/node_modules/mod1/index.d.ts', '/tmp/node_modules/mod2/index.d.ts'))

0 commit comments

Comments
 (0)