Skip to content

Commit

Permalink
fix(angular): fix component export logic to handle internal modules a…
Browse files Browse the repository at this point in the history
…nd secondary entry points (#10517)
  • Loading branch information
leosvelperez committed May 31, 2022
1 parent d200818 commit 2b1591d
Show file tree
Hide file tree
Showing 9 changed files with 512 additions and 71 deletions.
2 changes: 1 addition & 1 deletion docs/generated/packages/angular.json
Expand Up @@ -360,7 +360,7 @@
},
"export": {
"type": "boolean",
"description": "Specifies if the component should be exported in the declaring `NgModule`. Additionally, if the project is a library, the component will be exported from the project's entry point (normally `index.ts`).",
"description": "Specifies if the component should be exported in the declaring `NgModule`. Additionally, if the project is a library, the component will be exported from the project's entry point (normally `index.ts`) if the module it belongs to is also exported.",
"default": false
}
},
Expand Down
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP

exports[`component Generator --flat should create the component correctly and export it 1`] = `
exports[`component Generator --flat should create the component correctly and export it in the entry point 1`] = `
"import { Component, OnInit } from '@angular/core';
@Component({
Expand All @@ -19,7 +19,7 @@ export class ExampleComponent implements OnInit {
"
`;

exports[`component Generator --flat should create the component correctly and not export it 1`] = `
exports[`component Generator --flat should create the component correctly and not export it when "export=false" 1`] = `
"import { Component, OnInit } from '@angular/core';
@Component({
Expand All @@ -38,7 +38,7 @@ export class ExampleComponent implements OnInit {
"
`;

exports[`component Generator --path should create the component correctly and export it 1`] = `
exports[`component Generator --path should create the component correctly and export it in the entry point 1`] = `
"import { Component, OnInit } from '@angular/core';
@Component({
Expand All @@ -57,7 +57,7 @@ export class ExampleComponent implements OnInit {
"
`;

exports[`component Generator should create the component correctly and export it 1`] = `
exports[`component Generator secondary entry points should create the component correctly and export it in the entry point 1`] = `
"import { Component, OnInit } from '@angular/core';
@Component({
Expand All @@ -76,12 +76,12 @@ export class ExampleComponent implements OnInit {
"
`;

exports[`component Generator should create the component correctly and export it 2`] = `
"
export * from \\"./lib/example/example.component\\";"
exports[`component Generator secondary entry points should create the component correctly and export it in the entry point 2`] = `
"export * from \\"./lib/secondary.module\\";
export * from \\"./lib/example/example.component\\";"
`;

exports[`component Generator should create the component correctly and not export it 1`] = `
exports[`component Generator should create the component correctly and export it in the entry point 1`] = `
"import { Component, OnInit } from '@angular/core';
@Component({
Expand All @@ -100,6 +100,11 @@ export class ExampleComponent implements OnInit {
"
`;

exports[`component Generator should create the component correctly and export it in the entry point 2`] = `
"export * from \\"./lib/lib.module\\";
export * from \\"./lib/example/example.component\\";"
`;

exports[`component Generator should create the component correctly and not export it when "--skip-import=true" 1`] = `
"import { Component, OnInit } from '@angular/core';
Expand All @@ -119,7 +124,26 @@ export class ExampleComponent implements OnInit {
"
`;

exports[`component Generator should create the component correctly but not export it when no entry point exists 1`] = `
exports[`component Generator should create the component correctly and not export it when "export=false" 1`] = `
"import { Component, OnInit } from '@angular/core';
@Component({
selector: 'example',
templateUrl: './example.component.html',
styleUrls: ['./example.component.css']
})
export class ExampleComponent implements OnInit {
constructor() { }
ngOnInit(): void {
}
}
"
`;

exports[`component Generator should create the component correctly but not export it in the entry point when it does not exist 1`] = `
"import { Component, OnInit } from '@angular/core';
@Component({
Expand Down

1 comment on commit 2b1591d

@vercel
Copy link

@vercel vercel bot commented on 2b1591d May 31, 2022

Choose a reason for hiding this comment

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

Successfully deployed to the following URLs:

nx-dev – ./

nx.dev
nx-dev-git-master-nrwl.vercel.app
nx-dev-nrwl.vercel.app
nx-five.vercel.app

Please sign in to comment.