├── .editorconfig
├── .gitignore
├── .prettierignore
├── .prettierrc
├── README.md
├── angular.json
├── apps
├── code-of-conduct
│ ├── .browserslistrc
│ ├── extra-webpack.config.js
│ ├── jest.config.js
│ ├── src
│ │ ├── app
│ │ │ ├── app.component.spec.ts
│ │ │ ├── app.component.ts
│ │ │ └── app.module.ts
│ │ ├── assets
│ │ │ └── CODE_OF_CONDUCT.md
│ │ ├── environments
│ │ │ ├── environment.prod.ts
│ │ │ └── environment.ts
│ │ ├── favicon.ico
│ │ ├── index.html
│ │ ├── main.ts
│ │ ├── polyfills.ts
│ │ ├── styles.scss
│ │ └── test-setup.ts
│ ├── tsconfig.app.json
│ ├── tsconfig.json
│ ├── tsconfig.spec.json
│ └── tslint.json
├── main
│ ├── .browserslistrc
│ ├── extra-webpack.config.js
│ ├── jest.config.js
│ ├── proxy.conf.json
│ ├── src
│ │ ├── app
│ │ │ ├── app.component.html
│ │ │ ├── app.component.scss
│ │ │ ├── app.component.spec.ts
│ │ │ ├── app.component.ts
│ │ │ ├── app.module.ts
│ │ │ ├── app.tokens.ts
│ │ │ └── blank
│ │ │ │ ├── blank.component.spec.ts
│ │ │ │ └── blank.component.ts
│ │ ├── assets
│ │ │ └── .gitkeep
│ │ ├── environments
│ │ │ ├── environment.prod.ts
│ │ │ └── environment.ts
│ │ ├── favicon.ico
│ │ ├── index.html
│ │ ├── main.ts
│ │ ├── polyfills.ts
│ │ ├── styles.scss
│ │ └── test-setup.ts
│ ├── tsconfig.app.json
│ ├── tsconfig.json
│ ├── tsconfig.spec.json
│ └── tslint.json
└── readme
│ ├── .browserslistrc
│ ├── extra-webpack.config.js
│ ├── jest.config.js
│ ├── src
│ ├── app
│ │ ├── app.component.html
│ │ ├── app.component.scss
│ │ ├── app.component.spec.ts
│ │ ├── app.component.ts
│ │ └── app.module.ts
│ ├── assets
│ │ └── README.md
│ ├── environments
│ │ ├── environment.prod.ts
│ │ └── environment.ts
│ ├── favicon.ico
│ ├── index.html
│ ├── main.ts
│ ├── polyfills.ts
│ ├── styles.scss
│ └── test-setup.ts
│ ├── tsconfig.app.json
│ ├── tsconfig.json
│ ├── tsconfig.spec.json
│ └── tslint.json
├── jest.config.js
├── libs
└── .gitkeep
├── nx.json
├── package-lock.json
├── package.json
├── tools
├── schematics
│ └── .gitkeep
└── tsconfig.tools.json
├── tsconfig.base.json
└── tslint.json
/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see http://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 |
8 | # dependencies
9 | /node_modules
10 |
11 | # IDEs and editors
12 | /.idea
13 | .project
14 | .classpath
15 | .c9/
16 | *.launch
17 | .settings/
18 | *.sublime-workspace
19 |
20 | # IDE - VSCode
21 | .vscode/*
22 | !.vscode/settings.json
23 | !.vscode/tasks.json
24 | !.vscode/launch.json
25 | !.vscode/extensions.json
26 |
27 | # misc
28 | /.sass-cache
29 | /connect.lock
30 | /coverage
31 | /libpeerconnection.log
32 | npm-debug.log
33 | yarn-error.log
34 | testem.log
35 | /typings
36 |
37 | # System Files
38 | .DS_Store
39 | Thumbs.db
40 |
--------------------------------------------------------------------------------
/.prettierignore:
--------------------------------------------------------------------------------
1 | # Add files here to ignore them from prettier formatting
2 |
3 | /dist
4 | /coverage
5 |
--------------------------------------------------------------------------------
/.prettierrc:
--------------------------------------------------------------------------------
1 | {
2 | "singleQuote": true
3 | }
4 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # SharedLibraryPluginDemo
2 |
3 | This project was generated using [Nx](https://nx.dev).
4 |
5 |
6 |
7 | 🔎 **Nx is a set of Extensible Dev Tools for Monorepos.**
8 |
9 | ## Quick Start & Documentation
10 |
11 | [Nx Documentation](https://nx.dev/angular)
12 |
13 | [10-minute video showing all Nx features](https://nx.dev/angular/getting-started/what-is-nx)
14 |
15 | [Interactive Tutorial](https://nx.dev/angular/tutorial/01-create-application)
16 |
17 | ## Adding capabilities to your workspace
18 |
19 | Nx supports many plugins which add capabilities for developing different types of applications and different tools.
20 |
21 | These capabilities include generating applications, libraries, etc as well as the devtools to test, and build projects as well.
22 |
23 | Below are our core plugins:
24 |
25 | - [Angular](https://angular.io)
26 | - `ng add @nrwl/angular`
27 | - [React](https://reactjs.org)
28 | - `ng add @nrwl/react`
29 | - Web (no framework frontends)
30 | - `ng add @nrwl/web`
31 | - [Nest](https://nestjs.com)
32 | - `ng add @nrwl/nest`
33 | - [Express](https://expressjs.com)
34 | - `ng add @nrwl/express`
35 | - [Node](https://nodejs.org)
36 | - `ng add @nrwl/node`
37 |
38 | There are also many [community plugins](https://nx.dev/nx-community) you could add.
39 |
40 | ## Generate an application
41 |
42 | Run `ng g @nrwl/angular:app my-app` to generate an application.
43 |
44 | > You can use any of the plugins above to generate applications as well.
45 |
46 | When using Nx, you can create multiple applications and libraries in the same workspace.
47 |
48 | ## Generate a library
49 |
50 | Run `ng g @nrwl/angular:lib my-lib` to generate a library.
51 |
52 | > You can also use any of the plugins above to generate libraries as well.
53 |
54 | Libraries are sharable across libraries and applications. They can be imported from `@shared-library-plugin-demo/mylib`.
55 |
56 | ## Development server
57 |
58 | Run `ng serve my-app` for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.
59 |
60 | ## Code scaffolding
61 |
62 | Run `ng g component my-component --project=my-app` to generate a new component.
63 |
64 | ## Build
65 |
66 | Run `ng build my-app` to build the project. The build artifacts will be stored in the `dist/` directory. Use the `--prod` flag for a production build.
67 |
68 | ## Running unit tests
69 |
70 | Run `ng test my-app` to execute the unit tests via [Jest](https://jestjs.io).
71 |
72 | Run `nx affected:test` to execute the unit tests affected by a change.
73 |
74 | ## Running end-to-end tests
75 |
76 | Run `ng e2e my-app` to execute the end-to-end tests via [Cypress](https://www.cypress.io).
77 |
78 | Run `nx affected:e2e` to execute the end-to-end tests affected by a change.
79 |
80 | ## Understand your workspace
81 |
82 | Run `nx dep-graph` to see a diagram of the dependencies of your projects.
83 |
84 | ## Further help
85 |
86 | Visit the [Nx Documentation](https://nx.dev/angular) to learn more.
87 |
88 | ## ☁ Nx Cloud
89 |
90 | ### Computation Memoization in the Cloud
91 |
92 |
93 |
94 | Nx Cloud pairs with Nx in order to enable you to build and test code more rapidly, by up to 10 times. Even teams that are new to Nx can connect to Nx Cloud and start saving time instantly.
95 |
96 | Teams using Nx gain the advantage of building full-stack applications with their preferred framework alongside Nx’s advanced code generation and project dependency graph, plus a unified experience for both frontend and backend developers.
97 |
98 | Visit [Nx Cloud](https://nx.app/) to learn more.
99 |
--------------------------------------------------------------------------------
/angular.json:
--------------------------------------------------------------------------------
1 | {
2 | "version": 1,
3 | "projects": {
4 | "main": {
5 | "projectType": "application",
6 | "schematics": {
7 | "@nrwl/angular:component": {
8 | "style": "scss"
9 | }
10 | },
11 | "root": "apps/main",
12 | "sourceRoot": "apps/main/src",
13 | "prefix": "shared-library-plugin-demo",
14 | "architect": {
15 | "build": {
16 | "builder": "@angular-builders/custom-webpack:browser",
17 | "options": {
18 | "customWebpackConfig": {
19 | "path": "apps/main/extra-webpack.config.js"
20 | },
21 | "outputPath": "dist/apps/main",
22 | "index": "apps/main/src/index.html",
23 | "main": "apps/main/src/main.ts",
24 | "polyfills": "apps/main/src/polyfills.ts",
25 | "tsConfig": "apps/main/tsconfig.app.json",
26 | "aot": true,
27 | "assets": [
28 | "apps/main/src/favicon.ico",
29 | "apps/main/src/assets"
30 | ],
31 | "styles": [
32 | "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
33 | "apps/main/src/styles.scss"
34 | ],
35 | "scripts": []
36 | },
37 | "configurations": {
38 | "production": {
39 | "fileReplacements": [
40 | {
41 | "replace": "apps/main/src/environments/environment.ts",
42 | "with": "apps/main/src/environments/environment.prod.ts"
43 | }
44 | ],
45 | "optimization": true,
46 | "outputHashing": "all",
47 | "sourceMap": false,
48 | "extractCss": true,
49 | "namedChunks": false,
50 | "extractLicenses": true,
51 | "vendorChunk": false,
52 | "buildOptimizer": true,
53 | "budgets": [
54 | {
55 | "type": "initial",
56 | "maximumWarning": "2mb",
57 | "maximumError": "5mb"
58 | },
59 | {
60 | "type": "anyComponentStyle",
61 | "maximumWarning": "6kb",
62 | "maximumError": "10kb"
63 | }
64 | ]
65 | }
66 | }
67 | },
68 | "serve": {
69 | "builder": "@angular-builders/custom-webpack:dev-server",
70 | "options": {
71 | "browserTarget": "main:build",
72 | "proxyConfig": "apps/main/proxy.conf.json"
73 | },
74 | "configurations": {
75 | "production": {
76 | "browserTarget": "main:build:production"
77 | }
78 | }
79 | },
80 | "extract-i18n": {
81 | "builder": "@angular-devkit/build-angular:extract-i18n",
82 | "options": {
83 | "browserTarget": "main:build"
84 | }
85 | },
86 | "lint": {
87 | "builder": "@angular-devkit/build-angular:tslint",
88 | "options": {
89 | "tsConfig": [
90 | "apps/main/tsconfig.app.json",
91 | "apps/main/tsconfig.spec.json"
92 | ],
93 | "exclude": [
94 | "**/node_modules/**",
95 | "!apps/main/**/*"
96 | ]
97 | }
98 | },
99 | "test": {
100 | "builder": "@nrwl/jest:jest",
101 | "options": {
102 | "jestConfig": "apps/main/jest.config.js",
103 | "tsConfig": "apps/main/tsconfig.spec.json",
104 | "passWithNoTests": true,
105 | "setupFile": "apps/main/src/test-setup.ts"
106 | }
107 | }
108 | }
109 | },
110 | "readme": {
111 | "projectType": "application",
112 | "schematics": {
113 | "@nrwl/angular:component": {
114 | "style": "scss"
115 | }
116 | },
117 | "root": "apps/readme",
118 | "sourceRoot": "apps/readme/src",
119 | "prefix": "shared-library-plugin-demo",
120 | "architect": {
121 | "build": {
122 | "builder": "@angular-builders/custom-webpack:browser",
123 | "options": {
124 | "customWebpackConfig": {
125 | "path": "apps/readme/extra-webpack.config.js"
126 | },
127 | "outputPath": "dist/apps/main/readme/static",
128 | "index": "apps/readme/src/index.html",
129 | "main": "apps/readme/src/main.ts",
130 | "polyfills": "apps/readme/src/polyfills.ts",
131 | "tsConfig": "apps/readme/tsconfig.app.json",
132 | "aot": true,
133 | "assets": [
134 | "apps/readme/src/favicon.ico",
135 | "apps/readme/src/assets"
136 | ],
137 | "styles": [
138 | "./node_modules/@angular/material/prebuilt-themes/indigo-pink.css",
139 | "apps/readme/src/styles.scss"
140 | ],
141 | "scripts": [],
142 | "baseHref": "/readme/static/"
143 | },
144 | "configurations": {
145 | "production": {
146 | "fileReplacements": [
147 | {
148 | "replace": "apps/readme/src/environments/environment.ts",
149 | "with": "apps/readme/src/environments/environment.prod.ts"
150 | }
151 | ],
152 | "optimization": true,
153 | "outputHashing": "all",
154 | "sourceMap": false,
155 | "extractCss": true,
156 | "namedChunks": false,
157 | "extractLicenses": true,
158 | "vendorChunk": false,
159 | "buildOptimizer": true,
160 | "budgets": [
161 | {
162 | "type": "initial",
163 | "maximumWarning": "2mb",
164 | "maximumError": "5mb"
165 | },
166 | {
167 | "type": "anyComponentStyle",
168 | "maximumWarning": "6kb",
169 | "maximumError": "10kb"
170 | }
171 | ]
172 | }
173 | }
174 | },
175 | "serve": {
176 | "builder": "@angular-builders/custom-webpack:dev-server",
177 | "options": {
178 | "browserTarget": "readme:build",
179 | "port": 4100
180 | },
181 | "configurations": {
182 | "production": {
183 | "browserTarget": "readme:build:production"
184 | }
185 | }
186 | },
187 | "extract-i18n": {
188 | "builder": "@angular-devkit/build-angular:extract-i18n",
189 | "options": {
190 | "browserTarget": "readme:build"
191 | }
192 | },
193 | "lint": {
194 | "builder": "@angular-devkit/build-angular:tslint",
195 | "options": {
196 | "tsConfig": [
197 | "apps/readme/tsconfig.app.json",
198 | "apps/readme/tsconfig.spec.json"
199 | ],
200 | "exclude": [
201 | "**/node_modules/**",
202 | "!apps/readme/**/*"
203 | ]
204 | }
205 | },
206 | "test": {
207 | "builder": "@nrwl/jest:jest",
208 | "options": {
209 | "jestConfig": "apps/readme/jest.config.js",
210 | "tsConfig": "apps/readme/tsconfig.spec.json",
211 | "passWithNoTests": true,
212 | "setupFile": "apps/readme/src/test-setup.ts"
213 | }
214 | }
215 | }
216 | },
217 | "code-of-conduct": {
218 | "projectType": "application",
219 | "schematics": {
220 | "@nrwl/angular:component": {
221 | "style": "scss"
222 | }
223 | },
224 | "root": "apps/code-of-conduct",
225 | "sourceRoot": "apps/code-of-conduct/src",
226 | "prefix": "code-of-conduct",
227 | "architect": {
228 | "build": {
229 | "builder": "@angular-builders/custom-webpack:browser",
230 | "options": {
231 | "customWebpackConfig": {
232 | "path": "apps/code-of-conduct/extra-webpack.config.js"
233 | },
234 | "outputPath": "dist/apps/main/code-of-conduct/static",
235 | "index": "apps/code-of-conduct/src/index.html",
236 | "main": "apps/code-of-conduct/src/main.ts",
237 | "polyfills": "apps/code-of-conduct/src/polyfills.ts",
238 | "tsConfig": "apps/code-of-conduct/tsconfig.app.json",
239 | "aot": true,
240 | "assets": [
241 | "apps/code-of-conduct/src/favicon.ico",
242 | "apps/code-of-conduct/src/assets"
243 | ],
244 | "styles": [
245 | "apps/code-of-conduct/src/styles.scss"
246 | ],
247 | "scripts": [],
248 | "baseHref": "/code-of-conduct/static/"
249 | },
250 | "configurations": {
251 | "production": {
252 | "fileReplacements": [
253 | {
254 | "replace": "apps/code-of-conduct/src/environments/environment.ts",
255 | "with": "apps/code-of-conduct/src/environments/environment.prod.ts"
256 | }
257 | ],
258 | "optimization": true,
259 | "outputHashing": "all",
260 | "sourceMap": false,
261 | "extractCss": true,
262 | "namedChunks": false,
263 | "extractLicenses": true,
264 | "vendorChunk": false,
265 | "buildOptimizer": true,
266 | "budgets": [
267 | {
268 | "type": "initial",
269 | "maximumWarning": "2mb",
270 | "maximumError": "5mb"
271 | },
272 | {
273 | "type": "anyComponentStyle",
274 | "maximumWarning": "6kb",
275 | "maximumError": "10kb"
276 | }
277 | ]
278 | }
279 | }
280 | },
281 | "serve": {
282 | "builder": "@angular-builders/custom-webpack:dev-server",
283 | "options": {
284 | "browserTarget": "code-of-conduct:build",
285 | "port": 4101
286 | },
287 | "configurations": {
288 | "production": {
289 | "browserTarget": "code-of-conduct:build:production"
290 | }
291 | }
292 | },
293 | "extract-i18n": {
294 | "builder": "@angular-devkit/build-angular:extract-i18n",
295 | "options": {
296 | "browserTarget": "code-of-conduct:build"
297 | }
298 | },
299 | "lint": {
300 | "builder": "@angular-devkit/build-angular:tslint",
301 | "options": {
302 | "tsConfig": [
303 | "apps/code-of-conduct/tsconfig.app.json",
304 | "apps/code-of-conduct/tsconfig.spec.json"
305 | ],
306 | "exclude": [
307 | "**/node_modules/**",
308 | "!apps/code-of-conduct/**/*"
309 | ]
310 | }
311 | },
312 | "test": {
313 | "builder": "@nrwl/jest:jest",
314 | "options": {
315 | "jestConfig": "apps/code-of-conduct/jest.config.js",
316 | "tsConfig": "apps/code-of-conduct/tsconfig.spec.json",
317 | "passWithNoTests": true,
318 | "setupFile": "apps/code-of-conduct/src/test-setup.ts"
319 | }
320 | }
321 | }
322 | }
323 | },
324 | "cli": {
325 | "defaultCollection": "@nrwl/angular",
326 | "analytics": false
327 | },
328 | "schematics": {
329 | "@nrwl/workspace": {
330 | "library": {
331 | "linter": "tslint"
332 | }
333 | },
334 | "@nrwl/cypress": {
335 | "cypress-project": {
336 | "linter": "tslint"
337 | }
338 | },
339 | "@nrwl/node": {
340 | "application": {
341 | "linter": "tslint"
342 | },
343 | "library": {
344 | "linter": "tslint"
345 | }
346 | },
347 | "@nrwl/nest": {
348 | "application": {
349 | "linter": "tslint"
350 | },
351 | "library": {
352 | "linter": "tslint"
353 | }
354 | },
355 | "@nrwl/express": {
356 | "application": {
357 | "linter": "tslint"
358 | },
359 | "library": {
360 | "linter": "tslint"
361 | }
362 | },
363 | "@nrwl/angular:application": {
364 | "unitTestRunner": "jest",
365 | "e2eTestRunner": "cypress"
366 | },
367 | "@nrwl/angular:library": {
368 | "unitTestRunner": "jest"
369 | }
370 | },
371 | "defaultProject": "main"
372 | }
373 |
--------------------------------------------------------------------------------
/apps/code-of-conduct/.browserslistrc:
--------------------------------------------------------------------------------
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 9-10 # Angular support for IE 9-10 has been deprecated and will be removed as of Angular v11. To opt-in, remove the 'not' prefix on this line.
18 | not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.
19 |
--------------------------------------------------------------------------------
/apps/code-of-conduct/extra-webpack.config.js:
--------------------------------------------------------------------------------
1 | const {
2 | SharedLibraryWebpackPlugin,
3 | } = require('@tinkoff/shared-library-webpack-plugin');
4 |
5 | module.exports = {
6 | output: {
7 | jsonpFunction: 'codeOfConductWebpackJsonp',
8 | },
9 | plugins: [
10 | new SharedLibraryWebpackPlugin({
11 | libs: [
12 | { name: '@angular/core', usedExports: [] },
13 | { name: '@angular/common', usedExports: [] },
14 | { name: '@angular/common/http', usedExports: [] },
15 | { name: '@angular/platform-browser', usedExports: ['DomSanitizer'] },
16 | { name: '@angular/platform-browser/animations', usedExports: [] },
17 | { name: '@angular/animations', usedExports: [] },
18 | { name: '@angular/animations/browser', usedExports: [] },
19 | 'zone.js/dist/zone',
20 | ],
21 | }),
22 | ],
23 | };
24 |
--------------------------------------------------------------------------------
/apps/code-of-conduct/jest.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: 'code-of-conduct',
3 | preset: '../../jest.config.js',
4 | setupFilesAfterEnv: ['/src/test-setup.ts'],
5 | globals: {
6 | 'ts-jest': {
7 | tsConfig: '/tsconfig.spec.json',
8 | stringifyContentPathRegex: '\\.(html|svg)$',
9 | astTransformers: [
10 | 'jest-preset-angular/build/InlineFilesTransformer',
11 | 'jest-preset-angular/build/StripStylesTransformer',
12 | ],
13 | },
14 | },
15 | coverageDirectory: '../../coverage/apps/code-of-conduct',
16 | snapshotSerializers: [
17 | 'jest-preset-angular/build/AngularNoNgAttributesSnapshotSerializer.js',
18 | 'jest-preset-angular/build/AngularSnapshotSerializer.js',
19 | 'jest-preset-angular/build/HTMLCommentSerializer.js',
20 | ],
21 | };
22 |
--------------------------------------------------------------------------------
/apps/code-of-conduct/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, async } from '@angular/core/testing';
2 | import { AppComponent } from './app.component';
3 |
4 | describe('AppComponent', () => {
5 | beforeEach(async(() => {
6 | TestBed.configureTestingModule({
7 | declarations: [AppComponent],
8 | }).compileComponents();
9 | }));
10 |
11 | it('should create the app', () => {
12 | const fixture = TestBed.createComponent(AppComponent);
13 | const app = fixture.componentInstance;
14 | expect(app).toBeTruthy();
15 | });
16 |
17 | it(`should have as title 'code-of-conduct'`, () => {
18 | const fixture = TestBed.createComponent(AppComponent);
19 | const app = fixture.componentInstance;
20 | expect(app.title).toEqual('code-of-conduct');
21 | });
22 |
23 | it('should render title', () => {
24 | const fixture = TestBed.createComponent(AppComponent);
25 | fixture.detectChanges();
26 | const compiled = fixture.nativeElement;
27 | expect(compiled.querySelector('h1').textContent).toContain(
28 | 'Welcome to code-of-conduct!'
29 | );
30 | });
31 | });
32 |
--------------------------------------------------------------------------------
/apps/code-of-conduct/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'code-of-conduct-root',
5 | template: `
6 |
7 | Child App
8 |
9 |
10 |
11 |
12 |
13 | `,
14 | styles: [
15 | `
16 | .container {
17 | margin: 20px;
18 | }
19 | `,
20 | ],
21 | })
22 | export class AppComponent {}
23 |
--------------------------------------------------------------------------------
/apps/code-of-conduct/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { NgModule } from '@angular/core';
3 |
4 | import { AppComponent } from './app.component';
5 | import { MatToolbarModule } from '@angular/material/toolbar';
6 | import { MarkdownModule } from 'ngx-markdown';
7 | import { HttpClientModule } from '@angular/common/http';
8 |
9 | @NgModule({
10 | declarations: [AppComponent],
11 | imports: [
12 | BrowserModule,
13 | MatToolbarModule,
14 | HttpClientModule,
15 | MarkdownModule.forRoot(),
16 | ],
17 | providers: [],
18 | bootstrap: [AppComponent],
19 | })
20 | export class AppModule {}
21 |
--------------------------------------------------------------------------------
/apps/code-of-conduct/src/assets/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Contributor Covenant Code of Conduct
2 |
3 | ## Our Pledge
4 |
5 | In the interest of fostering an open and welcoming environment, we as
6 | contributors and maintainers pledge to making participation in our project and
7 | our community a harassment-free experience for everyone, regardless of age, body
8 | size, disability, ethnicity, sex characteristics, gender identity and expression,
9 | level of experience, education, socio-economic status, nationality, personal
10 | appearance, race, religion, or sexual identity and orientation.
11 |
12 | ## Our Standards
13 |
14 | Examples of behavior that contributes to creating a positive environment
15 | include:
16 |
17 | - Using welcoming and inclusive language
18 | - Being respectful of differing viewpoints and experiences
19 | - Gracefully accepting constructive criticism
20 | - Focusing on what is best for the community
21 | - Showing empathy towards other community members
22 |
23 | Examples of unacceptable behavior by participants include:
24 |
25 | - The use of sexualized language or imagery and unwelcome sexual attention or
26 | advances
27 | - Trolling, insulting/derogatory comments, and personal or political attacks
28 | - Public or private harassment
29 | - Publishing others' private information, such as a physical or electronic
30 | address, without explicit permission
31 | - Other conduct which could reasonably be considered inappropriate in a
32 | professional setting
33 |
34 | ## Our Responsibilities
35 |
36 | Project maintainers are responsible for clarifying the standards of acceptable
37 | behavior and are expected to take appropriate and fair corrective action in
38 | response to any instances of unacceptable behavior.
39 |
40 | Project maintainers have the right and responsibility to remove, edit, or
41 | reject comments, commits, code, wiki edits, issues, and other contributions
42 | that are not aligned to this Code of Conduct, or to ban temporarily or
43 | permanently any contributor for other behaviors that they deem inappropriate,
44 | threatening, offensive, or harmful.
45 |
46 | ## Scope
47 |
48 | This Code of Conduct applies both within project spaces and in public spaces
49 | when an individual is representing the project or its community. Examples of
50 | representing a project or community include using an official project e-mail
51 | address, posting via an official social media account, or acting as an appointed
52 | representative at an online or offline event. Representation of a project may be
53 | further defined and clarified by project maintainers.
54 |
55 | ## Enforcement
56 |
57 | Instances of abusive, harassing, or otherwise unacceptable behavior may be
58 | reported by contacting the project team at opensource@tinkoff.ru. All
59 | complaints will be reviewed and investigated and will result in a response that
60 | is deemed necessary and appropriate to the circumstances. The project team is
61 | obligated to maintain confidentiality with regard to the reporter of an incident.
62 | Further details of specific enforcement policies may be posted separately.
63 |
64 | Project maintainers who do not follow or enforce the Code of Conduct in good
65 | faith may face temporary or permanent repercussions as determined by other
66 | members of the project's leadership.
67 |
68 | ## Attribution
69 |
70 | This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71 | available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html
72 |
73 | [homepage]: https://www.contributor-covenant.org
74 |
75 | For answers to common questions about this code of conduct, see
76 | https://www.contributor-covenant.org/faq
77 |
--------------------------------------------------------------------------------
/apps/code-of-conduct/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true,
3 | };
4 |
--------------------------------------------------------------------------------
/apps/code-of-conduct/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // This file can be replaced during build by using the `fileReplacements` array.
2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
3 | // The list of file replacements can be found in `angular.json`.
4 |
5 | export const environment = {
6 | production: false,
7 | };
8 |
9 | /*
10 | * For easier debugging in development mode, you can import the following file
11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
12 | *
13 | * This import should be commented out in production mode because it will have a negative impact
14 | * on performance if an error is thrown.
15 | */
16 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI.
17 |
--------------------------------------------------------------------------------
/apps/code-of-conduct/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IKatsuba/shared-library-plugin-demo/080b96f91f5c172d50298c69e819271a95e0a06b/apps/code-of-conduct/src/favicon.ico
--------------------------------------------------------------------------------
/apps/code-of-conduct/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CODE_OF_CONDUCT.md
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/apps/code-of-conduct/src/main.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core';
2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3 |
4 | import { AppModule } from './app/app.module';
5 | import { environment } from './environments/environment';
6 |
7 | if (environment.production) {
8 | try {
9 | enableProdMode();
10 | } catch (e) {}
11 | }
12 |
13 | platformBrowserDynamic()
14 | .bootstrapModule(AppModule)
15 | .catch((err) => console.error(err));
16 |
--------------------------------------------------------------------------------
/apps/code-of-conduct/src/polyfills.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This file includes polyfills needed by Angular and is loaded before the app.
3 | * You can add your own extra polyfills to this file.
4 | *
5 | * This file is divided into 2 sections:
6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
8 | * file.
9 | *
10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
13 | *
14 | * Learn more in https://angular.io/guide/browser-support
15 | */
16 |
17 | /***************************************************************************************************
18 | * BROWSER POLYFILLS
19 | */
20 |
21 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */
22 | // import 'classlist.js'; // Run `npm install --save classlist.js`.
23 |
24 | /**
25 | * Web Animations `@angular/platform-browser/animations`
26 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
27 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
28 | */
29 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
30 |
31 | /**
32 | * By default, zone.js will patch all possible macroTask and DomEvents
33 | * user can disable parts of macroTask/DomEvents patch by setting following flags
34 | * because those flags need to be set before `zone.js` being loaded, and webpack
35 | * will put import in the top of bundle, so user need to create a separate file
36 | * in this directory (for example: zone-flags.ts), and put the following flags
37 | * into that file, and then add the following code before importing zone.js.
38 | * import './zone-flags';
39 | *
40 | * The flags allowed in zone-flags.ts are listed here.
41 | *
42 | * The following flags will work for all browsers.
43 | *
44 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
45 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
46 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
47 | *
48 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
49 | * with the following flag, it will bypass `zone.js` patch for IE/Edge
50 | *
51 | * (window as any).__Zone_enable_cross_context_check = true;
52 | *
53 | */
54 |
55 | /***************************************************************************************************
56 | * Zone JS is required by default for Angular itself.
57 | */
58 | import 'zone.js/dist/zone'; // Included with Angular CLI.
59 |
60 | /***************************************************************************************************
61 | * APPLICATION IMPORTS
62 | */
63 |
--------------------------------------------------------------------------------
/apps/code-of-conduct/src/styles.scss:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 |
--------------------------------------------------------------------------------
/apps/code-of-conduct/src/test-setup.ts:
--------------------------------------------------------------------------------
1 | import 'jest-preset-angular';
2 |
--------------------------------------------------------------------------------
/apps/code-of-conduct/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../dist/out-tsc",
5 | "types": []
6 | },
7 | "files": ["src/main.ts", "src/polyfills.ts"]
8 | }
9 |
--------------------------------------------------------------------------------
/apps/code-of-conduct/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.base.json",
3 | "files": [],
4 | "include": [],
5 | "references": [
6 | {
7 | "path": "./tsconfig.app.json"
8 | },
9 | {
10 | "path": "./tsconfig.spec.json"
11 | }
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/apps/code-of-conduct/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../dist/out-tsc",
5 | "module": "commonjs",
6 | "types": ["jest", "node"]
7 | },
8 | "files": ["src/test-setup.ts"],
9 | "include": ["**/*.spec.ts", "**/*.d.ts"]
10 | }
11 |
--------------------------------------------------------------------------------
/apps/code-of-conduct/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tslint.json",
3 | "rules": {
4 | "directive-selector": [true, "attribute", "code-of-conduct", "camelCase"],
5 | "component-selector": [true, "element", "code-of-conduct", "kebab-case"]
6 | },
7 | "linterOptions": {
8 | "exclude": ["!**/*"]
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/apps/main/.browserslistrc:
--------------------------------------------------------------------------------
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 9-10 # Angular support for IE 9-10 has been deprecated and will be removed as of Angular v11. To opt-in, remove the 'not' prefix on this line.
18 | not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.
19 |
--------------------------------------------------------------------------------
/apps/main/extra-webpack.config.js:
--------------------------------------------------------------------------------
1 | const {
2 | SharedLibraryWebpackPlugin,
3 | } = require('@tinkoff/shared-library-webpack-plugin');
4 |
5 | module.exports = {
6 | output: {
7 | jsonpFunction: 'mainWebpackJsonp',
8 | },
9 | plugins: [
10 | new SharedLibraryWebpackPlugin({
11 | libs: [
12 | { name: '@angular/core', usedExports: [] },
13 | { name: '@angular/common', usedExports: [] },
14 | { name: '@angular/common/http', usedExports: [] },
15 | { name: '@angular/platform-browser', usedExports: ['DomSanitizer'] },
16 | { name: '@angular/platform-browser/animations', usedExports: [] },
17 | { name: '@angular/animations', usedExports: [] },
18 | { name: '@angular/animations/browser', usedExports: [] },
19 | 'zone.js/dist/zone',
20 | ],
21 | }),
22 | ],
23 | };
24 |
--------------------------------------------------------------------------------
/apps/main/jest.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: 'main',
3 | preset: '../../jest.config.js',
4 | setupFilesAfterEnv: ['/src/test-setup.ts'],
5 | globals: {
6 | 'ts-jest': {
7 | tsConfig: '/tsconfig.spec.json',
8 | stringifyContentPathRegex: '\\.(html|svg)$',
9 | astTransformers: [
10 | 'jest-preset-angular/build/InlineFilesTransformer',
11 | 'jest-preset-angular/build/StripStylesTransformer',
12 | ],
13 | },
14 | },
15 | coverageDirectory: '../../coverage/apps/main',
16 | snapshotSerializers: [
17 | 'jest-preset-angular/build/AngularNoNgAttributesSnapshotSerializer.js',
18 | 'jest-preset-angular/build/AngularSnapshotSerializer.js',
19 | 'jest-preset-angular/build/HTMLCommentSerializer.js',
20 | ],
21 | };
22 |
--------------------------------------------------------------------------------
/apps/main/proxy.conf.json:
--------------------------------------------------------------------------------
1 | {
2 | "/readme/static": {
3 | "target": "http://localhost:4100",
4 | "secure": false
5 | },
6 | "/code-of-conduct/static": {
7 | "target": "http://localhost:4101",
8 | "secure": false
9 | }
10 | }
11 |
--------------------------------------------------------------------------------
/apps/main/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
2 | Host App
3 |
4 |
5 |
6 |
7 |
8 | README.md
9 |
10 |
15 | CODE_OF_CONDUCT.md
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/apps/main/src/app/app.component.scss:
--------------------------------------------------------------------------------
1 | @import "~@angular/material/theming";
2 |
3 | .container {
4 | height: calc(100% - 64px);
5 | }
6 |
7 | mat-toolbar {
8 | position: sticky;
9 | top: 0;
10 | }
11 |
12 | a.active-link[routerLink] {
13 | background-color: map-get($mat-grey, 100);
14 | }
15 |
--------------------------------------------------------------------------------
/apps/main/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, async } from '@angular/core/testing';
2 | import { AppComponent } from './app.component';
3 |
4 | describe('AppComponent', () => {
5 | beforeEach(async(() => {
6 | TestBed.configureTestingModule({
7 | declarations: [AppComponent],
8 | }).compileComponents();
9 | }));
10 |
11 | it('should create the app', () => {
12 | const fixture = TestBed.createComponent(AppComponent);
13 | const app = fixture.componentInstance;
14 | expect(app).toBeTruthy();
15 | });
16 |
17 | it(`should have as title 'main'`, () => {
18 | const fixture = TestBed.createComponent(AppComponent);
19 | const app = fixture.componentInstance;
20 | expect(app.title).toEqual('main');
21 | });
22 |
23 | it('should render title', () => {
24 | const fixture = TestBed.createComponent(AppComponent);
25 | fixture.detectChanges();
26 | const compiled = fixture.nativeElement;
27 | expect(compiled.querySelector('h1').textContent).toContain(
28 | 'Welcome to main!'
29 | );
30 | });
31 | });
32 |
--------------------------------------------------------------------------------
/apps/main/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import {
2 | AfterViewInit,
3 | Component,
4 | ElementRef,
5 | Inject,
6 | ViewChild,
7 | } from '@angular/core';
8 | import { HttpClient } from '@angular/common/http';
9 | import { DOCUMENT } from '@angular/common';
10 | import { Observable } from 'rxjs';
11 | import { APP_FACTORY, AppFactory, APPS } from './app.tokens';
12 |
13 | @Component({
14 | selector: 'main-root',
15 | templateUrl: './app.component.html',
16 | styleUrls: ['./app.component.scss'],
17 | })
18 | export class AppComponent implements AfterViewInit {
19 | title = 'main';
20 |
21 | @ViewChild('container') appContainer: ElementRef;
22 |
23 | constructor(
24 | private http: HttpClient,
25 | @Inject(DOCUMENT) private document: Document,
26 | @Inject(APPS) private apps$: Observable,
27 | @Inject(APP_FACTORY) private appFactory: AppFactory
28 | ) {}
29 |
30 | ngAfterViewInit(): void {
31 | this.apps$
32 | .pipe(this.appFactory(this.appContainer.nativeElement))
33 | .subscribe();
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/apps/main/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { NgModule } from '@angular/core';
3 | import { MatButtonModule } from '@angular/material/button';
4 |
5 | import { AppComponent } from './app.component';
6 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
7 | import { HttpClientModule } from '@angular/common/http';
8 | import { MatSidenavModule } from '@angular/material/sidenav';
9 | import { MatListModule } from '@angular/material/list';
10 | import { MatToolbarModule } from '@angular/material/toolbar';
11 | import { RouterModule } from '@angular/router';
12 | import { BlankComponent } from './blank/blank.component';
13 |
14 | @NgModule({
15 | declarations: [AppComponent, BlankComponent],
16 | imports: [
17 | BrowserModule,
18 | BrowserAnimationsModule,
19 | MatButtonModule,
20 | HttpClientModule,
21 | MatSidenavModule,
22 | MatListModule,
23 | MatToolbarModule,
24 | RouterModule.forRoot([
25 | {
26 | path: '**',
27 | component: BlankComponent
28 | }
29 | ]),
30 | ],
31 | providers: [],
32 | bootstrap: [AppComponent],
33 | })
34 | export class AppModule {}
35 |
--------------------------------------------------------------------------------
/apps/main/src/app/app.tokens.ts:
--------------------------------------------------------------------------------
1 | import { inject, InjectionToken } from '@angular/core';
2 | import { Observable, OperatorFunction } from 'rxjs';
3 | import { NavigationEnd, Router } from '@angular/router';
4 | import {
5 | distinctUntilChanged,
6 | filter,
7 | map,
8 | mapTo,
9 | switchMap,
10 | tap,
11 | } from 'rxjs/operators';
12 | import { HttpClient } from '@angular/common/http';
13 | import { DOCUMENT } from '@angular/common';
14 |
15 | export const APPS = new InjectionToken>('Apps', {
16 | providedIn: 'root',
17 | factory() {
18 | const router = inject(Router);
19 |
20 | return router.events.pipe(
21 | filter((event) => event instanceof NavigationEnd),
22 | map((event: NavigationEnd) => event.url.replace('/', '')),
23 | filter(Boolean),
24 | distinctUntilChanged()
25 | );
26 | },
27 | });
28 |
29 | export type AppFactory = (
30 | container: HTMLElement
31 | ) => OperatorFunction;
32 |
33 | export const APP_FACTORY = new InjectionToken('App initialize', {
34 | providedIn: 'root',
35 | factory() {
36 | const http = inject(HttpClient);
37 | const document = inject(DOCUMENT);
38 |
39 | return function runApp(container: HTMLElement) {
40 | return (source: Observable) =>
41 | source.pipe(
42 | switchMap((app) =>
43 | http
44 | .get(`/${app}/static/index.html`, { responseType: 'text' })
45 | .pipe(
46 | map((html) =>
47 | new DOMParser().parseFromString(html, 'text/html')
48 | ),
49 | tap((doc: Document) => {
50 | const base = doc.querySelector('base');
51 |
52 | document.querySelector('base').href = base.href;
53 |
54 | const root = document.createElement(`${app}-root`);
55 |
56 | container.innerHTML = '';
57 | container.appendChild(root);
58 |
59 | Array.from(doc.querySelectorAll('script')).forEach(
60 | (originalScript) => {
61 | const script = document.createElement('script');
62 | script.defer = true;
63 | script.src = originalScript.src;
64 |
65 | document.body.appendChild(script);
66 | }
67 | );
68 | }),
69 | mapTo(undefined)
70 | )
71 | )
72 | );
73 | };
74 | },
75 | });
76 |
--------------------------------------------------------------------------------
/apps/main/src/app/blank/blank.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { async, ComponentFixture, TestBed } from '@angular/core/testing';
2 |
3 | import { BlankComponent } from './blank.component';
4 |
5 | describe('BlankComponent', () => {
6 | let component: BlankComponent;
7 | let fixture: ComponentFixture;
8 |
9 | beforeEach(async(() => {
10 | TestBed.configureTestingModule({
11 | declarations: [ BlankComponent ]
12 | })
13 | .compileComponents();
14 | }));
15 |
16 | beforeEach(() => {
17 | fixture = TestBed.createComponent(BlankComponent);
18 | component = fixture.componentInstance;
19 | fixture.detectChanges();
20 | });
21 |
22 | it('should create', () => {
23 | expect(component).toBeTruthy();
24 | });
25 | });
26 |
--------------------------------------------------------------------------------
/apps/main/src/app/blank/blank.component.ts:
--------------------------------------------------------------------------------
1 | import { Component, OnInit } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'main-blank',
5 | template: '',
6 | })
7 | export class BlankComponent implements OnInit {
8 | constructor() {
9 | }
10 |
11 | ngOnInit(): void {
12 | }
13 | }
14 |
--------------------------------------------------------------------------------
/apps/main/src/assets/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IKatsuba/shared-library-plugin-demo/080b96f91f5c172d50298c69e819271a95e0a06b/apps/main/src/assets/.gitkeep
--------------------------------------------------------------------------------
/apps/main/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true,
3 | };
4 |
--------------------------------------------------------------------------------
/apps/main/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // This file can be replaced during build by using the `fileReplacements` array.
2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
3 | // The list of file replacements can be found in `angular.json`.
4 |
5 | export const environment = {
6 | production: false,
7 | };
8 |
9 | /*
10 | * For easier debugging in development mode, you can import the following file
11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
12 | *
13 | * This import should be commented out in production mode because it will have a negative impact
14 | * on performance if an error is thrown.
15 | */
16 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI.
17 |
--------------------------------------------------------------------------------
/apps/main/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IKatsuba/shared-library-plugin-demo/080b96f91f5c172d50298c69e819271a95e0a06b/apps/main/src/favicon.ico
--------------------------------------------------------------------------------
/apps/main/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Main app
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
--------------------------------------------------------------------------------
/apps/main/src/main.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core';
2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3 |
4 | import { AppModule } from './app/app.module';
5 | import { environment } from './environments/environment';
6 |
7 | if (environment.production) {
8 | enableProdMode();
9 | }
10 |
11 | platformBrowserDynamic()
12 | .bootstrapModule(AppModule)
13 | .catch((err) => console.error(err));
14 |
--------------------------------------------------------------------------------
/apps/main/src/polyfills.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This file includes polyfills needed by Angular and is loaded before the app.
3 | * You can add your own extra polyfills to this file.
4 | *
5 | * This file is divided into 2 sections:
6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
8 | * file.
9 | *
10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
13 | *
14 | * Learn more in https://angular.io/guide/browser-support
15 | */
16 |
17 | /***************************************************************************************************
18 | * BROWSER POLYFILLS
19 | */
20 |
21 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */
22 | // import 'classlist.js'; // Run `npm install --save classlist.js`.
23 |
24 | /**
25 | * Web Animations `@angular/platform-browser/animations`
26 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
27 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
28 | */
29 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
30 |
31 | /**
32 | * By default, zone.js will patch all possible macroTask and DomEvents
33 | * user can disable parts of macroTask/DomEvents patch by setting following flags
34 | * because those flags need to be set before `zone.js` being loaded, and webpack
35 | * will put import in the top of bundle, so user need to create a separate file
36 | * in this directory (for example: zone-flags.ts), and put the following flags
37 | * into that file, and then add the following code before importing zone.js.
38 | * import './zone-flags';
39 | *
40 | * The flags allowed in zone-flags.ts are listed here.
41 | *
42 | * The following flags will work for all browsers.
43 | *
44 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
45 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
46 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
47 | *
48 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
49 | * with the following flag, it will bypass `zone.js` patch for IE/Edge
50 | *
51 | * (window as any).__Zone_enable_cross_context_check = true;
52 | *
53 | */
54 |
55 | /***************************************************************************************************
56 | * Zone JS is required by default for Angular itself.
57 | */
58 | import 'zone.js/dist/zone'; // Included with Angular CLI.
59 |
60 | /***************************************************************************************************
61 | * APPLICATION IMPORTS
62 | */
63 |
--------------------------------------------------------------------------------
/apps/main/src/styles.scss:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 |
3 | html, body { height: 100%; }
4 | body { margin: 0; font-family: Roboto, "Helvetica Neue", sans-serif; }
5 |
--------------------------------------------------------------------------------
/apps/main/src/test-setup.ts:
--------------------------------------------------------------------------------
1 | import 'jest-preset-angular';
2 |
--------------------------------------------------------------------------------
/apps/main/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../dist/out-tsc",
5 | "types": []
6 | },
7 | "files": ["src/main.ts", "src/polyfills.ts"]
8 | }
9 |
--------------------------------------------------------------------------------
/apps/main/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.base.json",
3 | "files": [],
4 | "include": [],
5 | "references": [
6 | {
7 | "path": "./tsconfig.app.json"
8 | },
9 | {
10 | "path": "./tsconfig.spec.json"
11 | }
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/apps/main/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../dist/out-tsc",
5 | "module": "commonjs",
6 | "types": ["jest", "node"]
7 | },
8 | "files": ["src/test-setup.ts"],
9 | "include": ["**/*.spec.ts", "**/*.d.ts"]
10 | }
11 |
--------------------------------------------------------------------------------
/apps/main/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tslint.json",
3 | "rules": {
4 | "directive-selector": [
5 | true,
6 | "attribute",
7 | "main",
8 | "camelCase"
9 | ],
10 | "component-selector": [
11 | true,
12 | "element",
13 | "main",
14 | "kebab-case"
15 | ]
16 | },
17 | "linterOptions": {
18 | "exclude": ["!**/*"]
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/apps/readme/.browserslistrc:
--------------------------------------------------------------------------------
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 9-10 # Angular support for IE 9-10 has been deprecated and will be removed as of Angular v11. To opt-in, remove the 'not' prefix on this line.
18 | not IE 11 # Angular supports IE 11 only as an opt-in. To opt-in, remove the 'not' prefix on this line.
19 |
--------------------------------------------------------------------------------
/apps/readme/extra-webpack.config.js:
--------------------------------------------------------------------------------
1 | const {
2 | SharedLibraryWebpackPlugin,
3 | } = require('@tinkoff/shared-library-webpack-plugin');
4 |
5 | module.exports = {
6 | output: {
7 | jsonpFunction: 'readmeWebpackJsonp',
8 | },
9 | plugins: [
10 | new SharedLibraryWebpackPlugin({
11 | libs: [
12 | { name: '@angular/core', usedExports: [] },
13 | { name: '@angular/common', usedExports: [] },
14 | { name: '@angular/common/http', usedExports: [] },
15 | { name: '@angular/platform-browser', usedExports: ['DomSanitizer'] },
16 | { name: '@angular/platform-browser/animations', usedExports: [] },
17 | { name: '@angular/animations', usedExports: [] },
18 | { name: '@angular/animations/browser', usedExports: [] },
19 | 'zone.js/dist/zone',
20 | ],
21 | }),
22 | ],
23 | };
24 |
--------------------------------------------------------------------------------
/apps/readme/jest.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | name: 'readme',
3 | preset: '../../jest.config.js',
4 | setupFilesAfterEnv: ['/src/test-setup.ts'],
5 | globals: {
6 | 'ts-jest': {
7 | tsConfig: '/tsconfig.spec.json',
8 | stringifyContentPathRegex: '\\.(html|svg)$',
9 | astTransformers: [
10 | 'jest-preset-angular/build/InlineFilesTransformer',
11 | 'jest-preset-angular/build/StripStylesTransformer',
12 | ],
13 | },
14 | },
15 | coverageDirectory: '../../coverage/apps/readme',
16 | snapshotSerializers: [
17 | 'jest-preset-angular/build/AngularNoNgAttributesSnapshotSerializer.js',
18 | 'jest-preset-angular/build/AngularSnapshotSerializer.js',
19 | 'jest-preset-angular/build/HTMLCommentSerializer.js',
20 | ],
21 | };
22 |
--------------------------------------------------------------------------------
/apps/readme/src/app/app.component.html:
--------------------------------------------------------------------------------
1 |
2 | Child App
3 |
4 |
5 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/apps/readme/src/app/app.component.scss:
--------------------------------------------------------------------------------
1 | .container {
2 | margin: 20px;
3 | }
4 |
--------------------------------------------------------------------------------
/apps/readme/src/app/app.component.spec.ts:
--------------------------------------------------------------------------------
1 | import { TestBed, async } from '@angular/core/testing';
2 | import { AppComponent } from './app.component';
3 |
4 | describe('AppComponent', () => {
5 | beforeEach(async(() => {
6 | TestBed.configureTestingModule({
7 | declarations: [AppComponent],
8 | }).compileComponents();
9 | }));
10 |
11 | it('should create the app', () => {
12 | const fixture = TestBed.createComponent(AppComponent);
13 | const app = fixture.componentInstance;
14 | expect(app).toBeTruthy();
15 | });
16 |
17 | it(`should have as title 'readme'`, () => {
18 | const fixture = TestBed.createComponent(AppComponent);
19 | const app = fixture.componentInstance;
20 | expect(app.title).toEqual('readme');
21 | });
22 |
23 | it('should render title', () => {
24 | const fixture = TestBed.createComponent(AppComponent);
25 | fixture.detectChanges();
26 | const compiled = fixture.nativeElement;
27 | expect(compiled.querySelector('h1').textContent).toContain(
28 | 'Welcome to readme!'
29 | );
30 | });
31 | });
32 |
--------------------------------------------------------------------------------
/apps/readme/src/app/app.component.ts:
--------------------------------------------------------------------------------
1 | import { Component } from '@angular/core';
2 |
3 | @Component({
4 | selector: 'readme-root',
5 | templateUrl: './app.component.html',
6 | styleUrls: ['./app.component.scss'],
7 | })
8 | export class AppComponent {
9 | }
10 |
--------------------------------------------------------------------------------
/apps/readme/src/app/app.module.ts:
--------------------------------------------------------------------------------
1 | import { BrowserModule } from '@angular/platform-browser';
2 | import { NgModule } from '@angular/core';
3 | import { MatButtonModule } from '@angular/material/button';
4 | import { ClipboardModule } from '@angular/cdk/clipboard';
5 | import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
6 |
7 | import { AppComponent } from './app.component';
8 | import { MarkdownModule } from 'ngx-markdown';
9 | import { HttpClientModule } from '@angular/common/http';
10 | import { MatToolbarModule } from '@angular/material/toolbar';
11 |
12 | @NgModule({
13 | declarations: [AppComponent],
14 | imports: [
15 | BrowserModule,
16 | BrowserAnimationsModule,
17 | HttpClientModule,
18 | MatButtonModule,
19 | ClipboardModule,
20 | MarkdownModule.forRoot(),
21 | MatToolbarModule,
22 | ],
23 | bootstrap: [AppComponent],
24 | })
25 | export class AppModule {}
26 |
--------------------------------------------------------------------------------
/apps/readme/src/assets/README.md:
--------------------------------------------------------------------------------
1 | # SharedLibraryWebpackPlugin
2 |
3 | SharedLibraryWebpackPlugin предназначен для шаринга библиотек между приложениями в рантайме.
4 |
5 | ## Мотивация
6 |
7 | При загрузке нескольких бандлов разных приложений встал вопрос о минимизации размеров этих бандлов.
8 | Так как бандлы имели очень много одинаковых зависимостей, логично вынести и поставлять их отдельно.
9 |
10 | После ряда исследований было принято решение о создании плагина для Webpack 4, который решает следующие проблемы:
11 |
12 | 1. Приложения остаются самодостаточным и автономными (т.е. не меняется механизм загрузки и почти не меняется сборка)
13 | 2. Самостоятельная загрузка недостающих модулей
14 | 3. Шаринг кода в рантайме
15 | 4. Разные версии библиотек работают независимо друг от друга
16 |
17 | ## Установка и пример конфигурации
18 |
19 | Добавляем плагин в зависимости `package.json`:
20 |
21 | ```
22 | npm install @tinkoff/shared-library-webpack-plugin -D
23 | ```
24 |
25 | Добавляем плагин в конфигурацию webpack
26 |
27 | ```typescript
28 | {
29 | plugins: [
30 | ...,
31 | new SharedLibraryWebpackPlugin({
32 | libs: ['lodash']
33 | }),
34 | ...
35 | ]
36 | }
37 | ```
38 |
39 | Сборки приложения с такой конфигурацией плагина будет содержать
40 | отдельный чанк с библиотекой lodash. Чанк будет загружен в случае,
41 | если lodash не был загружен ранее при инициализации другого приложения
42 | с подобной конфигурацией.
43 |
44 | ## Так что же делает плагин?
45 |
46 | Плагин вносит коррективы как в процесс сборки приложения (buildtime), так и в процесс запуска и проигрывания приложения (runtime).
47 |
48 | ### Buildtime
49 |
50 | 1. Происходит анализ сформированных чанков на наличие указанных библиотек.
51 | Каждая из найденных библиотек выделяется в отдельный чанк с отключением tree shaking(!).
52 | Все выделенные чанки с точки зрения webpack существуют сами по себе и не привязываются к entry points.
53 | 2. Модифицируется webpack runtime для записи и чтения результата выполнения и загрузки выделенных библиотек.
54 | 3. Модифицируется стандартная обертка entry points для проверки на уже существующие в runtime библиотеки.
55 |
56 | ### Runtime
57 |
58 | 1. Загружается entry points приложения
59 | 2. При загрузке entry point происходит проверка на загрузку зависимых библиотек.
60 | 3. Затем загружаются только недостающие библиотеки.
61 | 4. Загруженные выделенные библиотеки экспортируются в общий неймспейс в глобальном пространстве.
62 | 5. Инициализация entry points (запуск приложения)
63 |
64 | ## Шаринг библиотек с разными версиями
65 |
66 | По умолчанию мы считаем, что все разработчики библиотек придерживаются semantic release. На основе этого соглашения можно предположить, что при шаринге нужно учитывать лишь мажор, минор и пререлизные версии. Именно такой шаблон {major}.{minor}-{prerelease} будет использоваться по умолчанию при поиске в runtime заруженного аналога используемой в entry point библиотеки.
67 |
68 | ### Что это значит?
69 |
70 | Допустим, что одно из приложений поставляет `lodash`, как библиотеку которую можно переиспользовать, если она уже загружена.
71 |
72 | ```typescript
73 | {
74 | plugins: [
75 | ...,
76 | new SharedLibraryWebpackPlugin({
77 | libs: 'lodash'
78 | }),
79 | ...
80 | ]
81 | }
82 | ```
83 |
84 | При сборке будет выделен соответствующий чанк с названием `lodash-4.16.js`, который содержит
85 | выделенную библиотеку. В название чанка была включена версия библиотеки без учета патча.
86 |
87 | Второе приложение имеет такую же конфигурацию, но отличную версию `lodash`. При сборке выделяется чанк с названием `lodash-4.17.js`.
88 |
89 | При загрузке первого приложения будет загружен чанк `lodash-4.16.js`, так как очевидно `lodash` еще не загружался.
90 | При этом будут проставлены метки, что чанк загружен и результат экспорта будет записан в глобальный неймспейс,
91 | откуда он будет импортироваться следующими приложениями, имеющими аналогичную настройку.
92 |
93 | При загрузке второго приложения в runtime будут проверен глобальный неймспейс на факт загрузки `lodash@4.17.x`,
94 | но неймспейс не будет содержать ничего, кроме `lodash@4.16.x`. Но как было описано выше по умолчанию разница в миноре
95 | считается несовместимой. По этому второе приложение так же загрузит lodash, но свою версию и будет при работе
96 | использовать только ее.
97 |
98 | Для изменения дефолтного поведения в конфигурации можно указать `suffix`, который заменит стандартный шаблон с версией пакета.
99 |
100 | ```typescript
101 | {
102 | plugins: [
103 | ...,
104 | new SharedLibraryWebpackPlugin({
105 | libs: {name: 'lodash', suffix: 'someSuffix'}
106 | }),
107 | ...
108 | ]
109 | }
110 | ```
111 |
112 | В этом случае при сборке будет выделен чанк `lodash-someSuffix.js`. При загрузке двух приложений, использующих такой
113 | конфиг `lodash` будет загружен один раз и переиспользован обоими приложениями,
114 | даже если приложения имеют разные версии `lodash` в зависимостях.
115 |
--------------------------------------------------------------------------------
/apps/readme/src/environments/environment.prod.ts:
--------------------------------------------------------------------------------
1 | export const environment = {
2 | production: true,
3 | };
4 |
--------------------------------------------------------------------------------
/apps/readme/src/environments/environment.ts:
--------------------------------------------------------------------------------
1 | // This file can be replaced during build by using the `fileReplacements` array.
2 | // `ng build --prod` replaces `environment.ts` with `environment.prod.ts`.
3 | // The list of file replacements can be found in `angular.json`.
4 |
5 | export const environment = {
6 | production: false,
7 | };
8 |
9 | /*
10 | * For easier debugging in development mode, you can import the following file
11 | * to ignore zone related error stack frames such as `zone.run`, `zoneDelegate.invokeTask`.
12 | *
13 | * This import should be commented out in production mode because it will have a negative impact
14 | * on performance if an error is thrown.
15 | */
16 | // import 'zone.js/dist/zone-error'; // Included with Angular CLI.
17 |
--------------------------------------------------------------------------------
/apps/readme/src/favicon.ico:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IKatsuba/shared-library-plugin-demo/080b96f91f5c172d50298c69e819271a95e0a06b/apps/readme/src/favicon.ico
--------------------------------------------------------------------------------
/apps/readme/src/index.html:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | README.md
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
--------------------------------------------------------------------------------
/apps/readme/src/main.ts:
--------------------------------------------------------------------------------
1 | import { enableProdMode } from '@angular/core';
2 | import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
3 |
4 | import { AppModule } from './app/app.module';
5 | import { environment } from './environments/environment';
6 |
7 | if (environment.production) {
8 | try {
9 | enableProdMode();
10 | } catch (e) {}
11 | }
12 |
13 | platformBrowserDynamic()
14 | .bootstrapModule(AppModule)
15 | .catch((err) => console.error(err));
16 |
--------------------------------------------------------------------------------
/apps/readme/src/polyfills.ts:
--------------------------------------------------------------------------------
1 | /**
2 | * This file includes polyfills needed by Angular and is loaded before the app.
3 | * You can add your own extra polyfills to this file.
4 | *
5 | * This file is divided into 2 sections:
6 | * 1. Browser polyfills. These are applied before loading ZoneJS and are sorted by browsers.
7 | * 2. Application imports. Files imported after ZoneJS that should be loaded before your main
8 | * file.
9 | *
10 | * The current setup is for so-called "evergreen" browsers; the last versions of browsers that
11 | * automatically update themselves. This includes Safari >= 10, Chrome >= 55 (including Opera),
12 | * Edge >= 13 on the desktop, and iOS 10 and Chrome on mobile.
13 | *
14 | * Learn more in https://angular.io/guide/browser-support
15 | */
16 |
17 | /***************************************************************************************************
18 | * BROWSER POLYFILLS
19 | */
20 |
21 | /** IE10 and IE11 requires the following for NgClass support on SVG elements */
22 | // import 'classlist.js'; // Run `npm install --save classlist.js`.
23 |
24 | /**
25 | * Web Animations `@angular/platform-browser/animations`
26 | * Only required if AnimationBuilder is used within the application and using IE/Edge or Safari.
27 | * Standard animation support in Angular DOES NOT require any polyfills (as of Angular 6.0).
28 | */
29 | // import 'web-animations-js'; // Run `npm install --save web-animations-js`.
30 |
31 | /**
32 | * By default, zone.js will patch all possible macroTask and DomEvents
33 | * user can disable parts of macroTask/DomEvents patch by setting following flags
34 | * because those flags need to be set before `zone.js` being loaded, and webpack
35 | * will put import in the top of bundle, so user need to create a separate file
36 | * in this directory (for example: zone-flags.ts), and put the following flags
37 | * into that file, and then add the following code before importing zone.js.
38 | * import './zone-flags';
39 | *
40 | * The flags allowed in zone-flags.ts are listed here.
41 | *
42 | * The following flags will work for all browsers.
43 | *
44 | * (window as any).__Zone_disable_requestAnimationFrame = true; // disable patch requestAnimationFrame
45 | * (window as any).__Zone_disable_on_property = true; // disable patch onProperty such as onclick
46 | * (window as any).__zone_symbol__UNPATCHED_EVENTS = ['scroll', 'mousemove']; // disable patch specified eventNames
47 | *
48 | * in IE/Edge developer tools, the addEventListener will also be wrapped by zone.js
49 | * with the following flag, it will bypass `zone.js` patch for IE/Edge
50 | *
51 | * (window as any).__Zone_enable_cross_context_check = true;
52 | *
53 | */
54 |
55 | /***************************************************************************************************
56 | * Zone JS is required by default for Angular itself.
57 | */
58 | import 'zone.js/dist/zone'; // Included with Angular CLI.
59 |
60 | /***************************************************************************************************
61 | * APPLICATION IMPORTS
62 | */
63 |
--------------------------------------------------------------------------------
/apps/readme/src/styles.scss:
--------------------------------------------------------------------------------
1 | /* You can add global styles to this file, and also import other style files */
2 |
--------------------------------------------------------------------------------
/apps/readme/src/test-setup.ts:
--------------------------------------------------------------------------------
1 | import 'jest-preset-angular';
2 |
--------------------------------------------------------------------------------
/apps/readme/tsconfig.app.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../dist/out-tsc",
5 | "types": []
6 | },
7 | "files": ["src/main.ts", "src/polyfills.ts"]
8 | }
9 |
--------------------------------------------------------------------------------
/apps/readme/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tsconfig.base.json",
3 | "files": [],
4 | "include": [],
5 | "references": [
6 | {
7 | "path": "./tsconfig.app.json"
8 | },
9 | {
10 | "path": "./tsconfig.spec.json"
11 | }
12 | ]
13 | }
14 |
--------------------------------------------------------------------------------
/apps/readme/tsconfig.spec.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "./tsconfig.json",
3 | "compilerOptions": {
4 | "outDir": "../../dist/out-tsc",
5 | "module": "commonjs",
6 | "types": ["jest", "node"]
7 | },
8 | "files": ["src/test-setup.ts"],
9 | "include": ["**/*.spec.ts", "**/*.d.ts"]
10 | }
11 |
--------------------------------------------------------------------------------
/apps/readme/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../../tslint.json",
3 | "rules": {
4 | "directive-selector": [
5 | true,
6 | "attribute",
7 | "readme",
8 | "camelCase"
9 | ],
10 | "component-selector": [
11 | true,
12 | "element",
13 | "readme",
14 | "kebab-case"
15 | ]
16 | },
17 | "linterOptions": {
18 | "exclude": ["!**/*"]
19 | }
20 | }
21 |
--------------------------------------------------------------------------------
/jest.config.js:
--------------------------------------------------------------------------------
1 | module.exports = {
2 | testMatch: ['**/+(*.)+(spec|test).+(ts|js)?(x)'],
3 | transform: {
4 | '^.+\\.(ts|js|html)$': 'ts-jest',
5 | },
6 | resolver: '@nrwl/jest/plugins/resolver',
7 | moduleFileExtensions: ['ts', 'js', 'html'],
8 | coverageReporters: ['html'],
9 | };
10 |
--------------------------------------------------------------------------------
/libs/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IKatsuba/shared-library-plugin-demo/080b96f91f5c172d50298c69e819271a95e0a06b/libs/.gitkeep
--------------------------------------------------------------------------------
/nx.json:
--------------------------------------------------------------------------------
1 | {
2 | "npmScope": "shared-library-plugin-demo",
3 | "affected": {
4 | "defaultBase": "master"
5 | },
6 | "implicitDependencies": {
7 | "angular.json": "*",
8 | "package.json": {
9 | "dependencies": "*",
10 | "devDependencies": "*"
11 | },
12 | "tsconfig.base.json": "*",
13 | "tslint.json": "*",
14 | "nx.json": "*"
15 | },
16 | "tasksRunnerOptions": {
17 | "default": {
18 | "runner": "@nrwl/workspace/tasks-runners/default",
19 | "options": {
20 | "cacheableOperations": ["build", "lint", "test", "e2e"]
21 | }
22 | }
23 | },
24 | "projects": {
25 | "main": {
26 | "tags": []
27 | },
28 | "readme": {
29 | "tags": []
30 | },
31 | "code-of-conduct": {
32 | "tags": []
33 | }
34 | }
35 | }
36 |
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "shared-library-plugin-demo",
3 | "version": "0.0.0",
4 | "license": "MIT",
5 | "scripts": {
6 | "ng": "ng",
7 | "nx": "nx",
8 | "start": "npm run target serve -- --parallel",
9 | "target": "nx run-many --all --target",
10 | "build": "nx build main --prod && nx build readme --prod && nx build code-of-conduct --prod && npm run compress",
11 | "compress": "gzipper compress ./dist",
12 | "test": "ng test",
13 | "lint": "nx workspace-lint && ng lint",
14 | "e2e": "ng e2e",
15 | "affected:apps": "nx affected:apps",
16 | "affected:libs": "nx affected:libs",
17 | "affected:build": "nx affected:build",
18 | "affected:e2e": "nx affected:e2e",
19 | "affected:test": "nx affected:test",
20 | "affected:lint": "nx affected:lint",
21 | "affected:dep-graph": "nx affected:dep-graph",
22 | "affected": "nx affected",
23 | "format": "nx format:write",
24 | "format:write": "nx format:write",
25 | "format:check": "nx format:check",
26 | "update": "ng update @nrwl/workspace",
27 | "workspace-schematic": "nx workspace-schematic",
28 | "dep-graph": "nx dep-graph",
29 | "help": "nx help",
30 | "http2": "ws -d dist/apps/main --spa index.html -p 3002 --http2",
31 | "serve": "npm run http2"
32 | },
33 | "private": true,
34 | "dependencies": {
35 | "@angular/animations": "^10.0.0",
36 | "@angular/cdk": "^10.1.3",
37 | "@angular/common": "^10.0.0",
38 | "@angular/compiler": "^10.0.0",
39 | "@angular/core": "^10.0.0",
40 | "@angular/forms": "^10.0.0",
41 | "@angular/material": "^10.1.3",
42 | "@angular/platform-browser": "^10.0.0",
43 | "@angular/platform-browser-dynamic": "^10.0.0",
44 | "@angular/router": "^10.0.0",
45 | "@nrwl/angular": "10.0.12",
46 | "ngx-markdown": "^10.1.1",
47 | "rxjs": "~6.5.5",
48 | "zone.js": "^0.10.2"
49 | },
50 | "devDependencies": {
51 | "@angular-builders/custom-webpack": "^10.0.0",
52 | "@angular-devkit/build-angular": "~0.1000.0",
53 | "@angular/cli": "~10.0.0",
54 | "@angular/compiler-cli": "^10.0.0",
55 | "@angular/language-service": "^10.0.0",
56 | "@nrwl/cypress": "10.0.12",
57 | "@nrwl/jest": "10.0.12",
58 | "@nrwl/workspace": "10.0.12",
59 | "@tinkoff/shared-library-webpack-plugin": "^1.0.0",
60 | "@types/jest": "25.1.4",
61 | "@types/node": "~8.9.4",
62 | "codelyzer": "~5.0.1",
63 | "cypress": "^4.1.0",
64 | "dotenv": "6.2.0",
65 | "eslint": "6.8.0",
66 | "gzipper": "^4.0.1",
67 | "jest": "25.2.3",
68 | "jest-preset-angular": "8.1.2",
69 | "local-web-server": "^4.2.1",
70 | "prettier": "2.0.4",
71 | "ts-jest": "25.2.1",
72 | "ts-node": "~7.0.0",
73 | "tslint": "~6.0.0",
74 | "typescript": "~3.9.3"
75 | }
76 | }
77 |
--------------------------------------------------------------------------------
/tools/schematics/.gitkeep:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/IKatsuba/shared-library-plugin-demo/080b96f91f5c172d50298c69e819271a95e0a06b/tools/schematics/.gitkeep
--------------------------------------------------------------------------------
/tools/tsconfig.tools.json:
--------------------------------------------------------------------------------
1 | {
2 | "extends": "../tsconfig.base.json",
3 | "compilerOptions": {
4 | "outDir": "../dist/out-tsc/tools",
5 | "rootDir": ".",
6 | "module": "commonjs",
7 | "target": "es5",
8 | "types": ["node"]
9 | },
10 | "include": ["**/*.ts"]
11 | }
12 |
--------------------------------------------------------------------------------
/tsconfig.base.json:
--------------------------------------------------------------------------------
1 | {
2 | "compileOnSave": false,
3 | "compilerOptions": {
4 | "rootDir": ".",
5 | "sourceMap": true,
6 | "declaration": false,
7 | "moduleResolution": "node",
8 | "emitDecoratorMetadata": true,
9 | "experimentalDecorators": true,
10 | "importHelpers": true,
11 | "target": "es2015",
12 | "module": "esnext",
13 | "typeRoots": ["node_modules/@types"],
14 | "lib": ["es2017", "dom"],
15 | "skipLibCheck": true,
16 | "skipDefaultLibCheck": true,
17 | "baseUrl": ".",
18 | "paths": {}
19 | },
20 | "exclude": ["node_modules", "tmp"]
21 | }
22 |
--------------------------------------------------------------------------------
/tslint.json:
--------------------------------------------------------------------------------
1 | {
2 | "rulesDirectory": [
3 | "node_modules/@nrwl/workspace/src/tslint",
4 | "node_modules/codelyzer"
5 | ],
6 | "linterOptions": {
7 | "exclude": ["**/*"]
8 | },
9 | "rules": {
10 | "arrow-return-shorthand": true,
11 | "callable-types": true,
12 | "class-name": true,
13 | "deprecation": {
14 | "severity": "warn"
15 | },
16 | "forin": true,
17 | "import-blacklist": [true, "rxjs/Rx"],
18 | "interface-over-type-literal": true,
19 | "member-access": false,
20 | "member-ordering": [
21 | true,
22 | {
23 | "order": [
24 | "static-field",
25 | "instance-field",
26 | "static-method",
27 | "instance-method"
28 | ]
29 | }
30 | ],
31 | "no-arg": true,
32 | "no-bitwise": true,
33 | "no-console": [true, "debug", "info", "time", "timeEnd", "trace"],
34 | "no-construct": true,
35 | "no-debugger": true,
36 | "no-duplicate-super": true,
37 | "no-empty": false,
38 | "no-empty-interface": true,
39 | "no-eval": true,
40 | "no-inferrable-types": [true, "ignore-params"],
41 | "no-misused-new": true,
42 | "no-non-null-assertion": true,
43 | "no-shadowed-variable": true,
44 | "no-string-literal": false,
45 | "no-string-throw": true,
46 | "no-switch-case-fall-through": true,
47 | "no-unnecessary-initializer": true,
48 | "no-unused-expression": true,
49 | "no-var-keyword": true,
50 | "object-literal-sort-keys": false,
51 | "prefer-const": true,
52 | "radix": true,
53 | "triple-equals": [true, "allow-null-check"],
54 | "unified-signatures": true,
55 | "variable-name": false,
56 | "nx-enforce-module-boundaries": [
57 | true,
58 | {
59 | "enforceBuildableLibDependency": true,
60 | "allow": [],
61 | "depConstraints": [
62 | {
63 | "sourceTag": "*",
64 | "onlyDependOnLibsWithTags": ["*"]
65 | }
66 | ]
67 | }
68 | ],
69 | "directive-selector": [true, "attribute", "app", "camelCase"],
70 | "component-selector": [true, "element", "app", "kebab-case"],
71 | "no-conflicting-lifecycle": true,
72 | "no-host-metadata-property": true,
73 | "no-input-rename": true,
74 | "no-inputs-metadata-property": true,
75 | "no-output-native": true,
76 | "no-output-on-prefix": true,
77 | "no-output-rename": true,
78 | "no-outputs-metadata-property": true,
79 | "template-banana-in-box": true,
80 | "template-no-negated-async": true,
81 | "use-lifecycle-interface": true,
82 | "use-pipe-transform-interface": true
83 | }
84 | }
85 |
--------------------------------------------------------------------------------