Content-Length: 309890 | pFad | http://github.com/angular/angular/pull/60555/files

CB fix(compiler-cli): support relative imports to symbols outside `rootDir` by devversion · Pull Request #60555 · angular/angular · GitHub
Skip to content

fix(compiler-cli): support relative imports to symbols outside rootDir #60555

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions packages/compiler-cli/src/ngtsc/core/src/compiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1301,10 +1301,7 @@ export class NgCompiler {
// namespace" and the logic of `LogicalProjectStrategy` is required to generate correct
// imports which may cross these multiple directories. Otherwise, plain relative imports are
// sufficient.
if (
this.options.rootDir !== undefined ||
(this.options.rootDirs !== undefined && this.options.rootDirs.length > 0)
) {
if (this.options.rootDirs !== undefined && this.options.rootDirs.length > 0) {
// rootDirs logic is in effect - use the `LogicalProjectStrategy` for in-project relative
// imports.
localImportStrategy = new LogicalProjectStrategy(
Expand Down
39 changes: 39 additions & 0 deletions packages/compiler-cli/test/ngtsc/imports_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,45 @@ runInEachFileSystem(() => {
expect(diags[0].file!.fileName).toEqual(absoluteFrom('/app/comp.ts'));
expect(getDiagnosticSourceCode(diags[0])).toEqual('MyComponent');
});

it('should be possible to use a directive outside of `rootDir` when no `rootDirs` are set.', () => {
env.write(
'tsconfig.json',
JSON.stringify(
{
extends: './tsconfig-base.json',
compilerOptions: {rootDir: './app'},
},
null,
2,
),
);
env.write(
'/app/module.ts',
`
import {NgModule} from '@angular/core';
import {ExternalDir} from '../lib/dir';

@NgModule({
imports: [ExternalDir],
})
export class MyModule {}
`,
);
env.write(
'/lib/dir.d.ts',
`
import {ɵɵDirectiveDeclaration} from '@angular/core';

export class ExternalDir {
static ɵdir: ɵɵDirectiveDeclaration<ExternalDir, '[external]', never, never, never, never, never, true>;
}
`,
);

const diags = env.driveDiagnostics();
expect(diags.length).toBe(0);
});
});
});

Expand Down








ApplySandwichStrip

pFad - (p)hone/(F)rame/(a)nonymizer/(d)eclutterfier!      Saves Data!


--- a PPN by Garber Painting Akron. With Image Size Reduction included!

Fetched URL: http://github.com/angular/angular/pull/60555/files

Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy