From f273666e90c4e3648d271fe8fbde18ff21cd65d3 Mon Sep 17 00:00:00 2001 From: Alan Agius Date: Wed, 7 Dec 2022 15:45:56 +0000 Subject: [PATCH] refactor(compiler): replace deprecated `sourcemap-codec` (#48387) `sourcemap-codec` as been deprecated in favor of `@jridgewell/sourcemap-codec`. See: https://www.npmjs.com/package/sourcemap-codec?activeTab=versions PR Close #48387 --- package.json | 2 +- packages/compiler-cli/BUILD.bazel | 2 +- packages/compiler-cli/ngcc/test/BUILD.bazel | 2 +- .../ngcc/test/rendering/dts_renderer_spec.ts | 2 +- .../ngcc/test/rendering/renderer_spec.ts | 98 +------------------ packages/compiler-cli/package.json | 2 +- .../src/ngtsc/sourcemaps/BUILD.bazel | 2 +- .../src/ngtsc/sourcemaps/src/source_file.ts | 2 +- .../src/ngtsc/sourcemaps/test/BUILD.bazel | 2 +- .../ngtsc/sourcemaps/test/source_file_spec.ts | 2 +- yarn.lock | 4 +- 11 files changed, 13 insertions(+), 107 deletions(-) diff --git a/package.json b/package.json index e90c4b0806c..51cf10ce0b2 100644 --- a/package.json +++ b/package.json @@ -76,6 +76,7 @@ "@bazel/runfiles": "5.7.1", "@bazel/terser": "5.7.1", "@bazel/worker": "5.7.1", + "@jridgewell/sourcemap-codec": "^1.4.14", "@microsoft/api-extractor": "^7.24.2", "@rollup/plugin-babel": "^6.0.0", "@rollup/plugin-commonjs": "^23.0.0", @@ -162,7 +163,6 @@ "shelljs": "^0.8.5", "source-map": "0.7.4", "source-map-support": "0.5.21", - "sourcemap-codec": "^1.4.8", "start-server-and-test": "^1.10.11", "systemjs": "0.18.10", "terser": "^5.8.0", diff --git a/packages/compiler-cli/BUILD.bazel b/packages/compiler-cli/BUILD.bazel index c6a96684b6f..255a4779d7b 100644 --- a/packages/compiler-cli/BUILD.bazel +++ b/packages/compiler-cli/BUILD.bazel @@ -49,7 +49,7 @@ esbuild( "dependency-graph", "magic-string", "semver", - "sourcemap-codec", + "@jridgewell/sourcemap-codec", "tslib", "yargs", ], diff --git a/packages/compiler-cli/ngcc/test/BUILD.bazel b/packages/compiler-cli/ngcc/test/BUILD.bazel index b50a9a504b2..fa415e19bd6 100644 --- a/packages/compiler-cli/ngcc/test/BUILD.bazel +++ b/packages/compiler-cli/ngcc/test/BUILD.bazel @@ -27,11 +27,11 @@ ts_library( "//packages/compiler-cli/src/ngtsc/testing", "//packages/compiler-cli/src/ngtsc/transform", "//packages/compiler-cli/src/ngtsc/translator", + "@npm//@jridgewell/sourcemap-codec", "@npm//@types/convert-source-map", "@npm//@types/yargs", "@npm//dependency-graph", "@npm//magic-string", - "@npm//sourcemap-codec", "@npm//typescript", ], ) diff --git a/packages/compiler-cli/ngcc/test/rendering/dts_renderer_spec.ts b/packages/compiler-cli/ngcc/test/rendering/dts_renderer_spec.ts index 6ccdd643414..8276227c5f9 100644 --- a/packages/compiler-cli/ngcc/test/rendering/dts_renderer_spec.ts +++ b/packages/compiler-cli/ngcc/test/rendering/dts_renderer_spec.ts @@ -5,9 +5,9 @@ * 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 {encode} from '@jridgewell/sourcemap-codec'; import mapHelpers from 'convert-source-map'; import MagicString from 'magic-string'; -import {encode} from 'sourcemap-codec'; import ts from 'typescript'; import {absoluteFrom, getFileSystem} from '../../../src/ngtsc/file_system'; diff --git a/packages/compiler-cli/ngcc/test/rendering/renderer_spec.ts b/packages/compiler-cli/ngcc/test/rendering/renderer_spec.ts index 83e4f51b9ff..98acb3ac10a 100644 --- a/packages/compiler-cli/ngcc/test/rendering/renderer_spec.ts +++ b/packages/compiler-cli/ngcc/test/rendering/renderer_spec.ts @@ -8,7 +8,6 @@ import {Statement} from '@angular/compiler'; import mapHelpers from 'convert-source-map'; import MagicString from 'magic-string'; -import {encode, SourceMapMappings} from 'sourcemap-codec'; import ts from 'typescript'; import {absoluteFrom, getFileSystem} from '../../../src/ngtsc/file_system'; @@ -145,29 +144,6 @@ runInEachFileSystem(() => { `import { NgModule } from '@angular/core';\nexport class A {}\nA.decorators = [\n { type: NgModule, args: [{}] }\n];\n` }; - const JS_CONTENT_MAPPINGS: SourceMapMappings = [ - [ - [0, 0, 0, 0], [7, 0, 0, 7], [9, 0, 0, 8], [18, 0, 0, 17], [20, 0, 0, 18], [26, 0, 0, 24], - [41, 0, 0, 39], [42, 0, 0, 40] - ], - [[0, 0, 2, 0], [4, 0, 2, 13], [5, 0, 2, 14], [8, 0, 2, 0], [14, 0, 2, 13], [15, 0, 2, 14]], - [[4, 0, 3, 2], [7, 0, 3, 5], [8, 0, 3, 6], [9, 0, 3, 15]], - [ - [0, 0, 3, 27], [7, 0, 3, 34], [8, 0, 3, 35], [9, 0, 3, 36], [10, 0, 3, 37], - [11, 0, 3, 38], [1, 0, 4, 1], [2, 0, 4, 1] - ], - [[0, 0, 2, 13], [1, 0, 2, 14]], - [], - [ - [2, 0, 1, 1], [11, 0, 1, 10], [12, 0, 1, 11], [14, 0, 1, 12], [3, 0, 2, 13], - [4, 0, 2, 14], [5, 0, 4, 1] - ], - [ - [5, 0, 1, 20], [7, 0, 1, 22], [12, 0, 1, 27], [14, 0, 1, 28], [15, 0, 1, 29], - [9, 0, 2, 13], [10, 0, 2, 14] - ], - ]; - JS_CONTENT_MAP = mapHelpers.fromObject({ 'version': 3, 'file': 'file.js', @@ -175,7 +151,7 @@ runInEachFileSystem(() => { 'sources': ['file.ts'], 'sourcesContent': [TS_CONTENT.contents], 'names': [], - 'mappings': encode(JS_CONTENT_MAPPINGS), + 'mappings': ';;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA', }); RENDERED_CONTENTS = @@ -187,29 +163,7 @@ runInEachFileSystem(() => { 'file': 'file.js', 'sources': ['file.js'], 'names': [], - 'mappings': encode([ - [], - [], - [], - [], - [], - [], - [], - [], - [], - [], - [], - [], - [[0, 0, 0, 0]], - [[0, 0, 1, 0]], - [[0, 0, 2, 0]], - [[0, 0, 3, 0]], - [[0, 0, 4, 0]], - [[0, 0, 5, 0]], - [[0, 0, 6, 0]], - [[0, 0, 7, 0]], - [[0, 0, 8, 0]] - ]), + 'mappings': ';;;;;;;;;;;;AAAA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA', 'sourcesContent': [JS_CONTENT.contents], }); @@ -218,53 +172,7 @@ runInEachFileSystem(() => { 'file': 'file.js', 'sources': ['file.ts'], 'names': [], - 'mappings': encode([ - [], - [], - [], - [], - [], - [], - [], - [], - [], - [], - [], - [], - [ - [0, 0, 0, 0], [7, 0, 0, 7], [9, 0, 0, 8], [18, 0, 0, 17], [20, 0, 0, 18], - [26, 0, 0, 24], [41, 0, 0, 39], [42, 0, 0, 40] - ], - [ - [0, 0, 2, 0], [4, 0, 2, 13], [5, 0, 2, 14], [8, 0, 2, 0], [14, 0, 2, 13], [15, 0, 2, 14] - ], - [[0, 0, 2, 16], [4, 0, 3, 2], [7, 0, 3, 5], [8, 0, 3, 6], [9, 0, 3, 15]], - [ - [0, 0, 3, 27], [7, 0, 3, 34], [8, 0, 3, 35], [9, 0, 3, 36], [10, 0, 3, 37], - [11, 0, 3, 38], [1, 0, 4, 1], [2, 0, 4, 1] - ], - [[0, 0, 2, 13], [1, 0, 2, 14]], - [[0, 0, 3, 3]], - [ - [0, 0, 3, 5], [2, 0, 1, 1], [11, 0, 1, 10], [12, 0, 1, 11], [14, 0, 1, 12], - [3, 0, 2, 13], [4, 0, 2, 14], [5, 0, 4, 1] - ], - [ - [0, 0, 4, 13], [5, 0, 1, 20], [7, 0, 1, 22], [12, 0, 1, 27], [14, 0, 1, 28], - [15, 0, 1, 29], [9, 0, 2, 13], [10, 0, 2, 14] - ], - [[0, 0, 4, 2]], - [], - [ - [0, 0, 0, 2], [0, 0, 0, 2], [0, 0, 0, 2], [0, 0, 0, 2], [0, 0, 0, 2], [0, 0, 0, 2], - [0, 0, 0, 2], [0, 0, 0, 2], [0, 0, 2, 2], [0, 0, 2, 2], [0, 0, 2, 2], [0, 0, 2, 2], - [0, 0, 2, 2], [0, 0, 2, 2], [0, 0, 3, 2], [0, 0, 3, 2], [0, 0, 3, 2], [0, 0, 3, 2], - [0, 0, 3, 2], [0, 0, 3, 2], [0, 0, 3, 2], [0, 0, 3, 2], [0, 0, 3, 2], [0, 0, 3, 2], - [0, 0, 4, 2], [0, 0, 4, 2], [0, 0, 2, 2], [0, 0, 2, 2], [0, 0, 1, 2], [0, 0, 1, 2], - [0, 0, 1, 2], [0, 0, 1, 2], [0, 0, 2, 2], [0, 0, 2, 2], [0, 0, 4, 2], [0, 0, 1, 2], - [0, 0, 1, 2], [0, 0, 1, 2], [0, 0, 1, 2], [0, 0, 1, 2], [0, 0, 2, 2], [0, 0, 2, 2] - ], - ]), + 'mappings': ';;;;;;;;;;;;;;;;;;;;;;AAAA,AACA,AACA,AACA,AACA,AACA,AACA,AACA,AACA,AACA,AACA', 'sourcesContent': [TS_CONTENT.contents], }); }); diff --git a/packages/compiler-cli/package.json b/packages/compiler-cli/package.json index a8d4d746093..74ed8352f5f 100644 --- a/packages/compiler-cli/package.json +++ b/packages/compiler-cli/package.json @@ -54,13 +54,13 @@ }, "dependencies": { "@babel/core": "^7.17.2", + "@jridgewell/sourcemap-codec": "^1.4.14", "reflect-metadata": "^0.1.2", "chokidar": "^3.0.0", "convert-source-map": "^1.5.1", "dependency-graph": "^0.11.0", "magic-string": "^0.27.0", "semver": "^7.0.0", - "sourcemap-codec": "^1.4.8", "tslib": "^2.3.0", "yargs": "^17.2.1" }, diff --git a/packages/compiler-cli/src/ngtsc/sourcemaps/BUILD.bazel b/packages/compiler-cli/src/ngtsc/sourcemaps/BUILD.bazel index 5a1233e042c..8269493fd34 100644 --- a/packages/compiler-cli/src/ngtsc/sourcemaps/BUILD.bazel +++ b/packages/compiler-cli/src/ngtsc/sourcemaps/BUILD.bazel @@ -10,9 +10,9 @@ ts_library( deps = [ "//packages/compiler-cli/src/ngtsc/file_system", "//packages/compiler-cli/src/ngtsc/logging", + "@npm//@jridgewell/sourcemap-codec", "@npm//@types/convert-source-map", "@npm//@types/node", "@npm//convert-source-map", - "@npm//sourcemap-codec", ], ) diff --git a/packages/compiler-cli/src/ngtsc/sourcemaps/src/source_file.ts b/packages/compiler-cli/src/ngtsc/sourcemaps/src/source_file.ts index 6db7f72ca76..14472790fb2 100644 --- a/packages/compiler-cli/src/ngtsc/sourcemaps/src/source_file.ts +++ b/packages/compiler-cli/src/ngtsc/sourcemaps/src/source_file.ts @@ -5,8 +5,8 @@ * 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 {decode, encode, SourceMapMappings, SourceMapSegment} from '@jridgewell/sourcemap-codec'; import mapHelpers from 'convert-source-map'; -import {decode, encode, SourceMapMappings, SourceMapSegment} from 'sourcemap-codec'; import {AbsoluteFsPath, PathManipulation} from '../../file_system'; diff --git a/packages/compiler-cli/src/ngtsc/sourcemaps/test/BUILD.bazel b/packages/compiler-cli/src/ngtsc/sourcemaps/test/BUILD.bazel index 2e89c99f4f4..fd2bd5cc494 100644 --- a/packages/compiler-cli/src/ngtsc/sourcemaps/test/BUILD.bazel +++ b/packages/compiler-cli/src/ngtsc/sourcemaps/test/BUILD.bazel @@ -13,9 +13,9 @@ ts_library( "//packages/compiler-cli/src/ngtsc/file_system/testing", "//packages/compiler-cli/src/ngtsc/logging/testing", "//packages/compiler-cli/src/ngtsc/sourcemaps", + "@npm//@jridgewell/sourcemap-codec", "@npm//@types/convert-source-map", "@npm//convert-source-map", - "@npm//sourcemap-codec", ], ) diff --git a/packages/compiler-cli/src/ngtsc/sourcemaps/test/source_file_spec.ts b/packages/compiler-cli/src/ngtsc/sourcemaps/test/source_file_spec.ts index 9e4e079fbbe..fddb88ebbbf 100644 --- a/packages/compiler-cli/src/ngtsc/sourcemaps/test/source_file_spec.ts +++ b/packages/compiler-cli/src/ngtsc/sourcemaps/test/source_file_spec.ts @@ -5,7 +5,7 @@ * 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 {encode} from 'sourcemap-codec'; +import {encode} from '@jridgewell/sourcemap-codec'; import {absoluteFrom, getFileSystem, PathManipulation} from '../../file_system'; import {runInEachFileSystem} from '../../file_system/testing'; diff --git a/yarn.lock b/yarn.lock index 77d017c03ab..7470e2be3f7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -245,7 +245,6 @@ "@angular/build-tooling@https://github.com/angular/dev-infra-private-build-tooling-builds.git#d94cd02db1a276929ff63739d0b5f80a45a14abf": version "0.0.0-dd53634ba2a792fce0649c90b30752b7dff6f68a" - uid d94cd02db1a276929ff63739d0b5f80a45a14abf resolved "https://github.com/angular/dev-infra-private-build-tooling-builds.git#d94cd02db1a276929ff63739d0b5f80a45a14abf" dependencies: "@angular-devkit/build-angular" "15.1.0-next.0" @@ -399,7 +398,6 @@ "@angular/ng-dev@https://github.com/angular/dev-infra-private-ng-dev-builds.git#a2a71f76ee8a4cb4795f8a027d946f620e623b81": version "0.0.0-dd53634ba2a792fce0649c90b30752b7dff6f68a" - uid a2a71f76ee8a4cb4795f8a027d946f620e623b81 resolved "https://github.com/angular/dev-infra-private-ng-dev-builds.git#a2a71f76ee8a4cb4795f8a027d946f620e623b81" dependencies: "@yarnpkg/lockfile" "^1.1.0" @@ -2424,7 +2422,7 @@ "@jridgewell/gen-mapping" "^0.3.0" "@jridgewell/trace-mapping" "^0.3.9" -"@jridgewell/sourcemap-codec@^1.4.10", "@jridgewell/sourcemap-codec@^1.4.13": +"@jridgewell/sourcemap-codec@^1.4.10", "@jridgewell/sourcemap-codec@^1.4.13", "@jridgewell/sourcemap-codec@^1.4.14": version "1.4.14" resolved "https://registry.yarnpkg.com/@jridgewell/sourcemap-codec/-/sourcemap-codec-1.4.14.tgz#add4c98d341472a289190b424efbdb096991bb24" integrity sha512-XPSJHWmi394fuUuzDnGz1wiKqWfo1yXecHQMRf2l6hztTO+nPru658AyDngaBe7isIxEkRsPR3FZh+s7iVa4Uw==