Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade from source-map 0.6.1 to @cspotcode/source-map-consumer 0.8.0 #12486

Open
wants to merge 3 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
4 changes: 2 additions & 2 deletions e2e/coverage-handlebars/package.json
Expand Up @@ -6,7 +6,7 @@
"testEnvironment": "node"
},
"dependencies": {
"handlebars": "^4.7.3",
"source-map": "^0.6.1"
"@cspotcode/source-map": "0.8.0",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"handlebars": "^4.7.3"
}
}
9 changes: 8 additions & 1 deletion e2e/coverage-handlebars/yarn.lock
Expand Up @@ -5,6 +5,13 @@ __metadata:
version: 6
cacheKey: 8

"@cspotcode/source-map@npm:0.8.0":
version: 0.8.0
resolution: "@cspotcode/source-map@npm:0.8.0"
checksum: 2d6fa1f0fe0080e0466febf26d38b80f37bfe5641e089a8c8d78cafbd4d33424377abb48768fc1afd3f19fb941e1dbec8afd9e85a1f3ea9aca5ba44e721dbac4
languageName: node
linkType: hard

"handlebars@npm:^4.7.3":
version: 4.7.7
resolution: "handlebars@npm:4.7.7"
Expand Down Expand Up @@ -41,8 +48,8 @@ __metadata:
version: 0.0.0-use.local
resolution: "root-workspace-0b6124@workspace:."
dependencies:
"@cspotcode/source-map": 0.8.0
handlebars: ^4.7.3
source-map: ^0.6.1
languageName: unknown
linkType: soft

