@tamagui/build 3.0.0-beta.1420.1 → 3.0.0-beta.1432.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/tamagui-build.js +13 -8
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/build",
3
- "version": "3.0.0-beta.1420.1",
3
+ "version": "3.0.0-beta.1432.1",
4
4
  "license": "MIT",
5
5
  "gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
6
6
  "files": [
package/tamagui-build.js CHANGED
@@ -248,10 +248,7 @@ function restoreGlobalRequire(contents) {
248
248
  contents = contents.replace(injected[0], '\n')
249
249
  if (injected[1] !== 'require') {
250
250
  const identifier = injected[1].replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
251
- contents = contents.replace(
252
- new RegExp(`\\b${identifier}\\b`, 'g'),
253
- 'require'
254
- )
251
+ contents = contents.replace(new RegExp(`\\b${identifier}\\b`, 'g'), 'require')
255
252
  }
256
253
  }
257
254
 
@@ -264,10 +261,7 @@ function restoreGlobalRequire(contents) {
264
261
  if (!helper) return contents
265
262
 
266
263
  const remainingRuntime = runtime[1].replace(helper[0], '')
267
- contents = contents.replace(
268
- remainingRuntime.trim() ? helper[0] : runtime[0],
269
- ''
270
- )
264
+ contents = contents.replace(remainingRuntime.trim() ? helper[0] : runtime[0], '')
271
265
  const identifier = helper[1].replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
272
266
  return contents.replace(new RegExp(`\\b${identifier}\\b`, 'g'), 'require')
273
267
  }
@@ -341,6 +335,17 @@ function resolveOutputModuleSpecifier(
341
335
  const pathname = suffixIndex === -1 ? specifier : specifier.slice(0, suffixIndex)
342
336
 
343
337
  const targetPath = path.resolve(path.dirname(filePath), pathname)
338
+ // a module with .ios/.android siblings stays extensionless on native so the
339
+ // react native bundler picks the platform file over the .native fallback
340
+ if (outputExtension.startsWith('.native.') && !path.extname(pathname)) {
341
+ const hasPlatformFile = [targetPath, path.join(targetPath, 'index')].some((base) =>
342
+ ['.ios.js', '.android.js'].some(
343
+ (extension) =>
344
+ outputPaths.has(`${base}${extension}`) || FSE.existsSync(`${base}${extension}`)
345
+ )
346
+ )
347
+ if (hasPlatformFile) return specifier
348
+ }
344
349
  if (
345
350
  pathname.endsWith('.js') &&
346
351
  (outputPaths.has(targetPath) || FSE.existsSync(targetPath))