Skip to content
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

feat(compiler): generate proper reexports in .ngfactory.ts file… #13524

Merged
merged 1 commit into from
Dec 27, 2016

Conversation

tbosch
Copy link
Contributor

@tbosch tbosch commented Dec 16, 2016

To merge, this needs cl/142263969, cl/142784802, plus a run of release_tsc.sh in G3.

Global presubmit is green (besides flakes).

@tbosch tbosch force-pushed the gen_reexport branch 8 times, most recently from 9a25fec to c402ab2 Compare December 21, 2016 16:59
@@ -21,5 +21,6 @@ export interface PlatformReflectionCapabilities {
method(name: string): MethodFn;
importUri(type: Type<any>): string;
resolveIdentifier(name: string, moduleUrl: string, runtime: any): any;
getIdentifier(name: string, filePath: string, runtime: any): any;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this, pass SaticSymbolCache to CompileMetadataResolver

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -42,6 +42,9 @@ export class StaticAndDynamicReflectionCapabilities {
setter(name: string): SetterFn { return this.dynamicDelegate.setter(name); }
method(name: string): MethodFn { return this.dynamicDelegate.method(name); }
importUri(type: any): string { return this.staticDelegate.importUri(type); }
getIdentifier(name: string, filePath: string, runtime: any): any {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

if (!name) {
return null;
}
let filePath: string;
let isFunctionParam: boolean;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove variable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

if (!isFunctionParam) {
filePath = sourceSymbol.filePath;
if (topLevelSymbolNames.has(name)) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

move logic below into here, i.e. use early returns as well.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done


// Remove extra underscore from escaped identifier
export function unescapeIdentifier(identifier: string): string {
return identifier.length >= 3 && identifier.charCodeAt(0) === UNDERSCORE_CHAR_CODE &&
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe use startsWith('___')?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -70,7 +87,13 @@ export class AotSummaryResolver implements SummaryResolver<StaticSymbol> {
}
if (json) {
const readSummaries = deserializeSummaries(this.staticSymbolCache, json);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

destructure immediately

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

summaries: this.processedSummaries,
symbols: this.symbols.map((symbol, index) => {
let importAs: string;
if (this.summaryResolver.isLibraryFile(symbol.filePath)) {
importAs = `${symbol.name}${index}`;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add _ in between name and index?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

try {
this._directiveResolver.resolve(directiveType, false);
} catch (e) {
console.error('>>>>', directiveType);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove this!

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@@ -20,8 +20,7 @@ import {NgModuleProviderAnalyzer} from './provider_analyzer';
import {ProviderAst} from './template_parser/template_ast';

export class ComponentFactoryDependency {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment that this is not read any more, but we migth need it for later features.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

constructor(
public comp: CompileIdentifierMetadata, public name: string,
public placeholder: CompileIdentifierMetadata) {}
export class ComponentViewDependency {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add comment that these are not used right now but migth be in the future

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

serialize([{symbol: srcSymbol, metadata: 1}, {symbol: libSymbol, metadata: 2}], [])
});
summaryResolver.getSymbolsOf('/src.d.ts');
expect(summaryResolver.getImportAs(libSymbol))
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Check that we don't have an importAs for srcSymbol

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

@tbosch tbosch added action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews pr_state: LGTM and removed state: WIP labels Dec 21, 2016
@tbosch
Copy link
Contributor Author

tbosch commented Dec 21, 2016

Reviewed in person with @vicb

@tbosch tbosch removed the action: cleanup The PR is in need of cleanup, either due to needing a rebase or in response to comments from reviews label Dec 21, 2016
@tbosch tbosch changed the title refactor(compiler): generate proper reexports in .ngfactory.ts file… feat(compiler): generate proper reexports in .ngfactory.ts file… Dec 21, 2016
@tbosch tbosch added the action: merge The PR is ready for merge by the caretaker label Dec 21, 2016
… not need transitive deps for compiling `.ngfactory.ts` files.

Note: This checks the constructors of `@Injectable` classes more strictly.
E.g this will fail now as the constructor argument has no `@Inject` nor is
the type of the argument a DI token.

```
@Injectable()
class MyService {
  constructor(dep: string) {}
}
```

Last part of angular#12787
Closes angular#12787
@hansl hansl merged commit 9c69703 into angular:master Dec 27, 2016
@tbosch tbosch deleted the gen_reexport branch January 4, 2017 16:23
@angular-automatic-lock-bot
Copy link

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 10, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
action: merge The PR is ready for merge by the caretaker cla: yes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants