@@ -508,7 +508,7 @@ createAPIClient().pets.getPets.useQuery();
508508 }
509509 } ) ;
510510
511- it ( 'uses module access from options by default when creating a transform state' , async ( ) => {
511+ it ( 'uses explicit module access when creating a transform state' , async ( ) => {
512512 const fixture = await createFixture ( ) ;
513513 const sourceFile = path . join ( fixture , 'src/App.tsx' ) ;
514514 const fixtureModuleAccess = createFixtureModuleAccess ( fixture ) ;
@@ -538,10 +538,10 @@ export function App() {
538538 } ,
539539 } ,
540540 ] ,
541- moduleAccess : {
542- resolve : fixtureModuleAccess . resolve ,
543- load ,
544- } ,
541+ } ,
542+ {
543+ resolve : fixtureModuleAccess . resolve ,
544+ load ,
545545 }
546546 ) ;
547547
@@ -697,93 +697,6 @@ export function App() {
697697 }
698698 } ) ;
699699
700- it ( 'supports a legacy resolver 4th argument together with module access load options' , async ( ) => {
701- const fixture = await createFixture ( ) ;
702- const sourceFile = path . join ( fixture , 'src/App.tsx' ) ;
703- const fixtureModuleAccess = createFixtureModuleAccess ( fixture ) ;
704- const load = vi . fn ( fixtureModuleAccess . load ) ;
705-
706- const result = await transformQraftTreeShakingImpl (
707- `
708- import { createAPIClient } from './api';
709-
710- const api = createAPIClient();
711-
712- export function App() {
713- return api.pets.getPets.useQuery();
714- }
715- ` ,
716- sourceFile ,
717- {
718- entrypoints : [
719- {
720- kind : 'clientFactory' ,
721- factory : {
722- exportName : 'createAPIClient' ,
723- moduleSpecifier : './api' ,
724- } ,
725- reactContext : {
726- exportName : 'APIClientContext' ,
727- } ,
728- } ,
729- ] ,
730- moduleAccess : {
731- load,
732- } ,
733- } ,
734- fixtureModuleAccess . resolve
735- ) ;
736-
737- expect ( result ?. code ) . toContain ( 'api_pets_getPets.useQuery()' ) ;
738- expect ( load ) . toHaveBeenCalledWith ( path . join ( fixture , 'src/api/index.ts' ) ) ;
739- } ) ;
740-
741- it ( 'prefers module access resolve from options over a conflicting legacy resolver 4th argument' , async ( ) => {
742- const fixture = await createFixture ( ) ;
743- const sourceFile = path . join ( fixture , 'src/App.tsx' ) ;
744- const fixtureModuleAccess = createFixtureModuleAccess ( fixture ) ;
745- const load = vi . fn ( fixtureModuleAccess . load ) ;
746- const legacyResolver = vi . fn ( async ( ) => {
747- throw new Error ( 'legacy resolver should not be called' ) ;
748- } ) ;
749-
750- const result = await transformQraftTreeShakingImpl (
751- `
752- import { createAPIClient } from './api';
753-
754- const api = createAPIClient();
755-
756- export function App() {
757- return api.pets.getPets.useQuery();
758- }
759- ` ,
760- sourceFile ,
761- {
762- entrypoints : [
763- {
764- kind : 'clientFactory' ,
765- factory : {
766- exportName : 'createAPIClient' ,
767- moduleSpecifier : './api' ,
768- } ,
769- reactContext : {
770- exportName : 'APIClientContext' ,
771- } ,
772- } ,
773- ] ,
774- moduleAccess : {
775- resolve : fixtureModuleAccess . resolve ,
776- load,
777- } ,
778- } ,
779- legacyResolver
780- ) ;
781-
782- expect ( result ?. code ) . toContain ( 'api_pets_getPets.useQuery()' ) ;
783- expect ( legacyResolver ) . not . toHaveBeenCalled ( ) ;
784- expect ( load ) . toHaveBeenCalledWith ( path . join ( fixture , 'src/api/index.ts' ) ) ;
785- } ) ;
786-
787700 it ( 'does not match a same-named import that resolves to a different module' , async ( ) => {
788701 const fixture = await createFixture ( ) ;
789702 const sourceFile = path . join ( fixture , 'src/App.tsx' ) ;
0 commit comments