@angular-devkit/build-angular 0.901.8 → 0.901.12

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,30 +1,30 @@
1
1
  {
2
2
  "name": "@angular-devkit/build-angular",
3
- "version": "0.901.8",
3
+ "version": "0.901.12",
4
4
  "description": "Angular Webpack Build Facade",
5
5
  "experimental": true,
6
6
  "main": "src/index.js",
7
7
  "typings": "src/index.d.ts",
8
8
  "builders": "builders.json",
9
9
  "dependencies": {
10
- "@angular-devkit/architect": "0.901.8",
11
- "@angular-devkit/build-optimizer": "0.901.8",
12
- "@angular-devkit/build-webpack": "0.901.8",
13
- "@angular-devkit/core": "9.1.8",
10
+ "@angular-devkit/architect": "0.901.12",
11
+ "@angular-devkit/build-optimizer": "0.901.12",
12
+ "@angular-devkit/build-webpack": "0.901.12",
13
+ "@angular-devkit/core": "9.1.12",
14
14
  "@babel/core": "7.9.0",
15
15
  "@babel/generator": "7.9.3",
16
16
  "@babel/preset-env": "7.9.0",
17
17
  "@babel/template": "7.8.6",
18
18
  "@jsdevtools/coverage-istanbul-loader": "3.0.3",
19
- "@ngtools/webpack": "9.1.8",
20
- "ajv": "6.12.0",
19
+ "@ngtools/webpack": "9.1.12",
20
+ "ajv": "6.12.3",
21
21
  "autoprefixer": "9.7.4",
22
22
  "babel-loader": "8.0.6",
23
23
  "browserslist": "^4.9.1",
24
24
  "cacache": "15.0.0",
25
25
  "caniuse-lite": "^1.0.30001032",
26
26
  "circular-dependency-plugin": "5.2.0",
27
- "copy-webpack-plugin": "6.0.2",
27
+ "copy-webpack-plugin": "6.0.3",
28
28
  "core-js": "3.6.4",
29
29
  "css-loader": "3.5.1",
30
30
  "cssnano": "4.1.10",
@@ -60,7 +60,7 @@
60
60
  "stylus-loader": "3.0.2",
61
61
  "tree-kill": "1.2.2",
62
62
  "terser": "4.6.10",
63
- "terser-webpack-plugin": "2.3.5",
63
+ "terser-webpack-plugin": "3.0.3",
64
64
  "webpack": "4.42.0",
65
65
  "webpack-dev-middleware": "3.7.2",
66
66
  "webpack-dev-server": "3.11.0",
@@ -341,12 +341,13 @@ function getCommonConfig(wco) {
341
341
  // Name mangling is handled within the browser builder
342
342
  mangle: environment_options_1.allowMangle && buildOptions.platform !== 'server' && !differentialLoadingMode,
343
343
  };
344
+ const globalScriptsNames = globalScriptsByBundleName.map(s => s.bundleName);
344
345
  extraMinimizers.push(new TerserPlugin({
345
346
  sourceMap: scriptsSourceMap,
346
347
  parallel: utils_1.maxWorkers,
347
348
  cache: !environment_options_1.cachingDisabled && cache_path_1.findCachePath('terser-webpack'),
348
349
  extractComments: false,
349
- chunkFilter: (chunk) => !globalScriptsByBundleName.some(s => s.bundleName === chunk.name),
350
+ exclude: globalScriptsNames,
350
351
  terserOptions,
351
352
  }),
352
353
  // Script bundles are fully optimized here in one step since they are never downleveled.
@@ -356,7 +357,7 @@ function getCommonConfig(wco) {
356
357
  parallel: utils_1.maxWorkers,
357
358
  cache: !environment_options_1.cachingDisabled && cache_path_1.findCachePath('terser-webpack'),
358
359
  extractComments: false,
359
- chunkFilter: (chunk) => globalScriptsByBundleName.some(s => s.bundleName === chunk.name),
360
+ include: globalScriptsNames,
360
361
  terserOptions: {
361
362
  ...terserOptions,
362
363
  compress: environment_options_1.allowMinify && {
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,236 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const core_1 = require("@angular-devkit/core");
4
+ const express = require("express"); // tslint:disable-line:no-implicit-dependencies
5
+ const utils_1 = require("../utils");
6
+ // This test is excluded by default and will need to be run explicitly.
7
+ // This is because App-Shell builder uses zone.js which patched the global Promise
8
+ // Currently there is no clean way to unload zone.js which causes tests that run after
9
+ // this to be extremly flaky.
10
+ // To run this test use:
11
+ // yarn test-large --full --glob packages/angular_devkit/build_angular/test/app-shell/app-shell_spec_large_disabled.ts
12
+ describe('AppShell Builder', () => {
13
+ const target = { project: 'app', target: 'app-shell' };
14
+ let architect;
15
+ beforeEach(async () => {
16
+ await utils_1.host.initialize().toPromise();
17
+ architect = (await utils_1.createArchitect(utils_1.host.root())).architect;
18
+ });
19
+ afterEach(async () => utils_1.host.restore().toPromise());
20
+ const appShellRouteFiles = {
21
+ 'src/app/app-shell/app-shell.component.html': `
22
+ <p>
23
+ app-shell works!
24
+ </p>
25
+ `,
26
+ 'src/app/app-shell/app-shell.component.ts': `
27
+ import { Component, OnInit } from '@angular/core';
28
+
29
+ @Component({
30
+ selector: 'app-app-shell',
31
+ templateUrl: './app-shell.component.html',
32
+ })
33
+ export class AppShellComponent implements OnInit {
34
+
35
+ constructor() { }
36
+
37
+ ngOnInit() {
38
+ }
39
+
40
+ }
41
+ `,
42
+ 'src/app/app.module.ts': `
43
+ import { BrowserModule } from '@angular/platform-browser';
44
+ import { NgModule } from '@angular/core';
45
+
46
+ import { AppRoutingModule } from './app-routing.module';
47
+ import { AppComponent } from './app.component';
48
+ import { environment } from '../environments/environment';
49
+ import { RouterModule } from '@angular/router';
50
+
51
+ @NgModule({
52
+ declarations: [
53
+ AppComponent
54
+ ],
55
+ imports: [
56
+ BrowserModule.withServerTransition({ appId: 'serverApp' }),
57
+ AppRoutingModule,
58
+ RouterModule
59
+ ],
60
+ providers: [],
61
+ bootstrap: [AppComponent]
62
+ })
63
+ export class AppModule { }
64
+ `,
65
+ 'src/app/app.server.module.ts': `
66
+ import { NgModule } from '@angular/core';
67
+ import { ServerModule } from '@angular/platform-server';
68
+
69
+ import { AppModule } from './app.module';
70
+ import { AppComponent } from './app.component';
71
+ import { Routes, RouterModule } from '@angular/router';
72
+ import { AppShellComponent } from './app-shell/app-shell.component';
73
+
74
+ const routes: Routes = [ { path: 'shell', component: AppShellComponent }];
75
+
76
+ @NgModule({
77
+ imports: [
78
+ AppModule,
79
+ ServerModule,
80
+ RouterModule.forRoot(routes),
81
+ ],
82
+ bootstrap: [AppComponent],
83
+ declarations: [AppShellComponent],
84
+ })
85
+ export class AppServerModule {}
86
+ `,
87
+ 'src/main.ts': `
88
+ import { enableProdMode } from '@angular/core';
89
+ import { platformBrowserDynamic } from '@angular/platform-browser-dynamic';
90
+
91
+ import { AppModule } from './app/app.module';
92
+ import { environment } from './environments/environment';
93
+
94
+ if (environment.production) {
95
+ enableProdMode();
96
+ }
97
+
98
+ document.addEventListener('DOMContentLoaded', () => {
99
+ platformBrowserDynamic().bootstrapModule(AppModule)
100
+ .catch(err => console.log(err));
101
+ });
102
+ `,
103
+ 'src/app/app-routing.module.ts': `
104
+ import { NgModule } from '@angular/core';
105
+ import { Routes, RouterModule } from '@angular/router';
106
+
107
+ const routes: Routes = [];
108
+
109
+ @NgModule({
110
+ imports: [RouterModule.forRoot(routes)],
111
+ exports: [RouterModule]
112
+ })
113
+ export class AppRoutingModule { }
114
+ `,
115
+ 'src/app/app.component.html': `
116
+ <router-outlet></router-outlet>
117
+ `,
118
+ };
119
+ it('works (basic)', async () => {
120
+ utils_1.host.replaceInFile('src/app/app.module.ts', / BrowserModule/, `
121
+ BrowserModule.withServerTransition({ appId: 'some-app' })
122
+ `);
123
+ const run = await architect.scheduleTarget(target);
124
+ const output = await run.result;
125
+ await run.stop();
126
+ expect(output.success).toBe(true);
127
+ const fileName = 'dist/index.html';
128
+ const content = core_1.virtualFs.fileBufferToString(utils_1.host.scopedSync().read(core_1.normalize(fileName)));
129
+ expect(content).toMatch(/Welcome to app!/);
130
+ });
131
+ it('works with route', async () => {
132
+ utils_1.host.writeMultipleFiles(appShellRouteFiles);
133
+ const overrides = { route: 'shell' };
134
+ const run = await architect.scheduleTarget(target, overrides);
135
+ const output = await run.result;
136
+ await run.stop();
137
+ expect(output.success).toBe(true);
138
+ const fileName = 'dist/index.html';
139
+ const content = core_1.virtualFs.fileBufferToString(utils_1.host.scopedSync().read(core_1.normalize(fileName)));
140
+ expect(content).toContain('app-shell works!');
141
+ });
142
+ it('works with route and service-worker', async () => {
143
+ utils_1.host.writeMultipleFiles(appShellRouteFiles);
144
+ utils_1.host.writeMultipleFiles({
145
+ 'src/ngsw-config.json': `
146
+ {
147
+ "index": "/index.html",
148
+ "assetGroups": [{
149
+ "name": "app",
150
+ "installMode": "prefetch",
151
+ "resources": {
152
+ "files": [
153
+ "/favicon.ico",
154
+ "/index.html",
155
+ "/*.css",
156
+ "/*.js"
157
+ ]
158
+ }
159
+ }, {
160
+ "name": "assets",
161
+ "installMode": "lazy",
162
+ "updateMode": "prefetch",
163
+ "resources": {
164
+ "files": [
165
+ "/assets/**"
166
+ ]
167
+ }
168
+ }]
169
+ }
170
+ `,
171
+ 'src/app/app.module.ts': `
172
+ import { BrowserModule } from '@angular/platform-browser';
173
+ import { NgModule } from '@angular/core';
174
+
175
+ import { AppRoutingModule } from './app-routing.module';
176
+ import { AppComponent } from './app.component';
177
+ import { ServiceWorkerModule } from '@angular/service-worker';
178
+ import { environment } from '../environments/environment';
179
+ import { RouterModule } from '@angular/router';
180
+
181
+ @NgModule({
182
+ declarations: [
183
+ AppComponent
184
+ ],
185
+ imports: [
186
+ BrowserModule.withServerTransition({ appId: 'serverApp' }),
187
+ AppRoutingModule,
188
+ ServiceWorkerModule.register('/ngsw-worker.js', { enabled: environment.production }),
189
+ RouterModule
190
+ ],
191
+ providers: [],
192
+ bootstrap: [AppComponent]
193
+ })
194
+ export class AppModule { }
195
+ `,
196
+ 'e2e/app.e2e-spec.ts': `
197
+ import { browser, by, element } from 'protractor';
198
+
199
+ it('should have ngsw in normal state', () => {
200
+ browser.get('/');
201
+ // Wait for service worker to load.
202
+ browser.sleep(2000);
203
+ browser.waitForAngularEnabled(false);
204
+ browser.get('/ngsw/state');
205
+ // Should have updated, and be in normal state.
206
+ expect(element(by.css('pre')).getText()).not.toContain('Last update check: never');
207
+ expect(element(by.css('pre')).getText()).toContain('Driver state: NORMAL');
208
+ });
209
+ `,
210
+ });
211
+ // This should match the browser target prod config.
212
+ utils_1.host.replaceInFile('angular.json', '"buildOptimizer": true', '"buildOptimizer": true, "serviceWorker": true');
213
+ // We're changing the workspace file so we need to recreate the Architect instance.
214
+ architect = (await utils_1.createArchitect(utils_1.host.root())).architect;
215
+ const overrides = { route: 'shell' };
216
+ const run = await architect.scheduleTarget({ ...target, configuration: 'production' }, overrides);
217
+ const output = await run.result;
218
+ await run.stop();
219
+ expect(output.success).toBe(true);
220
+ // Make sure the index is pre-rendering the route.
221
+ const fileName = 'dist/index.html';
222
+ const content = core_1.virtualFs.fileBufferToString(utils_1.host.scopedSync().read(core_1.normalize(fileName)));
223
+ expect(content).toContain('app-shell works!');
224
+ // Serve the app using a simple static server.
225
+ const app = express();
226
+ app.use('/', express.static(core_1.getSystemPath(core_1.join(utils_1.host.root(), 'dist')) + '/'));
227
+ const server = app.listen(4200);
228
+ // Load app in protractor, then check service worker status.
229
+ const protractorRun = await architect.scheduleTarget({ project: 'app-e2e', target: 'e2e' }, { devServerTarget: undefined });
230
+ const protractorOutput = await protractorRun.result;
231
+ await protractorRun.stop();
232
+ expect(protractorOutput.success).toBe(true);
233
+ // Close the express server.
234
+ server.close();
235
+ });
236
+ });