Skip to content

Commit c74413f

Browse files
committed
fix(material/schematics): support standalone components in ng-add
Adds code to handle apps that are bootstrapped through `bootstrapApplication` instead of `bootstrapModule`.
1 parent fa4cedc commit c74413f

33 files changed

+8853
-29
lines changed

.bazelignore

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ integration/ng-update-v13/node_modules
99
integration/ng-add/.angular
1010
integration/ng-add/node_modules
1111

12+
integration/ng-add-standalone/.angular
13+
integration/ng-add-standalone/node_modules
14+
1215
integration/yarn-pnp-compat/.angular
1316
integration/yarn-pnp-compat/.yarn/cache
1417
integration/yarn-pnp-compat/.yarn/unplugged
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
2+
# For additional information regarding the format and rule options, please see:
3+
# https://github.com/browserslist/browserslist#queries
4+
5+
# For the full list of supported browsers by the Angular framework, please see:
6+
# https://angular.io/guide/browser-support
7+
8+
# You can see what browsers were selected by your queries by running:
9+
# npx browserslist
10+
11+
last 1 Chrome version
12+
last 1 Firefox version
13+
last 2 Edge major versions
14+
last 2 Safari major versions
15+
last 2 iOS major versions
16+
Firefox ESR
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
# Editor configuration, see https://editorconfig.org
2+
root = true
3+
4+
[*]
5+
charset = utf-8
6+
indent_style = space
7+
indent_size = 2
8+
insert_final_newline = true
9+
trim_trailing_whitespace = true
10+
11+
[*.ts]
12+
quote_type = single
13+
14+
[*.md]
15+
max_line_length = off
16+
trim_trailing_whitespace = false
+45
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
# See http://help.github.com/ignore-files/ for more about ignoring files.
2+
3+
# compiled output
4+
/dist
5+
/tmp
6+
/out-tsc
7+
# Only exists if Bazel was run
8+
/bazel-out
9+
10+
# dependencies
11+
/node_modules
12+
13+
# profiling files
14+
chrome-profiler-events*.json
15+
16+
# IDEs and editors
17+
/.idea
18+
.project
19+
.classpath
20+
.c9/
21+
*.launch
22+
.settings/
23+
*.sublime-workspace
24+
25+
# IDE - VSCode
26+
.vscode/*
27+
!.vscode/settings.json
28+
!.vscode/tasks.json
29+
!.vscode/launch.json
30+
!.vscode/extensions.json
31+
.history/*
32+
33+
# misc
34+
/.sass-cache
35+
/connect.lock
36+
/coverage
37+
/libpeerconnection.log
38+
npm-debug.log
39+
yarn-error.log
40+
testem.log
41+
/typings
42+
43+
# System Files
44+
.DS_Store
45+
Thumbs.db
+31
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
load("@bazel_skylib//lib:dicts.bzl", "dicts")
2+
load("//tools:integration.bzl", "CLI_PROJECT_MAPPINGS")
3+
load("//tools:defaults.bzl", "node_integration_test")
4+
5+
npmPackageMappings = dicts.add(
6+
CLI_PROJECT_MAPPINGS,
7+
{
8+
"//src/cdk:npm_package_archive": "@angular/cdk",
9+
"//src/material:npm_package_archive": "@angular/material",
10+
},
11+
)
12+
13+
node_integration_test(
14+
name = "test",
15+
srcs = glob(["**/*"]),
16+
commands = [
17+
# Note: We use a cache folder within the integration test as otherwise
18+
# the NPM package mapped archive would be cached in the system.
19+
# See: https://github.com/yarnpkg/yarn/issues/2165.
20+
# TODO(devversion): determine if a solution/workaround could live in the test runner.
21+
"yarn install --cache-folder .yarn_cache_folder/",
22+
"yarn ng add @angular/material",
23+
"yarn test",
24+
],
25+
npm_packages = npmPackageMappings,
26+
setup_chromium = True,
27+
tags = [
28+
# This test relies on `yarn` so there needs to be internet access.
29+
"requires-network",
30+
],
31+
)
+27
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# NgAddStandalone
2+
3+
This project was generated with [Angular CLI](https://github.com/angular/angular-cli) version 13.0.0-next.7.
4+
5+
## Development server
6+
7+
Run `ng serve` for a dev server. Navigate to `http://localhost:4200/`. The app will automatically reload if you change any of the source files.
8+
9+
## Code scaffolding
10+
11+
Run `ng generate component component-name` to generate a new component. You can also use `ng generate directive|pipe|service|class|guard|interface|enum|module`.
12+
13+
## Build
14+
15+
Run `ng build` to build the project. The build artifacts will be stored in the `dist/` directory.
16+
17+
## Running unit tests
18+
19+
Run `ng test` to execute the unit tests via [Karma](https://karma-runner.github.io).
20+
21+
## Running end-to-end tests
22+
23+
Run `ng e2e` to execute the end-to-end tests via a platform of your choice. To use this command, you need to first add a package that implements end-to-end testing capabilities.
24+
25+
## Further help
26+
27+
To get more help on the Angular CLI use `ng help` or go check out the [Angular CLI Overview and Command Reference](https://angular.io/cli) page.
+101
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"newProjectRoot": "projects",
5+
"projects": {
6+
"ng-add-standalone": {
7+
"projectType": "application",
8+
"schematics": {
9+
"@schematics/angular:component": {
10+
"style": "scss"
11+
},
12+
"@schematics/angular:application": {
13+
"strict": true
14+
}
15+
},
16+
"root": "",
17+
"sourceRoot": "src",
18+
"prefix": "app",
19+
"architect": {
20+
"build": {
21+
"builder": "@angular-devkit/build-angular:browser",
22+
"options": {
23+
"outputPath": "dist/ng-add-standalone",
24+
"index": "src/index.html",
25+
"main": "src/main.ts",
26+
"polyfills": "src/polyfills.ts",
27+
"tsConfig": "tsconfig.app.json",
28+
"inlineStyleLanguage": "scss",
29+
"assets": ["src/favicon.ico", "src/assets"],
30+
"styles": ["src/styles.scss"],
31+
"scripts": []
32+
},
33+
"configurations": {
34+
"production": {
35+
"budgets": [
36+
{
37+
"type": "initial",
38+
"maximumWarning": "500kb",
39+
"maximumError": "1mb"
40+
},
41+
{
42+
"type": "anyComponentStyle",
43+
"maximumWarning": "2kb",
44+
"maximumError": "4kb"
45+
}
46+
],
47+
"fileReplacements": [
48+
{
49+
"replace": "src/environments/environment.ts",
50+
"with": "src/environments/environment.prod.ts"
51+
}
52+
],
53+
"outputHashing": "all"
54+
},
55+
"development": {
56+
"buildOptimizer": false,
57+
"optimization": false,
58+
"vendorChunk": true,
59+
"extractLicenses": false,
60+
"sourceMap": true,
61+
"namedChunks": true
62+
}
63+
},
64+
"defaultConfiguration": "production"
65+
},
66+
"serve": {
67+
"builder": "@angular-devkit/build-angular:dev-server",
68+
"configurations": {
69+
"production": {
70+
"browserTarget": "ng-add-standalone:build:production"
71+
},
72+
"development": {
73+
"browserTarget": "ng-add-standalone:build:development"
74+
}
75+
},
76+
"defaultConfiguration": "development"
77+
},
78+
"extract-i18n": {
79+
"builder": "@angular-devkit/build-angular:extract-i18n",
80+
"options": {
81+
"browserTarget": "ng-add-standalone:build"
82+
}
83+
},
84+
"test": {
85+
"builder": "@angular-devkit/build-angular:karma",
86+
"options": {
87+
"main": "src/test.ts",
88+
"polyfills": "src/polyfills.ts",
89+
"tsConfig": "tsconfig.spec.json",
90+
"karmaConfig": "karma.conf.js",
91+
"inlineStyleLanguage": "scss",
92+
"assets": ["src/favicon.ico", "src/assets"],
93+
"styles": ["src/styles.scss"],
94+
"scripts": [],
95+
"watch": false
96+
}
97+
}
98+
}
99+
}
100+
}
101+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// Karma configuration file, see link for more information
2+
// https://karma-runner.github.io/1.0/config/configuration-file.html
3+
4+
module.exports = function (config) {
5+
config.set({
6+
basePath: '',
7+
frameworks: ['jasmine', '@angular-devkit/build-angular'],
8+
plugins: [
9+
require('karma-jasmine'),
10+
require('karma-chrome-launcher'),
11+
require('karma-jasmine-html-reporter'),
12+
require('karma-coverage'),
13+
require('@angular-devkit/build-angular/plugins/karma'),
14+
],
15+
client: {
16+
jasmine: {
17+
// you can add configuration options for Jasmine here
18+
// the possible options are listed at https://jasmine.github.io/api/edge/Configuration.html
19+
// for example, you can disable the random execution with `random: false`
20+
// or set a specific seed with `seed: 4321`
21+
},
22+
clearContext: false, // leave Jasmine Spec Runner output visible in browser
23+
},
24+
jasmineHtmlReporter: {
25+
suppressAll: true, // removes the duplicated traces
26+
},
27+
coverageReporter: {
28+
dir: require('path').join(__dirname, './coverage/ng-add-standalone'),
29+
subdir: '.',
30+
reporters: [{type: 'html'}, {type: 'text-summary'}],
31+
},
32+
customLaunchers: {
33+
ChromeHeadlessNoSandbox: {
34+
base: 'ChromeHeadless',
35+
flags: ['--no-sandbox'],
36+
},
37+
},
38+
reporters: ['progress', 'kjhtml'],
39+
port: 9876,
40+
colors: true,
41+
logLevel: config.LOG_INFO,
42+
autoWatch: true,
43+
// Chrome cannot run with sandbox enabled as this test already runs within
44+
// the Bazel sandbox environment and the sandboxes would conflict otherwise.
45+
browsers: ['ChromeHeadlessNoSandbox'],
46+
singleRun: false,
47+
restartOnFileChange: true,
48+
});
49+
};
+42
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
{
2+
"name": "ng-add-standalone",
3+
"version": "0.0.0",
4+
"scripts": {
5+
"ng": "ng",
6+
"start": "ng serve",
7+
"build": "ng build",
8+
"watch": "ng build --watch --configuration development",
9+
"test": "ng test"
10+
},
11+
"private": true,
12+
"dependencies": {
13+
"@angular/animations": "file:../../node_modules/@angular/animations",
14+
"@angular/cdk": "file:../../dist/releases/cdk",
15+
"@angular/common": "file:../../node_modules/@angular/common",
16+
"@angular/compiler": "file:../../node_modules/@angular/compiler",
17+
"@angular/core": "file:../../node_modules/@angular/core",
18+
"@angular/forms": "file:../../node_modules/@angular/forms",
19+
"@angular/material": "file:../../dist/releases/material",
20+
"@angular/platform-browser": "file:../../node_modules/@angular/platform-browser",
21+
"@angular/platform-browser-dynamic": "file:../../node_modules/@angular/platform-browser-dynamic",
22+
"@angular/router": "file:../../node_modules/@angular/router",
23+
"rxjs": "file:../../node_modules/rxjs",
24+
"tslib": "^2.3.0",
25+
"zone.js": "~0.11.4"
26+
},
27+
"devDependencies": {
28+
"@angular-devkit/build-angular": "file:../../node_modules/@angular-devkit/build-angular",
29+
"@angular/cli": "file:../../node_modules/@angular/cli",
30+
"@angular/compiler-cli": "file:../../node_modules/@angular/compiler-cli",
31+
"@types/jasmine": "~3.9.0",
32+
"@types/node": "^12.11.1",
33+
"glob": "^7.2.0",
34+
"jasmine-core": "~3.9.0",
35+
"karma": "~6.3.0",
36+
"karma-chrome-launcher": "~3.1.0",
37+
"karma-coverage": "~2.0.3",
38+
"karma-jasmine": "~4.0.0",
39+
"karma-jasmine-html-reporter": "~1.7.0",
40+
"typescript": "file:../../node_modules/typescript"
41+
}
42+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import {NgModule} from '@angular/core';
2+
import {RouterModule, Routes} from '@angular/router';
3+
4+
const routes: Routes = [];
5+
6+
@NgModule({
7+
imports: [RouterModule.forRoot(routes)],
8+
exports: [RouterModule],
9+
})
10+
export class AppRoutingModule {}

0 commit comments

Comments
 (0)