Skip to content

Commit

Permalink
refactor(compiler): replace deprecated sourcemap-codec (#48387)
Browse files Browse the repository at this point in the history
`sourcemap-codec` as been deprecated in favor of `@jridgewell/sourcemap-codec`.

See: https://www.npmjs.com/package/sourcemap-codec?activeTab=versions

PR Close #48387
  • Loading branch information
alan-agius4 authored and AndrewKushnir committed Dec 7, 2022
1 parent d814284 commit f273666
Show file tree
Hide file tree
Showing 11 changed files with 13 additions and 107 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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",
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-cli/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ esbuild(
"dependency-graph",
"magic-string",
"semver",
"sourcemap-codec",
"@jridgewell/sourcemap-codec",
"tslib",
"yargs",
],
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-cli/ngcc/test/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
98 changes: 3 additions & 95 deletions packages/compiler-cli/ngcc/test/rendering/renderer_spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -145,37 +144,14 @@ 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',
'sourceRoot': '',
'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 =
Expand All @@ -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],
});

Expand All @@ -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],
});
});
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-cli/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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"
},
Expand Down
2 changes: 1 addition & 1 deletion packages/compiler-cli/src/ngtsc/sourcemaps/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
)
Original file line number Diff line number Diff line change
Expand Up @@ -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';

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down
4 changes: 1 addition & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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"
Expand Down Expand Up @@ -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==
Expand Down

0 comments on commit f273666

Please sign in to comment.