├── .editorconfig
├── .gitignore
├── README.md
├── angular.json
├── browserslist
├── package.json
├── src
├── app
│ ├── app-routing.module.ts
│ ├── app.component.ts
│ ├── app.module.ts
│ ├── lazy-bar.component.ts
│ ├── lazy-foo.component.ts
│ └── lazy-loading.component.ts
├── assets
│ └── .gitkeep
├── environments
│ ├── environment.prod.ts
│ └── environment.ts
├── favicon.ico
├── index.html
├── main.ts
├── polyfills.ts
└── styles.css
├── tsconfig.app.json
├── tsconfig.json
└── yarn.lock
/.editorconfig:
--------------------------------------------------------------------------------
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 | [*.md]
12 | max_line_length = off
13 | trim_trailing_whitespace = false
14 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
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 | speed-measure-plugin*.json
16 |
17 | # IDEs and editors
18 | /.idea
19 | .project
20 | .classpath
21 | .c9/
22 | *.launch
23 | .settings/
24 | *.sublime-workspace
25 |
26 | # IDE - VSCode
27 | .vscode/*
28 | !.vscode/settings.json
29 | !.vscode/tasks.json
30 | !.vscode/launch.json
31 | !.vscode/extensions.json
32 | .history/*
33 |
34 | # misc
35 | /.sass-cache
36 | /connect.lock
37 | /coverage
38 | /libpeerconnection.log
39 | npm-debug.log
40 | yarn-error.log
41 | testem.log
42 | /typings
43 |
44 | # System Files
45 | .DS_Store
46 | Thumbs.db
47 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | Lazy loaded routed components without Angular modules.
2 |
3 | Components are lazy loaded on first route activation by the
4 | `LazyLoadingComponent`.
5 |
--------------------------------------------------------------------------------
/angular.json:
--------------------------------------------------------------------------------
1 | {
2 | "$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3 | "version": 1,
4 | "newProjectRoot": "projects",
5 | "projects": {
6 | "ngx-lazy-loaded-routes-without-ngmodules": {
7 | "projectType": "application",
8 | "schematics": {
9 | "@schematics/angular:class": {
10 | "skipTests": true
11 | },
12 | "@schematics/angular:component": {
13 | "skipTests": true
14 | },
15 | "@schematics/angular:directive": {
16 | "skipTests": true
17 | },
18 | "@schematics/angular:guard": {
19 | "skipTests": true
20 | },
21 | "@schematics/angular:interceptor": {
22 | "skipTests": true
23 | },
24 | "@schematics/angular:module": {
25 | "skipTests": true
26 | },
27 | "@schematics/angular:pipe": {
28 | "skipTests": true
29 | },
30 | "@schematics/angular:service": {
31 | "skipTests": true
32 | }
33 | },
34 | "root": "",
35 | "sourceRoot": "src",
36 | "prefix": "app",
37 | "architect": {
38 | "build": {
39 | "builder": "@angular-devkit/build-angular:browser",
40 | "options": {
41 | "outputPath": "dist/ngx-lazy-loaded-routes-without-ngmodules",
42 | "index": "src/index.html",
43 | "main": "src/main.ts",
44 | "polyfills": "src/polyfills.ts",
45 | "tsConfig": "tsconfig.app.json",
46 | "aot": true,
47 | "assets": [
48 | "src/favicon.ico",
49 | "src/assets"
50 | ],
51 | "styles": [
52 | "src/styles.css"
53 | ],
54 | "scripts": []
55 | },
56 | "configurations": {
57 | "production": {
58 | "fileReplacements": [
59 | {
60 | "replace": "src/environments/environment.ts",
61 | "with": "src/environments/environment.prod.ts"
62 | }
63 | ],
64 | "optimization": true,
65 | "outputHashing": "all",
66 | "sourceMap": false,
67 | "extractCss": true,
68 | "namedChunks": false,
69 | "extractLicenses": true,
70 | "vendorChunk": false,
71 | "buildOptimizer": true,
72 | "budgets": [
73 | {
74 | "type": "initial",
75 | "maximumWarning": "2mb",
76 | "maximumError": "5mb"
77 | },
78 | {
79 | "type": "anyComponentStyle",
80 | "maximumWarning": "6kb",
81 | "maximumError": "10kb"
82 | }
83 | ]
84 | }
85 | }
86 | },
87 | "serve": {
88 | "builder": "@angular-devkit/build-angular:dev-server",
89 | "options": {
90 | "browserTarget": "ngx-lazy-loaded-routes-without-ngmodules:build"
91 | },
92 | "configurations": {
93 | "production": {
94 | "browserTarget": "ngx-lazy-loaded-routes-without-ngmodules:build:production"
95 | }
96 | }
97 | },
98 | "extract-i18n": {
99 | "builder": "@angular-devkit/build-angular:extract-i18n",
100 | "options": {
101 | "browserTarget": "ngx-lazy-loaded-routes-without-ngmodules:build"
102 | }
103 | }
104 | }
105 | }},
106 | "defaultProject": "ngx-lazy-loaded-routes-without-ngmodules"
107 | }
108 |
--------------------------------------------------------------------------------
/browserslist:
--------------------------------------------------------------------------------
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 | # You can see what browsers were selected by your queries by running:
6 | # npx browserslist
7 |
8 | > 0.5%
9 | last 2 versions
10 | Firefox ESR
11 | not dead
12 | not IE 9-11 # For IE 9-11 support, remove 'not'.
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "ngx-lazy-loaded-routes-without-ngmodules",
3 | "version": "0.0.0",
4 | "scripts": {
5 | "ng": "ng",
6 | "start": "ng serve",
7 | "build": "ng build",
8 | "test": "ng test",
9 | "lint": "ng lint",
10 | "e2e": "ng e2e"
11 | },
12 | "private": true,
13 | "dependencies": {
14 | "@angular/animations": "~9.0.1",
15 | "@angular/common": "~9.0.1",
16 | "@angular/compiler": "~9.0.1",
17 | "@angular/core": "~9.0.1",
18 | "@angular/forms": "~9.0.1",
19 | "@angular/platform-browser": "~9.0.1",
20 | "@angular/platform-browser-dynamic": "~9.0.1",
21 | "@angular/router": "~9.0.1",
22 | "rxjs": "~6.5.4",
23 | "tslib": "^1.10.0",
24 | "zone.js": "~0.10.2"
25 | },
26 | "devDependencies": {
27 | "@angular-devkit/build-angular": "~0.900.2",
28 | "@angular/cli": "~9.0.2",
29 | "@angular/compiler-cli": "~9.0.1",
30 | "@angular/language-service": "~9.0.1",
31 | "@types/node": "^12.11.1",
32 | "ts-node": "~8.3.0",
33 | "tslint": "~5.18.0",
34 | "typescript": "~3.7.5"
35 | }
36 | }
37 |
--------------------------------------------------------------------------------
/src/app/app-routing.module.ts:
--------------------------------------------------------------------------------
1 | import { NgModule } from '@angular/core';
2 | import { RouterModule, Routes } from '@angular/router';
3 |
4 | import { LazyLoadingComponent } from './lazy-loading.component';
5 |
6 |
7 | const routes: Routes = [
8 | {
9 | path: 'lazy-foo',
10 | component: LazyLoadingComponent,
11 | },
12 | {
13 | path: 'lazy-bar',
14 | component: LazyLoadingComponent,
15 | },
16 | ];
17 |
18 | @NgModule({
19 | imports: [RouterModule.forRoot(routes)],
20 | exports: [RouterModule]
21 | })
22 | export class AppRoutingModule { }
23 |
--------------------------------------------------------------------------------
/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'app-root',
5 | template: `
6 |
27 |
28 |
lazy-bar loaded!
6 | `, 7 | }) 8 | export default class LazyBarComponent {} 9 | -------------------------------------------------------------------------------- /src/app/lazy-foo.component.ts: -------------------------------------------------------------------------------- 1 | import { Component } from '@angular/core'; 2 | 3 | @Component({ 4 | template: ` 5 |lazy-foo loaded!
6 | `, 7 | }) 8 | export default class LazyFooComponent {} 9 | -------------------------------------------------------------------------------- /src/app/lazy-loading.component.ts: -------------------------------------------------------------------------------- 1 | import { Component, OnInit, Type } from '@angular/core'; 2 | import { ActivatedRoute, Router, Routes } from '@angular/router'; 3 | 4 | @Component({ 5 | template: '