Skip to content

Commit

Permalink
Remove changes that are done by the PR to resolve-uri
Browse files Browse the repository at this point in the history
  • Loading branch information
onigoetz committed Mar 4, 2024
1 parent 1a8b1ad commit cc2da5c
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 295 deletions.
45 changes: 0 additions & 45 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@
"typescript": "4.5.5"
},
"dependencies": {
"@ampproject/remapping": "^2.2.0",
"@jridgewell/gen-mapping": "^0.3.0",
"@jridgewell/resolve-uri": "^3.0.7",
"@jridgewell/trace-mapping": "^0.3.11"
Expand Down
40 changes: 8 additions & 32 deletions src/source-map.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import remapping from '@ampproject/remapping';
import resolveUri from '@jridgewell/resolve-uri';

import {
AnyMap,
originalPositionFor,
Expand All @@ -15,6 +15,7 @@ import {
toEncodedMap,
setSourceContent,
fromMap,
applySourceMap,
} from '@jridgewell/gen-mapping';

import type {
Expand All @@ -28,8 +29,6 @@ export type { TraceMap, SourceMapInput, SectionedSourceMapInput, DecodedSourceMa
import type { Mapping, EncodedSourceMap } from '@jridgewell/gen-mapping';
export type { Mapping, EncodedSourceMap };

import { join, relative } from './util';

function resolve(input: string, base: string | undefined): string {
// The base is always treated as a directory, if it's not empty.
// https://github.com/mozilla/source-map/blob/8cb3ee57/lib/util.js#L327
Expand Down Expand Up @@ -173,36 +172,13 @@ export class SourceMapGenerator {
sourceFile?: string,
sourceMapPath?: string,
) {
// If the SourceMap has no file property, we will use `sourceFile`
if (sourceMapConsumer.file == null) {
if (sourceFile == null) {
throw new Error(
'SourceMapGenerator.prototype.applySourceMap requires either an explicit source file, ' +
'or the source map\'s "file" property. Both were omitted.',
);
}
sourceMapConsumer.file = sourceFile;
}

const sourceRoot = this._map.sourceRoot;

const remapped = remapping(
[toDecodedMap(this._map) as SourceMapInput, sourceMapConsumer],
(_, ctx) => {
if (sourceMapPath || sourceRoot) {
if (sourceMapPath != null) {
ctx.source = join(sourceMapPath, ctx.source);
}

if (sourceRoot != null) {
ctx.source = relative(sourceRoot, ctx.source);
}
}
},
{ decodedMappings: true },
// TODO :: not sure how sourceMapConsumer should be typed / converted
applySourceMap(
this._map,
new AnyMap(sourceMapConsumer) as unknown as any,
sourceFile,
sourceMapPath,
);

this._map = fromMap(remapped as DecodedSourceMap);
}

toJSON(): ReturnType<typeof toEncodedMap> {
Expand Down
217 changes: 0 additions & 217 deletions src/util.ts

This file was deleted.

0 comments on commit cc2da5c

Please sign in to comment.