@@ -3,6 +3,7 @@ import type { PleasantestContext, PleasantestUtils } from 'pleasantest';
33import { printErrorFrames } from '../test-utils' ;
44import vuePlugin from 'rollup-plugin-vue' ;
55import aliasPlugin from '@rollup/plugin-alias' ;
6+ import babel from '@rollup/plugin-babel' ;
67import ansiRegex from 'ansi-regex' ;
78
89const createHeading = async ( {
@@ -192,6 +193,23 @@ test(
192193 ) ,
193194) ;
194195
196+ test (
197+ 'Line/column offsets for source-mapped runtime error is correct even with esbuild disabled' ,
198+ withBrowser ( { moduleServer : { esbuild : false } } , async ( { utils } ) => {
199+ const error = await utils
200+ . runJS ( 'console.log(nothing)' )
201+ . catch ( ( error ) => error ) ;
202+ expect ( await printErrorFrames ( error ) ) . toMatchInlineSnapshot ( `
203+ "ReferenceError: nothing is not defined
204+ -------------------------------------------------------
205+ tests/utils/runJS.test.tsx
206+
207+ .runJS('console.log(nothing)')
208+ ^"
209+ ` ) ;
210+ } ) ,
211+ ) ;
212+
195213test (
196214 'allows importing .tsx file, and errors from imported file are source mapped' ,
197215 withBrowser ( async ( { utils, page } ) => {
@@ -467,3 +485,37 @@ test(
467485 } ,
468486 ) ,
469487) ;
488+
489+ test (
490+ '@rollup/plugin-babel works' ,
491+ withBrowser (
492+ {
493+ moduleServer : {
494+ esbuild : false ,
495+ plugins : [
496+ babel ( {
497+ extensions : [ '.js' , '.ts' , '.tsx' , '.mjs' ] ,
498+ babelHelpers : 'bundled' ,
499+ presets : [ '@babel/preset-typescript' ] ,
500+ } ) ,
501+ ] ,
502+ } ,
503+ } ,
504+ async ( { utils } ) => {
505+ await utils . runJS ( "const foo: string = 'hello'" ) ;
506+
507+ // Check that source map from babel works correctly
508+ const error = await utils
509+ . runJS ( 'console.log(nothing)' )
510+ . catch ( ( error ) => error ) ;
511+ expect ( await printErrorFrames ( error ) ) . toMatchInlineSnapshot ( `
512+ "ReferenceError: nothing is not defined
513+ -------------------------------------------------------
514+ tests/utils/runJS.test.tsx
515+
516+ .runJS('console.log(nothing)')
517+ ^"
518+ ` ) ;
519+ } ,
520+ ) ,
521+ ) ;
0 commit comments