Skip to content

Commit d66602e

Browse files
clydinhansl
authored andcommitted
refactor(@angular-devkit/build-webpack): remove common-tags dependency
1 parent 72e2d4f commit d66602e

7 files changed

Lines changed: 16 additions & 34 deletions

File tree

package-lock.json

Lines changed: 0 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,6 @@
6666
"@angular/router": "^5.2.6",
6767
"@angular/service-worker": "^5.2.7",
6868
"@ngtools/json-schema": "^1.0.9",
69-
"@types/common-tags": "^1.4.0",
7069
"@types/copy-webpack-plugin": "^4.0.1",
7170
"@types/express": "^4.11.1",
7271
"@types/glob": "^5.0.29",
@@ -89,7 +88,6 @@
8988
"circular-dependency-plugin": "^5.0.0",
9089
"clean-css": "^4.1.11",
9190
"codelyzer": "^4.0.2",
92-
"common-tags": "^1.5.1",
9391
"conventional-changelog": "^1.1.0",
9492
"copy-webpack-plugin": "^4.5.0",
9593
"express": "^4.16.2",

packages/angular_devkit/build_webpack/package.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
1818
"chalk": "~2.2.2",
1919
"circular-dependency-plugin": "^5.0.0",
2020
"clean-css": "^4.1.11",
21-
"common-tags": "^1.5.1",
2221
"copy-webpack-plugin": "^4.5.0",
2322
"file-loader": "^1.1.11",
2423
"glob": "^7.0.3",

packages/angular_devkit/build_webpack/src/angular-cli-files/lib/base-href-webpack/base-href-webpack-plugin_spec.ts

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// tslint:disable
22
// TODO: cleanup this file, it's copied as is from Angular CLI.
33

4-
import {oneLineTrim} from 'common-tags';
4+
import { tags } from '@angular-devkit/core';
55
import {BaseHrefWebpackPlugin} from './base-href-webpack-plugin';
66

77

@@ -22,7 +22,7 @@ function mockCompiler(indexHtml: string, callback: Function) {
2222
}
2323

