@@ -55,6 +55,50 @@ describeBuilder(buildWebpackBrowser, BROWSER_BUILDER_INFO, (harness) => {
55
55
harness . expectFile ( 'dist/main.js' ) . content . toContain ( '"from-async-js-function"' ) ;
56
56
} ) ;
57
57
58
+ it ( 'creates correct sourcemaps when downleveling async functions' , async ( ) => {
59
+ // Set TypeScript configuration target to ES2017 to enable native async
60
+ await harness . modifyFile ( 'src/tsconfig.app.json' , ( content ) => {
61
+ const tsconfig = JSON . parse ( content ) ;
62
+ if ( ! tsconfig . compilerOptions ) {
63
+ tsconfig . compilerOptions = { } ;
64
+ }
65
+ tsconfig . compilerOptions . target = 'es2017' ;
66
+
67
+ return JSON . stringify ( tsconfig ) ;
68
+ } ) ;
69
+
70
+ // Add a JavaScript file with async code
71
+ await harness . writeFile (
72
+ 'src/async-test.js' ,
73
+ 'async function testJs() { console.log("from-async-js-function"); }' ,
74
+ ) ;
75
+
76
+ // Add an async function to the project as well as JavaScript file
77
+ // The type `Void123` is used as a unique identifier for the final sourcemap
78
+ // If sourcemaps are not properly propagated then it will not be in the final sourcemap
79
+ await harness . modifyFile (
80
+ 'src/main.ts' ,
81
+ ( content ) =>
82
+ 'import "./async-test";\n' +
83
+ content +
84
+ '\ntype Void123 = void;' +
85
+ `\nasync function testApp(): Promise<Void123> { console.log("from-async-app-function"); }` ,
86
+ ) ;
87
+
88
+ harness . useTarget ( 'build' , {
89
+ ...BASE_OPTIONS ,
90
+ sourceMap : {
91
+ scripts : true ,
92
+ } ,
93
+ } ) ;
94
+
95
+ const { result } = await harness . executeOnce ( ) ;
96
+
97
+ expect ( result ?. success ) . toBe ( true ) ;
98
+ harness . expectFile ( 'dist/main.js' ) . content . not . toMatch ( / \s a s y n c \s / ) ;
99
+ harness . expectFile ( 'dist/main.js.map' ) . content . toContain ( 'Promise<Void123>' ) ;
100
+ } ) ;
101
+
58
102
it ( 'downlevels async functions when targetting greater than ES2017' , async ( ) => {
59
103
// Set TypeScript configuration target greater than ES2017 to enable native async
60
104
await harness . modifyFile ( 'src/tsconfig.app.json' , ( content ) => {
0 commit comments