Skip to content

Commit

Permalink
fix: source map warning on node 15
Browse files Browse the repository at this point in the history
Fixes #903
  • Loading branch information
connor4312 committed Jan 8, 2021
1 parent abeafc1 commit 9de0550
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ This changelog records changes to stable releases since 1.50.2. "TBA" changes he
- fix: fix: better handle html served as index and without extensions ([#883](https://github.com/microsoft/vscode-js-debug/issues/883), [#884](https://github.com/microsoft/vscode-js-debug/issues/884))
- docs: remove preview terminology from js-debug ([#894](https://github.com/microsoft/vscode-js-debug/issues/894))
- fix: debugger statements being missed if directly stepped on the first executable line of a new script early in execution
- fix: source map warning on node 15 ([#903](https://github.com/microsoft/vscode-js-debug/issues/903))

## v1.52.2 - 2020-12-07

Expand Down
3 changes: 1 addition & 2 deletions src/adapter/scriptSkipper/implementation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { ICdpApi } from '../../cdp/connection';
import { MapUsingProjection } from '../../common/datastructure/mapUsingProjection';
import { EventEmitter } from '../../common/events';
import { ILogger, LogTag } from '../../common/logging';
import { node15InternalsPrefix } from '../../common/node15Internal';
import { trailingEdgeThrottle } from '../../common/objUtils';
import * as pathUtils from '../../common/pathUtils';
import { getDeferred, IDeferred } from '../../common/promiseUtil';
Expand All @@ -32,8 +33,6 @@ interface ISharedSkipToggleEvent {
params: Dap.ToggleSkipFileStatusParams;
}

const node15InternalsPrefix = 'node:';

@injectable()
export class ScriptSkipper {
private static sharedSkipsEmitter = new EventEmitter<ISharedSkipToggleEvent>();
Expand Down
2 changes: 1 addition & 1 deletion src/adapter/sources.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1104,7 +1104,7 @@ export class SourceContainer {

const sourceMap = this._sourceMaps.get(source.sourceMap.url);
if (
!this.logger.assert(sourceMap, 'Unrecognized source mpa url in waitForSourceMapSources()')
!this.logger.assert(sourceMap, 'Unrecognized source map url in waitForSourceMapSources()')
) {
return [];
}
Expand Down
2 changes: 1 addition & 1 deletion src/adapter/threads.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ export class Thread implements IVariableStoreDelegate {
// but in practice that usually means new scripts with new source maps anyway.
resolvedSourceMapUrl = urlUtils.isDataUri(event.sourceMapURL)
? event.sourceMapURL
: event.url && urlUtils.completeUrl(event.url, event.sourceMapURL);
: (event.url && urlUtils.completeUrl(event.url, event.sourceMapURL)) || event.url;
if (!resolvedSourceMapUrl) {
this._dap.with(dap =>
errors.reportToConsole(dap, `Could not load source map from ${event.sourceMapURL}`),
Expand Down
8 changes: 8 additions & 0 deletions src/common/node15Internal.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*---------------------------------------------------------
* Copyright (C) Microsoft Corporation. All rights reserved.
*--------------------------------------------------------*/

/**
* URL prefix that Node 15 and onwards uses for its internals.
*/
export const node15InternalsPrefix = 'node:';
7 changes: 7 additions & 0 deletions src/targets/sourcePathResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import match from 'micromatch';
import * as path from 'path';
import { ILogger, LogTag } from '../common/logging';
import { node15InternalsPrefix } from '../common/node15Internal';
import {
fixDriveLetter,
fixDriveLetterAndSlashes,
Expand Down Expand Up @@ -71,6 +72,12 @@ export abstract class SourcePathResolverBase<T extends ISourcePathResolverOption
* following the `resolveSourceMapPaths`
*/
public shouldResolveSourceMap({ sourceMapUrl, compiledPath }: ISourceMapMetadata) {
// Node 15 started including some source-mapped internals (acorn), but
// they don't ship source maps in the build. Never try to resolve those.
if (compiledPath.startsWith(node15InternalsPrefix)) {
return false;
}

if (!this.resolveLocations || this.resolveLocations.length === 0) {
return true;
}
Expand Down

0 comments on commit 9de0550

Please sign in to comment.