2424
describe('base href webpack plugin', () => {
25-
const html = oneLineTrim`
25+
const html = tags.oneLine`
2626
<html>
2727
<head></head>
2828
<body></body>
@@ -41,7 +41,7 @@ describe('base href webpack plugin', () => {
4141
it('should insert base tag when not exist', function () {
4242
const plugin = new BaseHrefWebpackPlugin({ baseHref: '/' });
4343
const compiler = mockCompiler(html, (_x: any, htmlPluginData: any) => {
44-
expect(htmlPluginData.html).toEqual(oneLineTrim`
44+
expect(htmlPluginData.html).toEqual(tags.oneLine`
4545
<html>
4646
<head><base href="/"></head>
4747
<body></body>
@@ -55,11 +55,11 @@ describe('base href webpack plugin', () => {
5555
it('should replace href attribute when base tag already exists', function () {
5656
const plugin = new BaseHrefWebpackPlugin({ baseHref: '/myUrl/' });
5757

58-
const compiler = mockCompiler(oneLineTrim`
58+
const compiler = mockCompiler(tags.oneLine`
5959
<head><base href="/" target="_blank"></head>
6060
<body></body>
6161
`, (_x: any, htmlPluginData: any) => {
62-
expect(htmlPluginData.html).toEqual(oneLineTrim`
62+
expect(htmlPluginData.html).toEqual(tags.oneLine`
6363
<head><base href="/myUrl/" target="_blank"></head>
6464
<body></body>
6565
`);
@@ -70,11 +70,11 @@ describe('base href webpack plugin', () => {
7070
it('should replace href attribute when baseHref is empty', function () {
7171
const plugin = new BaseHrefWebpackPlugin({ baseHref: '' });
7272

73-
const compiler = mockCompiler(oneLineTrim`
73+
const compiler = mockCompiler(tags.oneLine`
7474
<head><base href="/" target="_blank"></head>
7575
<body></body>
7676
`, (_x: any, htmlPluginData: any) => {
77-
expect(htmlPluginData.html).toEqual(oneLineTrim`
77+
expect(htmlPluginData.html).toEqual(tags.oneLine`
7878
<head><base href="" target="_blank"></head>
7979
<body></body>
8080
`);

packages/angular_devkit/build_webpack/src/angular-cli-files/models/webpack-configs/typescript.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
// tslint:disable
22
// TODO: cleanup this file, it's copied as is from Angular CLI.
3-
import { virtualFs } from '@angular-devkit/core';
3+
import { tags, virtualFs } from '@angular-devkit/core';
44
import { Stats } from 'fs';
55
import * as path from 'path';
6-
import { stripIndent } from 'common-tags';
76
import {
87
AngularCompilerPlugin,
98
AngularCompilerPluginOptions,
@@ -40,7 +39,7 @@ function _createAotPlugin(
4039
if (!appConfig.environmentSource) {
4140
let migrationMessage = '';
4241
if ('source' in appConfig.environments) {
43-
migrationMessage = '\n\n' + stripIndent`
42+
migrationMessage = '\n\n' + tags.stripIndent`
4443
A new environmentSource entry replaces the previous source entry inside environments.
4544
4645
To migrate angular-cli.json follow the example below:

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

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
// tslint:disable
22
// TODO: cleanup this file, it's copied as is from Angular CLI.
3-
import { Path, join, normalize, virtualFs, dirname, getSystemPath } from '@angular-devkit/core';
3+
import { Path, join, normalize, virtualFs, dirname, getSystemPath, tags } from '@angular-devkit/core';
44
import { Filesystem } from '@angular/service-worker/config';
5-
import { oneLine, stripIndent } from 'common-tags';
65
import * as crypto from 'crypto';
76
import * as fs from 'fs';
87
import * as semver from 'semver';
@@ -55,7 +54,7 @@ export function usesServiceWorker(projectRoot: string): boolean {
5554
swPackageJsonPath = resolveProjectModule(projectRoot, '@angular/service-worker/package.json');
5655
} catch (_) {
5756
// @angular/service-worker is not installed
58-
throw new Error(stripIndent`
57+
throw new Error(tags.stripIndent`
5958
Your project is configured with serviceWorker = true, but @angular/service-worker
6059
is not installed. Run \`npm install --save-dev @angular/service-worker\`
6160
and try again, or run \`ng set apps.0.serviceWorker=false\` in your .angular-cli.json.
@@ -66,7 +65,7 @@ export function usesServiceWorker(projectRoot: string): boolean {
6665
const swVersion = JSON.parse(swPackageJson)['version'];
6766

6867
if (!semver.gte(swVersion, NEW_SW_VERSION)) {
69-
throw new Error(stripIndent`
68+
throw new Error(tags.stripIndent`
7069
The installed version of @angular/service-worker is ${swVersion}. This version of the CLI
7170
requires the @angular/service-worker version to satisfy ${NEW_SW_VERSION}. Please upgrade
7271
your service worker version.
@@ -98,7 +97,7 @@ export function augmentAppWithServiceWorker(
9897
return host.exists(configPath).pipe(
9998
switchMap(exists => {
10099
if (!exists) {
101-
throw new Error(oneLine`
100+
throw new Error(tags.oneLine`
102101
Error: Expected to find an ngsw-config.json configuration
103102
file in the ${appRoot} folder. Either provide one or disable Service Worker
104103
in your angular.json configuration file.`,

packages/angular_devkit/build_webpack/src/angular-cli-files/utilities/stats.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// TODO: cleanup this file, it's copied as is from Angular CLI.
33

44
import chalk from 'chalk';
5-
import { stripIndents } from 'common-tags';
5+
import { tags } from '@angular-devkit/core';
66

77

88
// Force basic color support on terminals with no color support.
@@ -47,13 +47,13 @@ export function statsToString(json: any, statsConfig: any) {
4747
const unchangedChunkNumber = json.chunks.length - changedChunksStats.length;
4848

4949
if (unchangedChunkNumber > 0) {
50-
return rs(stripIndents`
50+
return rs(tags.stripIndents`
5151
Date: ${w(new Date().toISOString())} - Hash: ${w(json.hash)} - Time: ${w('' + json.time)}ms
5252
${unchangedChunkNumber} unchanged chunks
5353
${changedChunksStats.join('\n')}
5454
`);
5555
} else {
56-
return rs(stripIndents`
56+
return rs(tags.stripIndents`
5757
Date: ${w(new Date().toISOString())}
5858
Hash: ${w(json.hash)}
5959
Time: ${w('' + json.time)}ms

0 commit comments

Comments
 (0)