Expand Down
2 changes: 1 addition & 1 deletion packages/jest-reporters/package.json
Expand Up @@ -13,6 +13,7 @@
},
"dependencies": {
"@bcoe/v8-coverage": "^0.2.3",
"@cspotcode/source-map-consumer": "0.8.0",
"@jest/console": "^28.0.0-alpha.4",
"@jest/test-result": "^28.0.0-alpha.4",
"@jest/transform": "^28.0.0-alpha.4",
Expand All @@ -33,7 +34,6 @@
"jest-util": "^28.0.0-alpha.4",
"jest-worker": "^28.0.0-alpha.4",
"slash": "^3.0.0",
"source-map": "^0.6.0",
"string-length": "^4.0.1",
"terminal-link": "^2.0.0",
"v8-to-istanbul": "^8.1.0"
Expand Down
11 changes: 3 additions & 8 deletions packages/jest-reporters/src/CoverageReporter.ts
Expand Up @@ -7,14 +7,14 @@

import * as path from 'path';
import {mergeProcessCovs} from '@bcoe/v8-coverage';
import type {RawSourceMap} from '@cspotcode/source-map-consumer';
import chalk = require('chalk');
import glob = require('glob');
import * as fs from 'graceful-fs';
import istanbulCoverage = require('istanbul-lib-coverage');
import istanbulReport = require('istanbul-lib-report');
import libSourceMaps = require('istanbul-lib-source-maps');
import istanbulReports = require('istanbul-reports');
import type {RawSourceMap} from 'source-map';
import v8toIstanbul = require('v8-to-istanbul');
import type {
AggregatedResult,
Expand All @@ -34,12 +34,6 @@ import type {
Test,
} from './types';

// This is fixed in a newer versions of source-map, but our dependencies are still stuck on old versions
interface FixedRawSourceMap extends Omit<RawSourceMap, 'version'> {
version: number;
file?: string;
}

const FAIL_COLOR = chalk.bold.red;
const RUNNING_TEST_COLOR = chalk.bold.dim;

Expand Down Expand Up @@ -442,7 +436,7 @@ export default class CoverageReporter extends BaseReporter {
mergedCoverages.result.map(async res => {
const fileTransform = fileTransforms.get(res.url);

let sourcemapContent: FixedRawSourceMap | undefined = undefined;
let sourcemapContent: RawSourceMap | undefined = undefined;

if (
fileTransform?.sourceMapPath &&
Expand All @@ -461,6 +455,7 @@ export default class CoverageReporter extends BaseReporter {
originalSource: fileTransform.originalCode,
source: fileTransform.code,
sourceMap: {
// @ts-expect-error sourcemapContent has non-optional `file` property; TS thinks we are always overwriting `file: res.url`
sourcemap: {file: res.url, ...sourcemapContent},
},
}
Expand Down
4 changes: 2 additions & 2 deletions packages/jest-source-map/package.json
Expand Up @@ -17,9 +17,9 @@
"./package.json": "./package.json"
},
"dependencies": {
"@cspotcode/source-map-consumer": "0.8.0",
"callsites": "^3.0.0",
"graceful-fs": "^4.2.9",
"source-map": "^0.6.0"
"graceful-fs": "^4.2.9"
},
"devDependencies": {
"@types/graceful-fs": "^4.1.2"
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-source-map/src/__tests__/getCallsite.test.ts
Expand Up @@ -5,8 +5,8 @@
* LICENSE file in the root directory of this source tree.
*/

import SourceMap from '@cspotcode/source-map-consumer';
import * as fs from 'graceful-fs';
import SourceMap from 'source-map';
import getCallsite from '../getCallsite';

// Node 10.5.x compatibility
Expand Down
3 changes: 1 addition & 2 deletions packages/jest-source-map/src/getCallsite.ts
Expand Up @@ -5,9 +5,9 @@
* LICENSE file in the root directory of this source tree.
*/

import {SourceMapConsumer} from '@cspotcode/source-map-consumer';
import callsites = require('callsites');
import {readFileSync} from 'graceful-fs';
import {SourceMapConsumer} from 'source-map';
import type {SourceMapRegistry} from './types';

// Copied from https://github.com/rexxars/sourcemap-decorate-callsites/blob/5b9735a156964973a75dc62fd2c7f0c1975458e8/lib/index.js#L113-L158
Expand Down Expand Up @@ -57,7 +57,6 @@ export default function getCallsite(
if (sourceMapFileName) {
try {
const sourceMap = readFileSync(sourceMapFileName, 'utf8');
// @ts-expect-error: Not allowed to pass string
addSourceMapConsumer(stack, new SourceMapConsumer(sourceMap));
} catch {
// ignore
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-transform/package.json
Expand Up @@ -18,6 +18,7 @@
},
"dependencies": {
"@babel/core": "^7.1.0",
"@cspotcode/source-map-consumer": "0.8.0",
"@jest/types": "^28.0.0-alpha.4",
"babel-plugin-istanbul": "^6.1.1",
"chalk": "^4.0.0",
Expand All @@ -30,7 +31,6 @@
"micromatch": "^4.0.4",
"pirates": "^4.0.4",
"slash": "^3.0.0",
"source-map": "^0.6.1",
"write-file-atomic": "^4.0.1"
},
"devDependencies": {
Expand Down
2 changes: 1 addition & 1 deletion packages/jest-transform/src/types.ts
Expand Up @@ -5,7 +5,7 @@
* LICENSE file in the root directory of this source tree.
*/

import type {RawSourceMap} from 'source-map';
import type {RawSourceMap} from '@cspotcode/source-map-consumer';
import type {Config, TransformTypes} from '@jest/types';

export interface ShouldInstrumentOptions
Expand Down
6 changes: 3 additions & 3 deletions yarn.lock
Expand Up @@ -2727,6 +2727,7 @@ __metadata:
resolution: "@jest/reporters@workspace:packages/jest-reporters"
dependencies:
"@bcoe/v8-coverage": ^0.2.3
"@cspotcode/source-map-consumer": 0.8.0
"@jest/console": ^28.0.0-alpha.4
"@jest/test-result": ^28.0.0-alpha.4
"@jest/test-utils": ^28.0.0-alpha.4
Expand Down Expand Up @@ -2758,7 +2759,6 @@ __metadata:
jest-worker: ^28.0.0-alpha.4
mock-fs: ^5.1.2
slash: ^3.0.0
source-map: ^0.6.0
string-length: ^4.0.1
strip-ansi: ^6.0.0
terminal-link: ^2.0.0
Expand All @@ -2783,10 +2783,10 @@ __metadata:
version: 0.0.0-use.local
resolution: "@jest/source-map@workspace:packages/jest-source-map"
dependencies:
"@cspotcode/source-map-consumer": 0.8.0
"@types/graceful-fs": ^4.1.2
callsites: ^3.0.0
graceful-fs: ^4.2.9
source-map: ^0.6.0
languageName: unknown
linkType: soft

Expand Down Expand Up @@ -2844,6 +2844,7 @@ __metadata:
resolution: "@jest/transform@workspace:packages/jest-transform"
dependencies:
"@babel/core": ^7.1.0
"@cspotcode/source-map-consumer": 0.8.0
"@jest/test-utils": ^28.0.0-alpha.4
"@jest/types": ^28.0.0-alpha.4
"@types/babel__core": ^7.1.0
Expand All @@ -2864,7 +2865,6 @@ __metadata:
micromatch: ^4.0.4
pirates: ^4.0.4
slash: ^3.0.0
source-map: ^0.6.1
write-file-atomic: ^4.0.1
languageName: unknown
linkType: soft
Expand Down