Skip to content

Commit 964e17d

Browse files
committed
feat: initial commit
0 parents  commit 964e17d

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+15274
-0
lines changed

.browserslistrc

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
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
17+
not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.

.editorconfig

Lines changed: 16 additions & 0 deletions
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

.gitignore

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
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

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# NgPackagr Lazy load modules (routing) example
2+
3+
This example show workaround how to create angular library with lazy loaded modules(routing) inside library
4+
5+
## Development server
6+
Run `npm run start`. You could use one of the configuration in tsconfig.json
7+
8+
## Build package
9+
10+
Uncomment "Package build" section in tsconfig.json and comment "Develop build". Run `npm run build:package`;
11+

angular.json

Lines changed: 171 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,171 @@
1+
{
2+
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
3+
"version": 1,
4+
"newProjectRoot": "projects",
5+
"projects": {
6+
"ng-packagr-lazy-load": {
7+
"projectType": "application",
8+
"schematics": {
9+
"@schematics/angular:application": {
10+
"strict": true
11+
}
12+
},
13+
"root": "",
14+
"sourceRoot": "src",
15+
"prefix": "app",
16+
"architect": {
17+
"build": {
18+
"builder": "@angular-devkit/build-angular:browser",
19+
"options": {
20+
"outputPath": "dist/ng-packagr-lazy-load",
21+
"index": "src/index.html",
22+
"main": "src/main.ts",
23+
"polyfills": "src/polyfills.ts",
24+
"tsConfig": "tsconfig.app.json",
25+
"aot": true,
26+
"assets": [
27+
"src/favicon.ico",
28+
"src/assets"
29+
],
30+
"styles": [
31+
"src/styles.css"
32+
],
33+
"scripts": []
34+
},
35+
"configurations": {
36+
"production": {
37+
"fileReplacements": [
38+
{
39+
"replace": "src/environments/environment.ts",
40+
"with": "src/environments/environment.prod.ts"
41+
}
42+
],
43+
"optimization": true,
44+
"outputHashing": "all",
45+
"sourceMap": false,
46+
"namedChunks": false,
47+
"extractLicenses": true,
48+
"vendorChunk": false,
49+
"buildOptimizer": true,
50+
"budgets": [
51+
{
52+
"type": "initial",
53+
"maximumWarning": "500kb",
54+
"maximumError": "1mb"
55+
},
56+
{
57+
"type": "anyComponentStyle",
58+
"maximumWarning": "2kb",
59+
"maximumError": "4kb"
60+
}
61+
]
62+
}
63+
}
64+
},
65+
"serve": {
66+
"builder": "@angular-devkit/build-angular:dev-server",
67+
"options": {
68+
"browserTarget": "ng-packagr-lazy-load:build"
69+
},
70+
"configurations": {
71+
"production": {
72+
"browserTarget": "ng-packagr-lazy-load:build:production"
73+
}
74+
}
75+
},
76+
"extract-i18n": {
77+
"builder": "@angular-devkit/build-angular:extract-i18n",
78+
"options": {
79+
"browserTarget": "ng-packagr-lazy-load:build"
80+
}
81+
},
82+
"test": {
83+
"builder": "@angular-devkit/build-angular:karma",
84+
"options": {
85+
"main": "src/test.ts",
86+
"polyfills": "src/polyfills.ts",
87+
"tsConfig": "tsconfig.spec.json",
88+
"karmaConfig": "karma.conf.js",
89+
"assets": [
90+
"src/favicon.ico",
91+
"src/assets"
92+
],
93+
"styles": [
94+
"src/styles.css"
95+
],
96+
"scripts": []
97+
}
98+
},
99+
"lint": {
100+
"builder": "@angular-devkit/build-angular:tslint",
101+
"options": {
102+
"tsConfig": [
103+
"tsconfig.app.json",
104+
"tsconfig.spec.json",
105+
"e2e/tsconfig.json"
106+
],
107+
"exclude": [
108+
"**/node_modules/**"
109+
]
110+
}
111+
},
112+
"e2e": {
113+
"builder": "@angular-devkit/build-angular:protractor",
114+
"options": {
115+
"protractorConfig": "e2e/protractor.conf.js",
116+
"devServerTarget": "ng-packagr-lazy-load:serve"
117+
},
118+
"configurations": {
119+
"production": {
120+
"devServerTarget": "ng-packagr-lazy-load:serve:production"
121+
}
122+
}
123+
}
124+
}
125+
},
126+
"auth": {
127+
"projectType": "library",
128+
"root": "projects/auth",
129+
"sourceRoot": "projects/auth/src",
130+
"prefix": "lib",
131+
"architect": {
132+
"build": {
133+
"builder": "@angular-devkit/build-angular:ng-packagr",
134+
"options": {
135+
"tsConfig": "projects/auth/tsconfig.lib.json",
136+
"project": "projects/auth/ng-package.json"
137+
},
138+
"configurations": {
139+
"production": {
140+
"tsConfig": "projects/auth/tsconfig.lib.prod.json"
141+
}
142+
}
143+
},
144+
"test": {
145+
"builder": "@angular-devkit/build-angular:karma",
146+
"options": {
147+
"main": "projects/auth/src/test.ts",
148+
"tsConfig": "projects/auth/tsconfig.spec.json",
149+
"karmaConfig": "projects/auth/karma.conf.js"
150+
}
151+
},
152+
"lint": {
153+
"builder": "@angular-devkit/build-angular:tslint",
154+
"options": {
155+
"tsConfig": [
156+
"projects/auth/tsconfig.lib.json",
157+
"projects/auth/tsconfig.spec.json"
158+
],
159+
"exclude": [
160+
"**/node_modules/**"
161+
]
162+
}
163+
}
164+
}
165+
}
166+
},
167+
"defaultProject": "ng-packagr-lazy-load",
168+
"cli": {
169+
"analytics": "df60582b-3f41-4518-9488-83ca0f0accbe"
170+
}
171+
}

