Skip to content

Commit 9250e8e

Browse files
clydinalexeagle
authored andcommittedAug 14, 2018
fix(@angular-devkit/build-angular): cleanup serviceworker direct import
1 parent 10c690b commit 9250e8e

File tree

2 files changed

+21
-10
lines changed
  • packages/angular_devkit/build_angular

2 files changed

+21
-10
lines changed
 

‎packages/angular_devkit/build_angular/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@
4040
"raw-loader": "^0.5.1",
4141
"rxjs": "^6.0.0",
4242
"sass-loader": "~6.0.7",
43+
"semver": "^5.5.0",
4344
"source-map-support": "^0.5.0",
4445
"source-map-loader": "^0.2.3",
4546
"stats-webpack-plugin": "^0.6.2",

‎packages/angular_devkit/build_angular/src/angular-cli-files/utilities/service-worker/index.ts

+20-10
Original file line numberDiff line numberDiff line change
@@ -5,17 +5,26 @@
55
* Use of this source code is governed by an MIT-style license that can be
66
* found in the LICENSE file at https://angular.io/license
77
*/
8-
// tslint:disable
98
// TODO: cleanup this file, it's copied as is from Angular CLI.
10-
import { Path, join, normalize, virtualFs, dirname, getSystemPath, tags, fragment } from '@angular-devkit/core';
11-
import { Filesystem } from '@angular/service-worker/config';
9+
import {
10+
Path,
11+
dirname,
12+
getSystemPath,
13+
join,
14+
normalize,
15+
tags,
16+
virtualFs,
17+
} from '@angular-devkit/core';
18+
import {
19+
Filesystem,
20+
Generator,
21+
} from '@angular/service-worker/config'; // tslint:disable-line:no-implicit-dependencies
1222
import * as crypto from 'crypto';
1323
import * as fs from 'fs';
24+
import { Observable, from, merge, of } from 'rxjs';
25+
import { concatMap, map, mergeMap, reduce, switchMap, toArray } from 'rxjs/operators';
1426
import * as semver from 'semver';
15-
1627
import { resolveProjectModule } from '../require-project-module';
17-
import { map, reduce, switchMap, concatMap, mergeMap, toArray, tap } from "rxjs/operators";
18-
import { Observable, merge, of, from } from "rxjs";
1928

2029

2130
export const NEW_SW_VERSION = '5.0.0-rc.0';
@@ -32,8 +41,8 @@ class CliFilesystem implements Filesystem {
3241
map(fragment => join(path, fragment)),
3342
// Emit directory content paths instead of the directory path.
3443
mergeMap(path => this._host.isDirectory(path).pipe(
35-
concatMap(isDir => isDir ? recursiveList(path) : of(path))
36-
)
44+
concatMap(isDir => isDir ? recursiveList(path) : of(path)),
45+
),
3746
),
3847
);
3948

@@ -133,14 +142,15 @@ export function augmentAppWithServiceWorker(
133142
}),
134143
map(content => JSON.parse(virtualFs.fileBufferToString(content))),
135144
switchMap(configJson => {
136-
const Generator = require(swConfigPath).Generator;
137-
const gen = new Generator(new CliFilesystem(host, outputPath), baseHref);
145+
const GeneratorConstructor = require(swConfigPath).Generator as typeof Generator;
146+
const gen = new GeneratorConstructor(new CliFilesystem(host, outputPath), baseHref);
138147

139148
return gen.process(configJson);
140149
}),
141150

142151
switchMap(output => {
143152
const manifest = JSON.stringify(output, null, 2);
153+
144154
return host.read(workerPath).pipe(
145155
switchMap(workerCode => {
146156
return merge(

0 commit comments

Comments
 (0)