Skip to content

Commit 2f244c0

Browse files
committed
add test case from #4104
1 parent 1dde994 commit 2f244c0

File tree

2 files changed

+57
-1
lines changed

2 files changed

+57
-1
lines changed

CHANGELOG.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
This fixes a regression from version 0.25.0 where esbuild didn't correctly resolve relative paths contained within source maps in inline `sourceMappingURL` data URLs. The paths were incorrectly being passed through as-is instead of being resolved relative to the source file containing the `sourceMappingURL` comment, which was due to the data URL not being a file URL. This regression has been fixed, and this case now has test coverage.
88

9-
* Fix invalid generated source maps ([#4080](https://github.com/evanw/esbuild/issues/4080), [#4082](https://github.com/evanw/esbuild/issues/4082), [#4107](https://github.com/evanw/esbuild/issues/4107))
9+
* Fix invalid generated source maps ([#4080](https://github.com/evanw/esbuild/issues/4080), [#4082](https://github.com/evanw/esbuild/issues/4082), [#4104](https://github.com/evanw/esbuild/issues/4104), [#4107](https://github.com/evanw/esbuild/issues/4107))
1010

1111
This release fixes a regression from version 0.24.1 that could cause esbuild to generate invalid source maps. Specifically under certain conditions, esbuild could generate a mapping with an out-of-bounds source index. It was introduced by code that attempted to improve esbuild's handling of "null" entries in source maps (i.e. mappings with a generated position but no original position). This regression has been fixed.
1212

scripts/verify-source-map.js

+56
Original file line numberDiff line numberDiff line change
@@ -573,6 +573,55 @@ const toSearchNestedFoldersIssue4070 = {
573573
'bar': 'src/app/app.config.js',
574574
}
575575

576+
const testCaseMissingSourcesIssue4104 = {
577+
'entry.js': `import { bootstrapApplication } from '@angular/platform-browser';
578+
import { AppComponent } from './app.js';
579+
580+
bootstrapApplication(AppComponent)
581+
.catch((err) => console.error(err));`,
582+
'app.component.html': `<div>`,
583+
'app.js': `import { __decorate } from "tslib";
584+
import __NG_CLI_RESOURCE__0 from "./app.component.html";
585+
import { Component } from '@angular/core';
586+
import { RouterOutlet } from '@angular/router';
587+
let AppComponent = class AppComponent {
588+
title = 'ng19-sourcemap-repro';
589+
onClick() {
590+
debugger;
591+
}
592+
};
593+
AppComponent = __decorate([
594+
Component({
595+
selector: 'app-root',
596+
imports: [RouterOutlet],
597+
template: __NG_CLI_RESOURCE__0,
598+
})
599+
], AppComponent);
600+
export { AppComponent };
601+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIj` +
602+
`oiYXBwLmNvbXBvbmVudC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbImFwcC5jb` +
603+
`21wb25lbnQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQSxPQUFPLEVBQUUs` +
604+
`U0FBUyxFQUFFLE1BQU0sZUFBZSxDQUFDO0FBQzFDLE9BQU8sRUFBRSxZQUFZLEVBQUUsTUF` +
605+
`BTSxpQkFBaUIsQ0FBQztBQU94QyxJQUFNLFlBQVksR0FBbEIsTUFBTSxZQUFZO0lBQ3ZCLE` +
606+
`tBQUssR0FBRyxzQkFBc0IsQ0FBQztJQUUvQixPQUFPO1FBQ0wsUUFBUSxDQUFDO0lBQ1gsQ` +
607+
`0FBQztDQUNGLENBQUE7QUFOWSxZQUFZO0lBTHhCLFNBQVMsQ0FBQztRQUNULFFBQVEsRUFB` +
608+
`RSxVQUFVO1FBQ3BCLE9BQU8sRUFBRSxDQUFDLFlBQVksQ0FBQztRQUN2Qiw4QkFBbUM7S0F` +
609+
`DcEMsQ0FBQztHQUNXLFlBQVksQ0FNeEIiLCJzb3VyY2VzQ29udGVudCI6WyJpbXBvcnQgey` +
610+
`BDb21wb25lbnQgfSBmcm9tICdAYW5ndWxhci9jb3JlJztcbmltcG9ydCB7IFJvdXRlck91d` +
611+
`GxldCB9IGZyb20gJ0Bhbmd1bGFyL3JvdXRlcic7XG5cbkBDb21wb25lbnQoe1xuICBzZWxl` +
612+
`Y3RvcjogJ2FwcC1yb290JyxcbiAgaW1wb3J0czogW1JvdXRlck91dGxldF0sXG4gIHRlbXB` +
613+
`sYXRlVXJsOiAnLi9hcHAuY29tcG9uZW50Lmh0bWwnLFxufSlcbmV4cG9ydCBjbGFzcyBBcH` +
614+
`BDb21wb25lbnQge1xuICB0aXRsZSA9ICduZzE5LXNvdXJjZW1hcC1yZXBybyc7XG5cbiAgb` +
615+
`25DbGljaygpIHtcbiAgICBkZWJ1Z2dlcjtcbiAgfVxufVxuIl19`,
616+
}
617+
618+
const toSearchMissingSourcesIssue4104 = {
619+
'@angular/platform-browser': 'entry.js',
620+
'@angular/core': 'app.component.ts',
621+
'ng19-sourcemap-repro': 'app.component.ts',
622+
'app-root': 'app.component.ts',
623+
}
624+
576625
async function check(kind, testCase, toSearch, { outfile, flags, entryPoints, crlf, followUpFlags = [], checkFirstChunk }) {
577626
let failed = 0
578627

@@ -1048,6 +1097,13 @@ async function main() {
10481097
entryPoints: ['entry.js'],
10491098
crlf,
10501099
}),
1100+
check('issue-4104' + suffix, testCaseMissingSourcesIssue4104, toSearchMissingSourcesIssue4104, {
1101+
outfile: 'out.js',
1102+
flags: flags.concat('--format=esm', '--sourcemap', '--bundle', '--loader:.html=text', '--packages=external'),
1103+
entryPoints: ['entry.js'],
1104+
crlf,
1105+
followUpFlags: ['--packages=external'],
1106+
}),
10511107

10521108
// Checks for the "names" field
10531109
checkNames('names' + suffix, testCaseNames, {

0 commit comments

Comments
 (0)