e2e/protractor.conf.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// @ts-check
2+
// Protractor configuration file, see link for more information
3+
// https://github.com/angular/protractor/blob/master/lib/config.ts
4+
5+
const { SpecReporter, StacktraceOption } = require('jasmine-spec-reporter');
6+
7+
/**
8+
* @type { import("protractor").Config }
9+
*/
10+
exports.config = {
11+
allScriptsTimeout: 11000,
12+
specs: [
13+
'./src/**/*.e2e-spec.ts'
14+
],
15+
capabilities: {
16+
browserName: 'chrome'
17+
},
18+
directConnect: true,
19+
SELENIUM_PROMISE_MANAGER: false,
20+
baseUrl: 'http://localhost:4200/',
21+
framework: 'jasmine',
22+
jasmineNodeOpts: {
23+
showColors: true,
24+
defaultTimeoutInterval: 30000,
25+
print: function() {}
26+
},
27+
onPrepare() {
28+
require('ts-node').register({
29+
project: require('path').join(__dirname, './tsconfig.json')
30+
});
31+
jasmine.getEnv().addReporter(new SpecReporter({
32+
spec: {
33+
displayStacktrace: StacktraceOption.PRETTY
34+
}
35+
}));
36+
}
37+
};

e2e/src/app.e2e-spec.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import { AppPage } from './app.po';
2+
import { browser, logging } from 'protractor';
3+
4+
describe('workspace-project App', () => {
5+
let page: AppPage;
6+
7+
beforeEach(() => {
8+
page = new AppPage();
9+
});
10+
11+
it('should display welcome message', async () => {
12+
await page.navigateTo();
13+
expect(await page.getTitleText()).toEqual('ng-packagr-lazy-load app is running!');
14+
});
15+
16+
afterEach(async () => {
17+
// Assert that there are no errors emitted from the browser
18+
const logs = await browser.manage().logs().get(logging.Type.BROWSER);
19+
expect(logs).not.toContain(jasmine.objectContaining({
20+
level: logging.Level.SEVERE,
21+
} as logging.Entry));
22+
});
23+
});

e2e/src/app.po.ts

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import { browser, by, element } from 'protractor';
2+
3+
export class AppPage {
4+
async navigateTo(): Promise<unknown> {
5+
return browser.get(browser.baseUrl);
6+
}
7+
8+
async getTitleText(): Promise<string> {
9+
return element(by.css('app-root .content span')).getText();
10+
}
11+
}

e2e/tsconfig.json

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
/* To learn more about this file see: https://angular.io/config/tsconfig. */
2+
{
3+
"extends": "../tsconfig.json",
4+
"compilerOptions": {
5+
"outDir": "../out-tsc/e2e",
6+
"module": "commonjs",
7+
"target": "es2018",
8+
"types": [
9+
"jasmine",
10+
"node"
11+
]
12+
}
13+
}

karma.conf.js

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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+
clearContext: false // leave Jasmine Spec Runner output visible in browser
17+
},
18+
coverageReporter: {
19+
dir: require('path').join(__dirname, './coverage/ng-packagr-lazy-load'),
20+
subdir: '.',
21+
reporters: [
22+
{ type: 'html' },
23+
{ type: 'text-summary' }
24+
]
25+
},
26+
reporters: ['progress', 'kjhtml'],
27+
port: 9876,
28+
colors: true,
29+
logLevel: config.LOG_INFO,
30+
autoWatch: true,
31+
browsers: ['Chrome'],
32+
singleRun: false,
33+
restartOnFileChange: true
34+
});
35+
};

0 commit comments

Comments
 (0)