@@ -147,16 +147,17 @@ yargs
147
147
? targets [ 0 ]
148
148
: undefined ;
149
149
150
- const entries : { [ key : string ] : string } = {
151
- 'main' : target
152
- ? path . join ( output , target , 'index.js' )
150
+ const entries : {
151
+ [ key in 'source' | 'main' | 'module' | 'types' ] ?: string ;
152
+ } = {
153
+ source : path . join ( source , entryFile ) ,
154
+ main : target
155
+ ? path . join ( output , target , 'index.cjs' )
153
156
: path . join ( source , entryFile ) ,
154
- 'react-native' : path . join ( source , entryFile ) ,
155
- 'source' : path . join ( source , entryFile ) ,
156
157
} ;
157
158
158
159
if ( targets . includes ( 'module' ) ) {
159
- entries . module = path . join ( output , 'module' , 'index.js ' ) ;
160
+ entries . module = path . join ( output , 'module' , 'index.mjs ' ) ;
160
161
}
161
162
162
163
if ( targets . includes ( 'typescript' ) ) {
@@ -181,9 +182,9 @@ yargs
181
182
esModuleInterop : true ,
182
183
forceConsistentCasingInFileNames : true ,
183
184
jsx : 'react' ,
184
- lib : [ 'esnext ' ] ,
185
- module : 'esnext ' ,
186
- moduleResolution : 'node ' ,
185
+ lib : [ 'ESNext ' ] ,
186
+ module : 'ESNext ' ,
187
+ moduleResolution : 'Bundler ' ,
187
188
noFallthroughCasesInSwitch : true ,
188
189
noImplicitReturns : true ,
189
190
noImplicitUseStrict : false ,
@@ -194,7 +195,7 @@ yargs
194
195
resolveJsonModule : true ,
195
196
skipLibCheck : true ,
196
197
strict : true ,
197
- target : 'esnext ' ,
198
+ target : 'ESNext ' ,
198
199
verbatimModuleSyntax : true ,
199
200
} ,
200
201
} ,
@@ -214,7 +215,7 @@ yargs
214
215
] ;
215
216
216
217
for ( const key in entries ) {
217
- const entry = entries [ key ] ;
218
+ const entry = entries [ key as keyof typeof entries ] ;
218
219
219
220
if ( pkg [ key ] && pkg [ key ] !== entry ) {
220
221
const { replace } = await prompts ( {
@@ -232,6 +233,41 @@ yargs
232
233
}
233
234
}
234
235
236
+ if ( Object . values ( entries ) . some ( ( entry ) => entry . endsWith ( '.ms' ) ) ) {
237
+ let replace = false ;
238
+
239
+ if ( pkg . exports ) {
240
+ replace = (
241
+ await prompts ( {
242
+ type : 'confirm' ,
243
+ name : 'replace' ,
244
+ message : `Your package.json has 'exports' field set. Do you want to replace it?` ,
245
+ initial : true ,
246
+ } )
247
+ ) . replace ;
248
+ } else {
249
+ replace = true ;
250
+ }
251
+
252
+ if ( replace ) {
253
+ pkg . exports = {
254
+ '.' : { } ,
255
+ } ;
256
+
257
+ if ( entries . types ) {
258
+ pkg . exports [ '.' ] . types = entries . types ;
259
+ }
260
+
261
+ if ( entries . module ) {
262
+ pkg . exports [ '.' ] . import = entries . module ;
263
+ }
264
+
265
+ if ( entries . main ) {
266
+ pkg . exports [ '.' ] . require = entries . main ;
267
+ }
268
+ }
269
+ }
270
+
235
271
if ( pkg . scripts ?. prepare && pkg . scripts . prepare !== prepare ) {
236
272
const { replace } = await prompts ( {
237
273
type : 'confirm' ,
0 commit comments