diff --git a/packages/compiler-cli/ngcc/BUILD.bazel b/packages/compiler-cli/ngcc/BUILD.bazel index ac5df645db..6241361c09 100644 --- a/packages/compiler-cli/ngcc/BUILD.bazel +++ b/packages/compiler-cli/ngcc/BUILD.bazel @@ -25,6 +25,7 @@ ts_library( "//packages/compiler-cli/src/ngtsc/perf", "//packages/compiler-cli/src/ngtsc/reflection", "//packages/compiler-cli/src/ngtsc/scope", + "//packages/compiler-cli/src/ngtsc/sourcemaps", "//packages/compiler-cli/src/ngtsc/transform", "//packages/compiler-cli/src/ngtsc/translator", "//packages/compiler-cli/src/ngtsc/util", @@ -36,8 +37,6 @@ ts_library( "@npm//dependency-graph", "@npm//magic-string", "@npm//semver", - "@npm//source-map", - "@npm//sourcemap-codec", "@npm//typescript", ], ) diff --git a/packages/compiler-cli/ngcc/src/rendering/source_maps.ts b/packages/compiler-cli/ngcc/src/rendering/source_maps.ts index 364c37e389..e15e2cdaf5 100644 --- a/packages/compiler-cli/ngcc/src/rendering/source_maps.ts +++ b/packages/compiler-cli/ngcc/src/rendering/source_maps.ts @@ -11,8 +11,7 @@ import * as ts from 'typescript'; import {absoluteFrom, absoluteFromSourceFile, basename, FileSystem} from '../../../src/ngtsc/file_system'; import {Logger} from '../../../src/ngtsc/logging'; -import {RawSourceMap} from '../sourcemaps/raw_source_map'; -import {SourceFileLoader} from '../sourcemaps/source_file_loader'; +import {RawSourceMap, SourceFileLoader} from '../../../src/ngtsc/sourcemaps'; import {FileToWrite} from './utils'; diff --git a/packages/compiler-cli/src/ngtsc/sourcemaps/BUILD.bazel b/packages/compiler-cli/src/ngtsc/sourcemaps/BUILD.bazel new file mode 100644 index 0000000000..f4d1adee28 --- /dev/null +++ b/packages/compiler-cli/src/ngtsc/sourcemaps/BUILD.bazel @@ -0,0 +1,18 @@ +load("//tools:defaults.bzl", "ts_library") + +package(default_visibility = ["//visibility:public"]) + +ts_library( + name = "sourcemaps", + srcs = ["index.ts"] + glob([ + "src/**/*.ts", + ]), + deps = [ + "//packages/compiler-cli/src/ngtsc/file_system", + "//packages/compiler-cli/src/ngtsc/logging", + "@npm//@types/convert-source-map", + "@npm//@types/node", + "@npm//source-map", + "@npm//sourcemap-codec", + ], +) diff --git a/packages/compiler-cli/src/ngtsc/sourcemaps/README.md b/packages/compiler-cli/src/ngtsc/sourcemaps/README.md new file mode 100644 index 0000000000..22ec327b30 --- /dev/null +++ b/packages/compiler-cli/src/ngtsc/sourcemaps/README.md @@ -0,0 +1,3 @@ +# Source-map handling + +Here there are classes for loading and merging source-maps. \ No newline at end of file diff --git a/packages/compiler-cli/src/ngtsc/sourcemaps/index.ts b/packages/compiler-cli/src/ngtsc/sourcemaps/index.ts new file mode 100644 index 0000000000..583e3b1a0c --- /dev/null +++ b/packages/compiler-cli/src/ngtsc/sourcemaps/index.ts @@ -0,0 +1,10 @@ +/** + * @license + * Copyright Google LLC All Rights Reserved. + * + * 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 + */ +export {RawSourceMap} from './src/raw_source_map'; +export {Mapping, SourceFile} from './src/source_file'; +export {SourceFileLoader} from './src/source_file_loader'; diff --git a/packages/compiler-cli/ngcc/src/sourcemaps/raw_source_map.ts b/packages/compiler-cli/src/ngtsc/sourcemaps/src/raw_source_map.ts similarity index 100% rename from packages/compiler-cli/ngcc/src/sourcemaps/raw_source_map.ts rename to packages/compiler-cli/src/ngtsc/sourcemaps/src/raw_source_map.ts diff --git a/packages/compiler-cli/ngcc/src/sourcemaps/segment_marker.ts b/packages/compiler-cli/src/ngtsc/sourcemaps/src/segment_marker.ts similarity index 100% rename from packages/compiler-cli/ngcc/src/sourcemaps/segment_marker.ts rename to packages/compiler-cli/src/ngtsc/sourcemaps/src/segment_marker.ts diff --git a/packages/compiler-cli/ngcc/src/sourcemaps/source_file.ts b/packages/compiler-cli/src/ngtsc/sourcemaps/src/source_file.ts similarity index 99% rename from packages/compiler-cli/ngcc/src/sourcemaps/source_file.ts rename to packages/compiler-cli/src/ngtsc/sourcemaps/src/source_file.ts index 79a98e6802..fad6e88705 100644 --- a/packages/compiler-cli/ngcc/src/sourcemaps/source_file.ts +++ b/packages/compiler-cli/src/ngtsc/sourcemaps/src/source_file.ts @@ -8,7 +8,7 @@ import {removeComments, removeMapFileComments} from 'convert-source-map'; import {decode, encode, SourceMapMappings, SourceMapSegment} from 'sourcemap-codec'; -import {AbsoluteFsPath, dirname, relative} from '../../../src/ngtsc/file_system'; +import {AbsoluteFsPath, dirname, relative} from '../../file_system'; import {RawSourceMap} from './raw_source_map'; import {compareSegments, offsetSegment, SegmentMarker} from './segment_marker'; diff --git a/packages/compiler-cli/ngcc/src/sourcemaps/source_file_loader.ts b/packages/compiler-cli/src/ngtsc/sourcemaps/src/source_file_loader.ts similarity index 97% rename from packages/compiler-cli/ngcc/src/sourcemaps/source_file_loader.ts rename to packages/compiler-cli/src/ngtsc/sourcemaps/src/source_file_loader.ts index bb25c4c092..1b7d49333e 100644 --- a/packages/compiler-cli/ngcc/src/sourcemaps/source_file_loader.ts +++ b/packages/compiler-cli/src/ngtsc/sourcemaps/src/source_file_loader.ts @@ -7,8 +7,8 @@ */ import {commentRegex, fromComment, mapFileCommentRegex} from 'convert-source-map'; -import {absoluteFrom, AbsoluteFsPath, FileSystem} from '../../../src/ngtsc/file_system'; -import {Logger} from '../../../src/ngtsc/logging'; +import {absoluteFrom, AbsoluteFsPath, FileSystem} from '../../file_system'; +import {Logger} from '../../logging'; import {RawSourceMap} from './raw_source_map'; import {SourceFile} from './source_file'; diff --git a/packages/compiler-cli/src/ngtsc/sourcemaps/test/BUILD.bazel b/packages/compiler-cli/src/ngtsc/sourcemaps/test/BUILD.bazel new file mode 100644 index 0000000000..d678c8a3cf --- /dev/null +++ b/packages/compiler-cli/src/ngtsc/sourcemaps/test/BUILD.bazel @@ -0,0 +1,28 @@ +load("//tools:defaults.bzl", "jasmine_node_test", "ts_library") + +package(default_visibility = ["//visibility:public"]) + +ts_library( + name = "test_lib", + testonly = True, + srcs = glob([ + "**/*.ts", + ]), + deps = [ + "//packages/compiler-cli/src/ngtsc/file_system", + "//packages/compiler-cli/src/ngtsc/file_system/testing", + "//packages/compiler-cli/src/ngtsc/logging/testing", + "//packages/compiler-cli/src/ngtsc/sourcemaps", + "@npm//@types/convert-source-map", + "@npm//convert-source-map", + "@npm//sourcemap-codec", + ], +) + +jasmine_node_test( + name = "test", + bootstrap = ["//tools/testing:node_no_angular_es5"], + deps = [ + ":test_lib", + ], +) diff --git a/packages/compiler-cli/ngcc/test/sourcemaps/segment_marker_spec.ts b/packages/compiler-cli/src/ngtsc/sourcemaps/test/segment_marker_spec.ts similarity index 97% rename from packages/compiler-cli/ngcc/test/sourcemaps/segment_marker_spec.ts rename to packages/compiler-cli/src/ngtsc/sourcemaps/test/segment_marker_spec.ts index 847ec6c6ed..d3fedc69b5 100644 --- a/packages/compiler-cli/ngcc/test/sourcemaps/segment_marker_spec.ts +++ b/packages/compiler-cli/src/ngtsc/sourcemaps/test/segment_marker_spec.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 {compareSegments, offsetSegment} from '../../src/sourcemaps/segment_marker'; -import {computeStartOfLinePositions} from '../../src/sourcemaps/source_file'; +import {compareSegments, offsetSegment} from '../src/segment_marker'; +import {computeStartOfLinePositions} from '../src/source_file'; describe('SegmentMarker utils', () => { describe('compareSegments()', () => { diff --git a/packages/compiler-cli/ngcc/test/sourcemaps/source_file_loader_spec.ts b/packages/compiler-cli/src/ngtsc/sourcemaps/test/source_file_loader_spec.ts similarity index 96% rename from packages/compiler-cli/ngcc/test/sourcemaps/source_file_loader_spec.ts rename to packages/compiler-cli/src/ngtsc/sourcemaps/test/source_file_loader_spec.ts index 7a51e58376..3d68671674 100644 --- a/packages/compiler-cli/ngcc/test/sourcemaps/source_file_loader_spec.ts +++ b/packages/compiler-cli/src/ngtsc/sourcemaps/test/source_file_loader_spec.ts @@ -5,13 +5,13 @@ * 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 {absoluteFrom, FileSystem, getFileSystem} from '@angular/compiler-cli/src/ngtsc/file_system'; import {fromObject} from 'convert-source-map'; -import {runInEachFileSystem} from '../../../src/ngtsc/file_system/testing'; -import {MockLogger} from '../../../src/ngtsc/logging/testing'; -import {RawSourceMap} from '../../src/sourcemaps/raw_source_map'; -import {SourceFileLoader as SourceFileLoader} from '../../src/sourcemaps/source_file_loader'; +import {absoluteFrom, FileSystem, getFileSystem} from '../../file_system'; +import {runInEachFileSystem} from '../../file_system/testing'; +import {MockLogger} from '../../logging/testing'; +import {RawSourceMap} from '../src/raw_source_map'; +import {SourceFileLoader as SourceFileLoader} from '../src/source_file_loader'; runInEachFileSystem(() => { describe('SourceFileLoader', () => { diff --git a/packages/compiler-cli/ngcc/test/sourcemaps/source_file_spec.ts b/packages/compiler-cli/src/ngtsc/sourcemaps/test/source_file_spec.ts similarity index 98% rename from packages/compiler-cli/ngcc/test/sourcemaps/source_file_spec.ts rename to packages/compiler-cli/src/ngtsc/sourcemaps/test/source_file_spec.ts index da3b72de0b..9162e37245 100644 --- a/packages/compiler-cli/ngcc/test/sourcemaps/source_file_spec.ts +++ b/packages/compiler-cli/src/ngtsc/sourcemaps/test/source_file_spec.ts @@ -7,11 +7,11 @@ */ import {encode} from 'sourcemap-codec'; -import {absoluteFrom} from '../../../src/ngtsc/file_system'; -import {runInEachFileSystem} from '../../../src/ngtsc/file_system/testing'; -import {RawSourceMap} from '../../src/sourcemaps/raw_source_map'; -import {SegmentMarker} from '../../src/sourcemaps/segment_marker'; -import {computeStartOfLinePositions, ensureOriginalSegmentLinks, extractOriginalSegments, findLastMappingIndexBefore, Mapping, parseMappings, SourceFile} from '../../src/sourcemaps/source_file'; +import {absoluteFrom} from '../../file_system'; +import {runInEachFileSystem} from '../../file_system/testing'; +import {RawSourceMap} from '../src/raw_source_map'; +import {SegmentMarker} from '../src/segment_marker'; +import {computeStartOfLinePositions, ensureOriginalSegmentLinks, extractOriginalSegments, findLastMappingIndexBefore, Mapping, parseMappings, SourceFile} from '../src/source_file'; runInEachFileSystem(() => { describe('SourceFile and utilities', () => {