@@ -576,6 +576,35 @@ test.skipIf(isWindows)('should build `sanity-plugin-with-vanilla-extract` packag
576576 await project . remove ( )
577577} )
578578
579+ test . skipIf ( isWindows ) ( 'should build `next-sanity-repro` package' , async ( ) => {
580+ const project = await spawnProject ( 'next-sanity-repro' )
581+
582+ await project . install ( )
583+
584+ await project . run ( 'build' )
585+
586+ const [ distHooksJs , distIndexJs ] = await Promise . all ( [
587+ project . readFile ( 'dist/hooks.js' ) ,
588+ project . readFile ( 'dist/index.js' ) ,
589+ ] )
590+
591+ // The dist/index.js should import from `@sanity/client`
592+ expect ( distIndexJs ) . toContain ( `from "@sanity/client"` )
593+
594+ // The dist/hooks.js should import from `@sanity/next-loader/hooks` and `@sanity/visual-editing/react`
595+ expect ( distHooksJs ) . toContain ( `from "@sanity/next-loader/hooks"` )
596+ expect ( distHooksJs ) . toContain ( `from "@sanity/visual-editing/react"` )
597+
598+ // The dist/index.js should not contain any references to imports from /hooks
599+ expect ( distIndexJs ) . not . toContain ( `import "@sanity/next-loader/hooks"` )
600+ expect ( distIndexJs ) . not . toContain ( `import "@sanity/visual-editing/react"` )
601+
602+ expect ( distHooksJs ) . toMatchSnapshot ( './dist/hooks.js' )
603+ expect ( distIndexJs ) . toMatchSnapshot ( './dist/index.js' )
604+
605+ await project . remove ( )
606+ } )
607+
579608describe . skip ( 'runtime: next.js' , ( ) => {
580609 test ( 'import `dist/*.browser.js` from package' , async ( ) => {
581610 const exportsDummy = await spawnProject ( 'dummy-module' )
0 commit comments