@@ -123,7 +123,7 @@ describe("Package file generation", () => {
123123 expect ( packageFile [ "//sampleConfiguration" ] ) . toEqual ( expectedSampleConfig ) ;
124124 } ) ;
125125
126- it ( "[esm] should include correct base entrypoints by default" , ( ) => {
126+ it ( "[esm] should include correct entrypoints (without react-native by default) " , ( ) => {
127127 const model = createMockModel ( {
128128 ...baseConfig ,
129129 withSamples : true ,
@@ -138,9 +138,13 @@ describe("Package file generation", () => {
138138 expect ( packageFile ) . to . have . property ( "module" , "./dist/esm/index.js" ) ;
139139 expect ( packageFile ) . to . have . property ( "types" , "./dist/commonjs/index.d.ts" ) ;
140140 expect ( packageFile ) . to . have . property ( "browser" , "./dist/browser/index.js" ) ;
141+ // Default: no react-native entrypoint
142+ expect ( packageFile ) . not . toHaveProperty ( "react-native" ) ;
141143 expect ( packageFile ) . to . have . property ( "exports" ) ;
142144 expect ( packageFile . exports [ "./package.json" ] ) . to . equal ( "./package.json" ) ;
143145 expect ( packageFile . exports [ "." ] ) . to . have . property ( "browser" ) ;
146+ // Default: no react-native in exports
147+ expect ( packageFile . exports [ "." ] ) . not . toHaveProperty ( "react-native" ) ;
144148 expect ( packageFile . exports [ "." ] ) . to . have . property ( "import" ) ;
145149 expect ( packageFile . exports [ "." ] ) . to . have . property ( "require" ) ;
146150 expect ( packageFile . exports [ "." ] [ "import" ] ) . toEqual ( {
@@ -149,21 +153,20 @@ describe("Package file generation", () => {
149153 } ) ;
150154 } ) ;
151155
152- it ( "[esm] should include consistent export conditions " , ( ) => {
156+ it ( "[esm] should include react-native entrypoints when generateReactNativeTarget is true " , ( ) => {
153157 const model = createMockModel ( {
154158 ...baseConfig ,
155159 withSamples : true ,
160+ generateReactNativeTarget : true ,
156161 } ) ;
157162 const packageFileContent = buildPackageFile ( model ) ;
158163 const packageFile = JSON . parse ( packageFileContent ?. content ?? "{}" ) ;
159164
160- expect ( packageFile . exports [ "." ] [ "browser" ] ) . toEqual ( {
161- types : "./dist/browser/index.d.ts" ,
162- default : "./dist/browser/index.js" ,
163- } ) ;
164- expect ( packageFile . exports [ "." ] [ "require" ] ) . toEqual ( {
165- types : "./dist/commonjs/index.d.ts" ,
166- default : "./dist/commonjs/index.js" ,
165+ expect ( packageFile ) . to . have . property ( "react-native" , "./dist/react-native/index.js" ) ;
166+ expect ( packageFile . exports [ "." ] ) . to . have . property ( "react-native" ) ;
167+ expect ( packageFile . exports [ "." ] [ "react-native" ] ) . toEqual ( {
168+ types : "./dist/react-native/index.d.ts" ,
169+ default : "./dist/react-native/index.js" ,
167170 } ) ;
168171 } ) ;
169172
@@ -314,7 +317,7 @@ describe("Package file generation", () => {
314317 expect ( packageFile . scripts ) . to . have . property ( "pack" , "pnpm pack 2>&1" ) ;
315318 } ) ;
316319
317- it ( "should include browser entrypoint by default for modular ARM packages " , ( ) => {
320+ it ( "should include browser but not react-native entrypoints by default " , ( ) => {
318321 const model = createMockModel ( {
319322 ...baseConfig ,
320323 azureArm : true ,
@@ -324,21 +327,22 @@ describe("Package file generation", () => {
324327 const packageFile = JSON . parse ( packageFileContent ?. content ?? "{}" ) ;
325328
326329 expect ( packageFile ) . to . have . property ( "browser" , "./dist/browser/index.js" ) ;
327- expect ( packageFile . exports [ "." ] ) . to . have . property ( "browser" ) ;
330+ // Default: no react-native entrypoint
331+ expect ( packageFile ) . not . toHaveProperty ( "react-native" ) ;
328332 } ) ;
329333
330- it ( "should include standard export conditions for modular ARM packages " , ( ) => {
334+ it ( "should include react-native entrypoint when generateReactNativeTarget is true " , ( ) => {
331335 const model = createMockModel ( {
332336 ...baseConfig ,
333337 azureArm : true ,
334338 isModularLibrary : true ,
339+ generateReactNativeTarget : true ,
335340 } ) ;
336341 const packageFileContent = buildPackageFile ( model ) ;
337342 const packageFile = JSON . parse ( packageFileContent ?. content ?? "{}" ) ;
338343
339344 expect ( packageFile ) . to . have . property ( "browser" , "./dist/browser/index.js" ) ;
340- expect ( packageFile . exports [ "." ] ) . to . have . property ( "import" ) ;
341- expect ( packageFile . exports [ "." ] ) . to . have . property ( "require" ) ;
345+ expect ( packageFile ) . to . have . property ( "react-native" , "./dist/react-native/index.js" ) ;
342346 } ) ;
343347 } ) ;
344348
0 commit comments