@@ -1193,6 +1193,65 @@ describe.skipIf(lt(denoVersion, '2.4.2'))(
11931193
11941194 await cleanup ( )
11951195 } )
1196+
1197+ test ( 'Importing from root vendor directory is handled' , async ( ) => {
1198+ const systemLogger = vi . fn ( )
1199+ const { basePath, cleanup, distPath } = await useFixture ( 'imports_vendor' , { copyDirectory : true } )
1200+ const declarations : Declaration [ ] = [
1201+ {
1202+ function : 'func1' ,
1203+ path : '/func1' ,
1204+ } ,
1205+ ]
1206+
1207+ await bundle ( [ join ( basePath , 'netlify/edge-functions' ) ] , distPath , declarations , {
1208+ basePath,
1209+ configPath : join ( basePath , '.netlify/edge-functions/config.json' ) ,
1210+ importMapPaths : [ resolve ( basePath , 'import_map.json' ) ] ,
1211+ featureFlags : {
1212+ edge_bundler_generate_tarball : true ,
1213+ } ,
1214+ systemLogger,
1215+ } )
1216+
1217+ expect (
1218+ systemLogger . mock . calls . find ( ( call ) => call [ 0 ] === 'Could not track dependencies in edge function:' ) ,
1219+ ) . toBeUndefined ( )
1220+
1221+ const expectedOutput = {
1222+ func1 : 'hello hello' ,
1223+ }
1224+
1225+ const manifestFile = await readFile ( resolve ( distPath , 'manifest.json' ) , 'utf8' )
1226+ const manifest = JSON . parse ( manifestFile )
1227+
1228+ expect ( manifest . bundling_timing ) . toEqual ( { tarball_ms : expect . any ( Number ) } )
1229+
1230+ const tarballPath = join ( distPath , manifest . bundles [ 0 ] . asset )
1231+ const tarballResult = await runTarball ( tarballPath )
1232+ expect ( tarballResult ) . toStrictEqual ( expectedOutput )
1233+
1234+ const entries : string [ ] = [ ]
1235+
1236+ await tar . list ( {
1237+ file : tarballPath ,
1238+ onReadEntry : ( entry ) => {
1239+ entries . push ( entry . path )
1240+ } ,
1241+ } )
1242+
1243+ expect ( entries ) . toContain ( './___netlify-edge-functions.json' )
1244+ expect ( entries ) . toContain ( './deno.json' )
1245+ expect ( entries ) . toContain ( './netlify/edge-functions/func1.ts' )
1246+ // vendor directory content was moved
1247+ expect ( entries ) . toContain ( './.root-vendor/hello.ts' )
1248+
1249+ const eszipPath = join ( distPath , manifest . bundles [ 1 ] . asset )
1250+ const eszipResult = await runESZIP ( eszipPath )
1251+ expect ( eszipResult ) . toStrictEqual ( expectedOutput )
1252+
1253+ await cleanup ( )
1254+ } )
11961255 } ,
11971256 10_000 ,
11981257)
0 commit comments