| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 32050ca commit bacecf4
3 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,11 +1,21 @@ | |||
| 1 | - import { writeFile } from '../../../utils/fs'; | ||
| 1 | + import { expectFileToMatch, writeMultipleFiles } from '../../../utils/fs'; | ||
| 2 | 2 | import { ng } from '../../../utils/process'; | |
| 3 | 3 | import { updateJsonFile } from '../../../utils/project'; | |
| 4 | 4 | ||
| 5 | 5 | export default async function () { | |
| 6 | 6 | await ng('generate', 'library', 'my-lib'); | |
| 7 | 7 | ||
| 8 | - await writeFile('./src/app/app.module.ts', ` | ||
| 8 | + // Force an external template | ||
| 9 | + await writeMultipleFiles({ | ||
| 10 | + 'projects/my-lib/src/lib/my-lib.component.html': `<p>my-lib works!</p>`, | ||
| 11 | + 'projects/my-lib/src/lib/my-lib.component.ts': `import { Component } from '@angular/core'; | ||
| 12 | + | ||
| 13 | + @Component({ | ||
| 14 | + selector: 'lib-my-lib', | ||
| 15 | + templateUrl: './my-lib.component.html', | ||
| 16 | + }) | ||
| 17 | + export class MyLibComponent {}`, | ||
| 18 | + './src/app/app.module.ts': ` | ||
| 9 | 19 | import { BrowserModule } from '@angular/platform-browser'; | |
| 10 | 20 | import { NgModule } from '@angular/core'; | |
| 11 | 21 | import { MyLibModule } from 'my-lib'; | |
@@ -24,9 +34,8 @@ export default async function () { | |||
| 24 | 34 | bootstrap: [AppComponent] | |
| 25 | 35 | }) | |
| 26 | 36 | export class AppModule { } | |
| 27 | - `); | ||
| 28 | - | ||
| 29 | - await writeFile('./src/app/app.component.ts', ` | ||
| 37 | + `, | ||
| 38 | + './src/app/app.component.ts': ` | ||
| 30 | 39 | import { Component } from '@angular/core'; | |
| 31 | 40 | import { MyLibService } from 'my-lib'; | |
| 32 | 41 | ||
@@ -41,9 +50,8 @@ export default async function () { | |||
| 41 | 50 | console.log(myLibService); | |
| 42 | 51 | } | |
| 43 | 52 | } | |
| 44 | - `); | ||
| 45 | - | ||
| 46 | - await writeFile('e2e/src/app.e2e-spec.ts', ` | ||
| 53 | + `, | ||
| 54 | + 'e2e/src/app.e2e-spec.ts': ` | ||
| 47 | 55 | import { browser, logging, element, by } from 'protractor'; | |
| 48 | 56 | import { AppPage } from './app.po'; | |
| 49 | 57 | ||
@@ -67,7 +75,8 @@ export default async function () { | |||
| 67 | 75 | })); | |
| 68 | 76 | }); | |
| 69 | 77 | }); | |
| 70 | - `); | ||
| 78 | + `, | ||
| 79 | + }); | ||
| 71 | 80 | ||
| 72 | 81 | // Build library in full mode (development) | |
| 73 | 82 | await ng('build', 'my-lib', '--configuration=development'); | |
@@ -76,7 +85,7 @@ export default async function () { | |||
| 76 | 85 | await runTests(); | |
| 77 | 86 | ||
| 78 | 87 | // JIT linking | |
| 79 | - await updateJsonFile('angular.json', config => { | ||
| 88 | + await updateJsonFile('angular.json', (config) => { | ||
| 80 | 89 | const build = config.projects['test-project'].architect.build; | |
| 81 | 90 | build.options.aot = false; | |
| 82 | 91 | build.configurations.production.buildOptimizer = false; | |
@@ -89,4 +98,8 @@ async function runTests(): Promise<void> { | |||
| 89 | 98 | // Check that the tests succeeds both with named project, unnamed (should test app), and prod. | |
| 90 | 99 | await ng('e2e'); | |
| 91 | 100 | await ng('e2e', 'test-project', '--devServerTarget=test-project:serve:production'); | |
| 101 | + | ||
| 102 | + // Validate that sourcemaps for the library exists. | ||
| 103 | + await ng('build', '--configuration=development'); | ||
| 104 | + await expectFileToMatch('dist/test-project/main.js.map', 'projects/my-lib/src/public-api.ts'); | ||
| 92 | 105 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,11 +1,21 @@ | |||
| 1 | - import { writeFile } from '../../../utils/fs'; | ||
| 1 | + import { expectFileToMatch, writeMultipleFiles } from '../../../utils/fs'; | ||
| 2 | 2 | import { ng } from '../../../utils/process'; | |
| 3 | 3 | import { updateJsonFile } from '../../../utils/project'; | |
| 4 | 4 | ||
| 5 | 5 | export default async function () { | |
| 6 | 6 | await ng('generate', 'library', 'my-lib'); | |
| 7 | 7 | ||
| 8 | - await writeFile('./src/app/app.module.ts', ` | ||
| 8 | + // Force an external template | ||
| 9 | + await writeMultipleFiles({ | ||
| 10 | + 'projects/my-lib/src/lib/my-lib.component.html': `<p>my-lib works!</p>`, | ||
| 11 | + 'projects/my-lib/src/lib/my-lib.component.ts': `import { Component } from '@angular/core'; | ||
| 12 | + | ||
| 13 | + @Component({ | ||
| 14 | + selector: 'lib-my-lib', | ||
| 15 | + templateUrl: './my-lib.component.html', | ||
| 16 | + }) | ||
| 17 | + export class MyLibComponent {}`, | ||
| 18 | + './src/app/app.module.ts': ` | ||
| 9 | 19 | import { BrowserModule } from '@angular/platform-browser'; | |
| 10 | 20 | import { NgModule } from '@angular/core'; | |
| 11 | 21 | import { MyLibModule } from 'my-lib'; | |
@@ -24,9 +34,8 @@ export default async function () { | |||
| 24 | 34 | bootstrap: [AppComponent] | |
| 25 | 35 | }) | |
| 26 | 36 | export class AppModule { } | |
| 27 | - `); | ||
| 28 | - | ||
| 29 | - await writeFile('./src/app/app.component.ts', ` | ||
| 37 | + `, | ||
| 38 | + './src/app/app.component.ts': ` | ||
| 30 | 39 | import { Component } from '@angular/core'; | |
| 31 | 40 | import { MyLibService } from 'my-lib'; | |
| 32 | 41 | ||
@@ -41,9 +50,8 @@ export default async function () { | |||
| 41 | 50 | console.log(myLibService); | |
| 42 | 51 | } | |
| 43 | 52 | } | |
| 44 | - `); | ||
| 45 | - | ||
| 46 | - await writeFile('e2e/src/app.e2e-spec.ts', ` | ||
| 53 | + `, | ||
| 54 | + 'e2e/src/app.e2e-spec.ts': ` | ||
| 47 | 55 | import { browser, logging, element, by } from 'protractor'; | |
| 48 | 56 | import { AppPage } from './app.po'; | |
| 49 | 57 | ||
@@ -67,7 +75,8 @@ export default async function () { | |||
| 67 | 75 | })); | |
| 68 | 76 | }); | |
| 69 | 77 | }); | |
| 70 | - `); | ||
| 78 | + `, | ||
| 79 | + }); | ||
| 71 | 80 | ||
| 72 | 81 | // Build library in partial mode (production) | |
| 73 | 82 | await ng('build', 'my-lib', '--configuration=production'); | |
@@ -76,7 +85,7 @@ export default async function () { | |||
| 76 | 85 | await runTests(); | |
| 77 | 86 | ||
| 78 | 87 | // JIT linking | |
| 79 | - await updateJsonFile('angular.json', config => { | ||
| 88 | + await updateJsonFile('angular.json', (config) => { | ||
| 80 | 89 | const build = config.projects['test-project'].architect.build; | |
| 81 | 90 | build.options.aot = false; | |
| 82 | 91 | build.configurations.production.buildOptimizer = false; | |
@@ -89,4 +98,8 @@ async function runTests(): Promise<void> { | |||
| 89 | 98 | // Check that the tests succeeds both with named project, unnamed (should test app), and prod. | |
| 90 | 99 | await ng('e2e'); | |
| 91 | 100 | await ng('e2e', 'test-project', '--devServerTarget=test-project:serve:production'); | |
| 101 | + | ||
| 102 | + // Validate that sourcemaps for the library exists. | ||
| 103 | + await ng('build', '--configuration=development'); | ||
| 104 | + await expectFileToMatch('dist/test-project/main.js.map', 'projects/my-lib/src/public-api.ts'); | ||
| 92 | 105 | } | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1,19 +1,29 @@ | |||
| 1 | - import { writeFile } from '../../../utils/fs'; | ||
| 1 | + import { expectFileToMatch, writeMultipleFiles } from '../../../utils/fs'; | ||
| 2 | 2 | import { ng } from '../../../utils/process'; | |
| 3 | 3 | import { updateJsonFile } from '../../../utils/project'; | |
| 4 | 4 | ||
| 5 | 5 | export default async function () { | |
| 6 | 6 | await ng('generate', 'library', 'my-lib'); | |
| 7 | 7 | ||
| 8 | - await updateJsonFile('projects/my-lib/tsconfig.lib.prod.json', config => { | ||
| 8 | + await updateJsonFile('projects/my-lib/tsconfig.lib.prod.json', (config) => { | ||
| 9 | 9 | const { angularCompilerOptions = {} } = config; | |
| 10 | 10 | angularCompilerOptions.enableIvy = false; | |
| 11 | 11 | angularCompilerOptions.skipTemplateCodegen = true; | |
| 12 | 12 | angularCompilerOptions.strictMetadataEmit = true; | |
| 13 | 13 | config.angularCompilerOptions = angularCompilerOptions; | |
| 14 | 14 | }); | |
| 15 | 15 | ||
| 16 | - await writeFile('./src/app/app.module.ts', ` | ||
| 16 | + // Force an external template | ||
| 17 | + await writeMultipleFiles({ | ||
| 18 | + 'projects/my-lib/src/lib/my-lib.component.html': `<p>my-lib works!</p>`, | ||
| 19 | + 'projects/my-lib/src/lib/my-lib.component.ts': `import { Component } from '@angular/core'; | ||
| 20 | + | ||
| 21 | + @Component({ | ||
| 22 | + selector: 'lib-my-lib', | ||
| 23 | + templateUrl: './my-lib.component.html', | ||
| 24 | + }) | ||
| 25 | + export class MyLibComponent {}`, | ||
| 26 | + './src/app/app.module.ts': ` | ||
| 17 | 27 | import { BrowserModule } from '@angular/platform-browser'; | |
| 18 | 28 | import { NgModule } from '@angular/core'; | |
| 19 | 29 | import { MyLibModule } from 'my-lib'; | |
@@ -32,9 +42,8 @@ export default async function () { | |||
| 32 | 42 | bootstrap: [AppComponent] | |
| 33 | 43 | }) | |
| 34 | 44 | export class AppModule { } | |
| 35 | - `); | ||
| 36 | - | ||
| 37 | - await writeFile('./src/app/app.component.ts', ` | ||
| 45 | + `, | ||
| 46 | + './src/app/app.component.ts': ` | ||
| 38 | 47 | import { Component } from '@angular/core'; | |
| 39 | 48 | import { MyLibService } from 'my-lib'; | |
| 40 | 49 | ||
@@ -49,9 +58,8 @@ export default async function () { | |||
| 49 | 58 | console.log(myLibService); | |
| 50 | 59 | } | |
| 51 | 60 | } | |
| 52 | - `); | ||
| 53 | - | ||
| 54 | - await writeFile('e2e/src/app.e2e-spec.ts', ` | ||
| 61 | + `, | ||
| 62 | + 'e2e/src/app.e2e-spec.ts': ` | ||
| 55 | 63 | import { browser, logging, element, by } from 'protractor'; | |
| 56 | 64 | import { AppPage } from './app.po'; | |
| 57 | 65 | ||
@@ -75,7 +83,8 @@ export default async function () { | |||
| 75 | 83 | })); | |
| 76 | 84 | }); | |
| 77 | 85 | }); | |
| 78 | - `); | ||
| 86 | + `, | ||
| 87 | + }); | ||
| 79 | 88 | ||
| 80 | 89 | // Build library in VE mode (production) | |
| 81 | 90 | await ng('build', 'my-lib', '--configuration=production'); | |
@@ -84,7 +93,7 @@ export default async function () { | |||
| 84 | 93 | await runTests(); | |
| 85 | 94 | ||
| 86 | 95 | // JIT linking | |
| 87 | - await updateJsonFile('angular.json', config => { | ||
| 96 | + await updateJsonFile('angular.json', (config) => { | ||
| 88 | 97 | const build = config.projects['test-project'].architect.build; | |
| 89 | 98 | build.options.aot = false; | |
| 90 | 99 | build.configurations.production.buildOptimizer = false; | |
@@ -97,4 +106,8 @@ async function runTests(): Promise<void> { | |||
| 97 | 106 | // Check that the tests succeeds both with named project, unnamed (should test app), and prod. | |
| 98 | 107 | await ng('e2e'); | |
| 99 | 108 | await ng('e2e', 'test-project', '--devServerTarget=test-project:serve:production'); | |
| 109 | + | ||
| 110 | + // Validate that sourcemaps for the library exists. | ||
| 111 | + await ng('build', '--configuration=development'); | ||
| 112 | + await expectFileToMatch('dist/test-project/main.js.map', 'projects/my-lib/src/public-api.ts'); | ||
| 100 | 113 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments