From 8185558e796517159f1bc3e4c452e8e0d05608d7 Mon Sep 17 00:00:00 2001 From: Charles Lyding <19598772+clydin@users.noreply.github.com> Date: Thu, 1 Apr 2021 11:51:03 -0400 Subject: [PATCH] refactor(@angular/pwa): remove `@angular-devkit/core` dependency The `@angular-devkit/core` dependency was only used for two path manipulation functions. Since this schematic already uses Node.js builtins, the `path` builtin can also be used to provide equivalent function without the need for an additional dependency. --- packages/angular/pwa/BUILD.bazel | 2 -- packages/angular/pwa/package.json | 1 - packages/angular/pwa/pwa/index.ts | 11 +++++++---- 3 files changed, 7 insertions(+), 7 deletions(-) diff --git a/packages/angular/pwa/BUILD.bazel b/packages/angular/pwa/BUILD.bazel index 525339f925..d51f759738 100644 --- a/packages/angular/pwa/BUILD.bazel +++ b/packages/angular/pwa/BUILD.bazel @@ -38,12 +38,10 @@ ts_library( ], ), deps = [ - "//packages/angular_devkit/core", "//packages/angular_devkit/schematics", "//packages/schematics/angular", "@npm//@types/node", "@npm//@types/parse5-html-rewriting-stream", - "@npm//rxjs", ], ) diff --git a/packages/angular/pwa/package.json b/packages/angular/pwa/package.json index 52a73368ea..8bcfbcb8d7 100644 --- a/packages/angular/pwa/package.json +++ b/packages/angular/pwa/package.json @@ -13,7 +13,6 @@ "save": false }, "dependencies": { - "@angular-devkit/core": "0.0.0", "@angular-devkit/schematics": "0.0.0", "@schematics/angular": "0.0.0", "parse5-html-rewriting-stream": "6.0.1" diff --git a/packages/angular/pwa/pwa/index.ts b/packages/angular/pwa/pwa/index.ts index 8c327d1e7e..e6cabae378 100644 --- a/packages/angular/pwa/pwa/index.ts +++ b/packages/angular/pwa/pwa/index.ts @@ -5,7 +5,6 @@ * Use of this source code is governed by an MIT-style license that can be * found in the LICENSE file at https://angular.io/license */ -import { join, normalize } from '@angular-devkit/core'; import { Rule, SchematicsException, @@ -19,6 +18,7 @@ import { url, } from '@angular-devkit/schematics'; import { getWorkspace, updateWorkspace } from '@schematics/angular/utility/workspace'; +import { posix } from 'path'; import { Readable, Writable } from 'stream'; import { Schema as PwaOptions } from './schema'; @@ -117,7 +117,10 @@ export default function(options: PwaOptions): Rule { } // Add manifest to asset configuration - const assetEntry = join(normalize(project.root), 'src', 'manifest.webmanifest'); + const assetEntry = posix.join( + project.sourceRoot ?? posix.join(project.root, 'src'), + 'manifest.webmanifest', + ); for (const target of [...buildTargets, ...testTargets]) { if (target.options) { if (Array.isArray(target.options.assets)) { @@ -149,7 +152,7 @@ export default function(options: PwaOptions): Rule { } // Setup sources for the assets files to add to the project - const sourcePath = normalize(project.sourceRoot ?? 'src'); + const sourcePath = project.sourceRoot ?? posix.join(project.root, 'src'); // Setup service worker schematic options const { title, ...swOptions } = options; @@ -163,7 +166,7 @@ export default function(options: PwaOptions): Rule { ])), mergeWith(apply(url('./files/assets'), [ template({ ...options }), - move(join(sourcePath, 'assets')), + move(posix.join(sourcePath, 'assets')), ])), ...[...indexFiles].map(path => updateIndexFile(path)), ]);