@@ -63,6 +63,9 @@ describe('buildAndImportApp', () => {
6363 entryPoints : [ filePath ] ,
6464 bundle : true ,
6565 write : false ,
66+ sourcemap : false ,
67+ sourcesContent : false ,
68+ sourceRoot : process . cwd ( ) ,
6669 format : 'esm' ,
6770 target : 'node20' ,
6871 jsx : 'automatic' ,
@@ -97,6 +100,9 @@ describe('buildAndImportApp', () => {
97100 entryPoints : [ filePath ] ,
98101 bundle : true ,
99102 write : false ,
103+ sourcemap : false ,
104+ sourcesContent : false ,
105+ sourceRoot : process . cwd ( ) ,
100106 format : 'esm' ,
101107 target : 'node20' ,
102108 jsx : 'automatic' ,
@@ -134,6 +140,9 @@ describe('buildAndImportApp', () => {
134140 entryPoints : [ filePath ] ,
135141 bundle : true ,
136142 write : false ,
143+ sourcemap : false ,
144+ sourcesContent : false ,
145+ sourceRoot : process . cwd ( ) ,
137146 format : 'esm' ,
138147 target : 'node20' ,
139148 jsx : 'automatic' ,
@@ -174,6 +183,33 @@ describe('buildAndImportApp', () => {
174183 expect ( result ) . toBe ( mockApp )
175184 } )
176185
186+ it ( 'should build and import file with sourcemap' , async ( ) => {
187+ const mockApp = new Hono ( )
188+ const filePath = '/path/to/app.ts'
189+ const bundledCode = 'export default app;'
190+
191+ setupBundledCode ( bundledCode )
192+
193+ // Mock dynamic import
194+ const dataUrl = `data:text/javascript;base64,${ Buffer . from ( `${ bundledCode } \n//# sourceURL=file://${ process . cwd ( ) } /__hono_cli_bundle__.js` ) . toString ( 'base64' ) } `
195+ vi . doMock ( dataUrl , ( ) => ( { default : mockApp } ) )
196+
197+ const buildIterator = buildAndImportApp ( filePath , { sourcemap : true } )
198+ const result = ( await buildIterator . next ( ) ) . value
199+
200+ expect ( mockEsbuild ) . toHaveBeenCalledWith (
201+ expect . objectContaining ( {
202+ entryPoints : [ filePath ] ,
203+ jsx : 'automatic' ,
204+ jsxImportSource : 'hono/jsx' ,
205+ sourcemap : true ,
206+ sourcesContent : false ,
207+ sourceRoot : process . cwd ( ) ,
208+ } )
209+ )
210+ expect ( result ) . toBe ( mockApp )
211+ } )
212+
177213 it ( 'should handle esbuild errors' , async ( ) => {
178214 const filePath = '/path/to/app.ts'
179215 const buildError = new Error ( 'Build failed' )
@@ -202,6 +238,9 @@ describe('buildAndImportApp', () => {
202238 entryPoints : [ filePath ] ,
203239 bundle : true ,
204240 write : false ,
241+ sourcemap : false ,
242+ sourcesContent : false ,
243+ sourceRoot : process . cwd ( ) ,
205244 format : 'esm' ,
206245 target : 'node20' ,
207246 jsx : 'automatic' ,
0 commit comments