28 Commits

Author SHA1 Message Date
Jan Martin
fcf7443d62 fix(@schematics/angular): explicitly set standalone:false 2024-10-16 07:56:23 -07:00
aparzi
a381a3db18 feat(@schematics/angular): add option to export component as default
Introduces option `--export-default` to control whether the generated component uses a default export instead of a named export.

Closes: #25023
2024-08-23 23:56:34 +02:00
jason zheng
9db7abd6bf refactor(@schematics/angular): remove unnecessary whitespace in spec template 2024-06-05 09:32:03 -07:00
cexbrayat
571722d2a9 fix(@schematics/angular): remove CommonModule import from standalone components
`ng g c` no longer generates a component with the `CommonModule` import.
This import is not useful if developers adopt the control flow syntax in their templates.
Instead, developers are encouraged to import the individual directives/pipes if needed.
2023-11-23 14:25:07 +01:00
Doug Parker
7b1fd9cf38 refactor(@schematics/angular): update component schematic to use single style or styleUrl property
An array is no longer required in v17 and we always generate a single style or style URL anyways, so we may as well drop the array.
2023-10-30 09:00:18 +01:00
Charles Lyding
0c20cc4dc5 fix(@angular-devkit/build-angular): re-add TestBed compileComponents in schematics to support defer block testing
The defer block support introduces a new asynchronous form of the set class metadata Angular function. This form
is needed to allow for providing metadata for dynamically imported deferred components. The asynchronous compileComponents
call within TestBed is now used to initialize this metadata during unit tests. Unit tests that contain defer blocks
must use this call prior to executing a test to allow templates containing defer to properly render. Existing tests that
do not use the new defer block do not require modification unless the defer block is introduced into components used in
the unit test.
2023-10-04 09:50:20 -04:00
cexbrayat
202e9a50f6 fix(@schematics/angular): remove compileComponents from component test schematic
`compileComponents` is not necessary when using the CLI (as the templates are inlined) and just adds boilerplate code. So we can remove it from the test schematic and make it independent from `async/await` (only place we would have it in the CLI generated code, and in most Angular apps).
2023-03-24 18:30:26 +00:00
Alan Agius
301b5669a7 feat(@schematics/angular): remove ngOnInit from component template
This commit removes the `constructor` and `ngOnInit` as most of the users prefer to add this manually if needed.

Closes #23678
2022-10-04 12:45:30 -04:00
Elton Coelho
d899091d5d fix(@schematics/angular): alphabetically order imports during component generation
change the order of imports during component generation using changeDetectionStrategy set to OnPush

closes angular#23156
2022-05-18 12:58:10 -04:00
Cédric Exbrayat
b16e6f13a7 fix(@schematics/angular): remove extra space in standalone imports 2022-05-06 11:05:29 -07:00
Pawel Kozlowski
df9fc8f5ab refactor(@schematics/angular): include CommonModule for standalone components
This commit adds the CommonModule imports to the standalone components
generated by the Angular's ng add component schematic.
2022-05-03 12:18:54 -07:00
Kristiyan Kostadinov
7b78b7840e feat(@schematics/angular): add --standalone to ng generate
Adds the `--standalone` flag when generating components, directives or pipes through `ng generate`.
2022-04-27 15:33:48 -04:00
gauravsoni119
a5e99762ef fix(@schematics/angular): fix extra comma added when use --change-detection=onPush and --style=none to generate a component 2022-03-30 16:59:17 +02:00
Adrien Crivelli
09a71bab60 fix(@schematics/angular): Consolidated setup with a single beforeEach()
Since f463c8403547 we use native `async`/`await` and thus we do not need
to split setup in two `beforeEach()`
2022-03-21 12:27:09 -07:00
David Scourfield
8ad1539c5e feat(@schematics/angular): add 'none' value for the 'style' option of the component schematic
Allow setting `--style=none` for the component schematic to prevent generation of any style file.  Previously this was possible only with `--inlineStyle=true`, which had the side-effect of adding an inline style block to the component decorator.  Useful for components or projects which have entirely externalised stylesheets and never want to use component-specific styles.
2021-06-21 11:10:23 +01:00
Charles Lyding
f463c84035 fix(@schematics/angular): remove async test helper function from component schematic 2020-07-15 12:36:48 -04:00
Chau Tran
f089bb144c fix(@schematics/angular): fix extra comma if inlineStyle is on
When generating a new component, if `inlineStyle` and either
`viewEncapsulation` or `changeDetection` flag is provided, there is an
extra comma after `styles: [],,` causing the component to bugged out.
2020-03-30 10:22:37 -07:00
Sachin Grover
1c1f1cde65 fix(@schematics/angular): Allow empty string in the type option
Currently, Component and Class have the options to add custom type. In the case of class, It's already working fine with  an empty string in type but in the case  of component When setting the type to an empty string the file names generated will contain an extra period (.) which breaks the flow.

With this PR, It will generate the files without an extra period (.)

Reference #16811 and #16891
2020-02-26 12:02:20 -08:00
Reto Ryter
d6fa2bde93 feat(@schematics/angular): add opt in option 'displayBlock' 2020-02-05 10:30:15 -08:00
Cyrille Tuzi
76d2656fe5 fix(@schematics/angular): add compliance with call-signature lint rule 2020-01-27 11:28:59 -08:00
Leon Radley
c0d42e0c0e feat(@schematics/angular): add type option to component generator (#15754)
the type option allows you to change the default .component.ts suffix to new types.
such as

Route
Dialog
UI
Container
2019-10-09 11:09:12 -07:00
mgechev
302cace038 feat(@schematics/angular): add skipSelector property to the component generator
Fix #14749
2019-06-20 10:57:33 -07:00
SamanthaAdrichem
8352f1e10f fix(@schematics/angular): remove indentation in component html
Most editors remember the indentation, even if you remove all code. This way, there is no
indentation thus there is nothing for the editor to remember and there will be no need for
a HTML lint fix.

Fixes #14816
2019-06-18 18:26:35 -07:00
Alan
08c4cb748f fix(@schematics/angular): reintroduce .sass as a supported file extention
Sass Indented (.sass) is fully supported by the Sass team and we should still offer and support it.

Fixes #13739
2019-03-04 10:26:09 -08:00
Alan
4718de4dae feat(@schematics/angular): only support known style extentions
Fixes #13149
2019-01-18 11:56:19 -08:00
Alan Agius
36eba0c9fc refactor: use .template suffix for all schematic files
Currently when using `ivy-ngcc` it will print out a warning

```
Failed to read entry point info from //node_modules/@schematics/angular/workspace/files/package.json with error SyntaxError: Unexpected token < in JSON at position 1121.
```

Fixes #13378
2019-01-16 10:29:56 -08:00
Alan Agius
a12a4e02a4 feat(@schematics/angular): consistent naming of options and arguments that do the same thing
This aligns options that do the same thing:
1) `skipSpecs` and `spec` has been deprecated in favor of `skipTests`.
2) `styleext` has been deprecated in favor of `style` since the latest is two words.

Fixes #12784
2018-12-11 11:55:54 -08:00
Hans Larsen
44086c60ff build: move devkit repo back to angular-cli 2018-06-05 18:50:06 -07:00