@tamagui/build 3.0.0-beta.924.1 → 3.0.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.
- package/esbuild-es5.js +4 -0
- package/package.json +7 -13
- package/tamagui-build.js +74 -9
- package/tamagui-tsgo.js +8 -4
- package/typescript-path.js +8 -0
- package/typescript-native.js +0 -13
package/esbuild-es5.js
CHANGED
|
@@ -49,6 +49,10 @@ function transformFile(file, options) {
|
|
|
49
49
|
// See: https://github.com/swc-project/swc/blob/v1.7.14/crates/swc_ecma_compat_es2015/src/generator.rs#L703-L705
|
|
50
50
|
'transform-async-to-generator',
|
|
51
51
|
'transform-regenerator', // Similar to above
|
|
52
|
+
// all modern React Native JS engines (Hermes, JSC) natively support
|
|
53
|
+
// `typeof Symbol`. the _type_of helper SWC injects is a regular JS
|
|
54
|
+
// function that crashes Reanimated 4 worklets on the UI Runtime.
|
|
55
|
+
'transform-typeof-symbol',
|
|
52
56
|
],
|
|
53
57
|
},
|
|
54
58
|
jsc: {
|
package/package.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/build",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.1",
|
|
4
|
+
"license": "MIT",
|
|
4
5
|
"gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
|
|
5
6
|
"files": [
|
|
6
7
|
"babel-plugin-process-env-to-meta.js",
|
|
@@ -11,7 +12,7 @@
|
|
|
11
12
|
"tamagui-build.js",
|
|
12
13
|
"tamagui-build-workspace.js",
|
|
13
14
|
"tamagui-tsgo.js",
|
|
14
|
-
"typescript-
|
|
15
|
+
"typescript-path.js",
|
|
15
16
|
"teesx.sh"
|
|
16
17
|
],
|
|
17
18
|
"bin": {
|
|
@@ -43,16 +44,8 @@
|
|
|
43
44
|
"lodash.debounce": "^4.0.8",
|
|
44
45
|
"oxc-transform": "^0.112.0",
|
|
45
46
|
"picomatch": "4.0.4",
|
|
46
|
-
"rolldown": "1.2.4"
|
|
47
|
-
|
|
48
|
-
"optionalDependencies": {
|
|
49
|
-
"@typescript/typescript-darwin-arm64": "7.1.0-dev.20260722.1",
|
|
50
|
-
"@typescript/typescript-darwin-x64": "7.1.0-dev.20260722.1",
|
|
51
|
-
"@typescript/typescript-linux-arm": "7.1.0-dev.20260722.1",
|
|
52
|
-
"@typescript/typescript-linux-arm64": "7.1.0-dev.20260722.1",
|
|
53
|
-
"@typescript/typescript-linux-x64": "7.1.0-dev.20260722.1",
|
|
54
|
-
"@typescript/typescript-win32-arm64": "7.1.0-dev.20260722.1",
|
|
55
|
-
"@typescript/typescript-win32-x64": "7.1.0-dev.20260722.1"
|
|
47
|
+
"rolldown": "1.2.4",
|
|
48
|
+
"typescript": "7.0.2"
|
|
56
49
|
},
|
|
57
50
|
"peerDependencies": {
|
|
58
51
|
"babel-plugin-react-compiler": ">=1"
|
|
@@ -69,5 +62,6 @@
|
|
|
69
62
|
"type": "git",
|
|
70
63
|
"url": "git+https://github.com/tamagui/tamagui.git",
|
|
71
64
|
"directory": "code/packages/build"
|
|
72
|
-
}
|
|
65
|
+
},
|
|
66
|
+
"releaseSourceCommit": "c156b7cc55e5a6cc5883ebc8189720850ac32dbd"
|
|
73
67
|
}
|
package/tamagui-build.js
CHANGED
|
@@ -36,7 +36,7 @@ const { transformSync: oxcTransformSync } = require('oxc-transform')
|
|
|
36
36
|
const { getTsconfig } = require('get-tsconfig')
|
|
37
37
|
const path = require('node:path')
|
|
38
38
|
const childProcess = require('node:child_process')
|
|
39
|
-
const {
|
|
39
|
+
const { getTypeScriptPath } = require('./typescript-path')
|
|
40
40
|
const {
|
|
41
41
|
printEsbuildError,
|
|
42
42
|
printBuildError,
|
|
@@ -227,6 +227,45 @@ function stripRolldownRegionComments(contents) {
|
|
|
227
227
|
.replace(/^\/\/#endregion[^\n]*(?:\n|$)/gm, '')
|
|
228
228
|
}
|
|
229
229
|
|
|
230
|
+
const preserveRequireModuleId = 'tamagui-build:preserve-require'
|
|
231
|
+
const preserveRequirePlugin = {
|
|
232
|
+
name: 'tamagui-build-preserve-require',
|
|
233
|
+
resolveId(id) {
|
|
234
|
+
if (id === preserveRequireModuleId) return id
|
|
235
|
+
},
|
|
236
|
+
load(id) {
|
|
237
|
+
if (id === preserveRequireModuleId) {
|
|
238
|
+
return 'export const require = globalThis.require'
|
|
239
|
+
}
|
|
240
|
+
},
|
|
241
|
+
}
|
|
242
|
+
|
|
243
|
+
function restoreGlobalRequire(contents) {
|
|
244
|
+
const injected = contents.match(
|
|
245
|
+
/(?:\r?\n)?\/\/#region tamagui-build:preserve-require\r?\nconst ([\w$]+) = globalThis\.require;\r?\n[ \t\r\n]*\/\/#endregion\r?\n/
|
|
246
|
+
)
|
|
247
|
+
if (injected) {
|
|
248
|
+
contents = contents.replace(injected[0], '\n')
|
|
249
|
+
if (injected[1] !== 'require') {
|
|
250
|
+
const identifier = injected[1].replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
251
|
+
contents = contents.replace(new RegExp(`\\b${identifier}\\b`, 'g'), 'require')
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
|
|
255
|
+
const runtime = contents.match(
|
|
256
|
+
/\/\/#region \\0rolldown\/runtime\.js\r?\n([\s\S]*?)\/\/#endregion\r?\n?/
|
|
257
|
+
)
|
|
258
|
+
const helper = runtime?.[1].match(
|
|
259
|
+
/var (__require(?:\$\d+)?) = \/\* @__PURE__ \*\/ \(\(x\) =>[\s\S]*?Calling `require`[\s\S]*?\r?\n\}\);\r?\n/
|
|
260
|
+
)
|
|
261
|
+
if (!helper) return contents
|
|
262
|
+
|
|
263
|
+
const remainingRuntime = runtime[1].replace(helper[0], '')
|
|
264
|
+
contents = contents.replace(remainingRuntime.trim() ? helper[0] : runtime[0], '')
|
|
265
|
+
const identifier = helper[1].replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
266
|
+
return contents.replace(new RegExp(`\\b${identifier}\\b`, 'g'), 'require')
|
|
267
|
+
}
|
|
268
|
+
|
|
230
269
|
async function pruneUnusedImports(contents, filePath) {
|
|
231
270
|
if (!contents.includes('import')) {
|
|
232
271
|
return contents
|
|
@@ -236,9 +275,15 @@ async function pruneUnusedImports(contents, filePath) {
|
|
|
236
275
|
|
|
237
276
|
const bundle = await rolldown({
|
|
238
277
|
input: entryId,
|
|
239
|
-
external: (id) => id !== entryId,
|
|
278
|
+
external: (id) => id !== entryId && id !== preserveRequireModuleId,
|
|
240
279
|
platform: 'neutral',
|
|
280
|
+
transform: {
|
|
281
|
+
inject: {
|
|
282
|
+
require: [preserveRequireModuleId, 'require'],
|
|
283
|
+
},
|
|
284
|
+
},
|
|
241
285
|
plugins: [
|
|
286
|
+
preserveRequirePlugin,
|
|
242
287
|
{
|
|
243
288
|
name: 'tamagui-build-prune-entry',
|
|
244
289
|
resolveId(id) {
|
|
@@ -267,7 +312,9 @@ async function pruneUnusedImports(contents, filePath) {
|
|
|
267
312
|
minify: false,
|
|
268
313
|
})
|
|
269
314
|
const chunk = result.output.find((item) => item.type === 'chunk')
|
|
270
|
-
return chunk?.code
|
|
315
|
+
return chunk?.code
|
|
316
|
+
? stripRolldownRegionComments(restoreGlobalRequire(chunk.code))
|
|
317
|
+
: contents
|
|
271
318
|
} finally {
|
|
272
319
|
await bundle.close?.()
|
|
273
320
|
}
|
|
@@ -288,6 +335,17 @@ function resolveOutputModuleSpecifier(
|
|
|
288
335
|
const pathname = suffixIndex === -1 ? specifier : specifier.slice(0, suffixIndex)
|
|
289
336
|
|
|
290
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
|
+
}
|
|
291
349
|
if (
|
|
292
350
|
pathname.endsWith('.js') &&
|
|
293
351
|
(outputPaths.has(targetPath) || FSE.existsSync(targetPath))
|
|
@@ -302,8 +360,8 @@ function resolveOutputModuleSpecifier(
|
|
|
302
360
|
const platformExtension = outputExtension.match(/^\.(native|web|ios|android)\./)?.[1]
|
|
303
361
|
const explicitPlatformExtension = pathname.match(/\.(native|web|ios|android)$/)?.[1]
|
|
304
362
|
let extension = outputExtension
|
|
305
|
-
if (explicitPlatformExtension
|
|
306
|
-
extension = '.js'
|
|
363
|
+
if (explicitPlatformExtension) {
|
|
364
|
+
extension = outputExtension.endsWith('.cjs') ? '.cjs' : '.js'
|
|
307
365
|
} else if (platformExtension && pathname.endsWith(`.${platformExtension}`)) {
|
|
308
366
|
extension = outputExtension.replace(`.${platformExtension}`, '')
|
|
309
367
|
}
|
|
@@ -387,7 +445,7 @@ async function fullySpecifyOutputs(
|
|
|
387
445
|
}
|
|
388
446
|
|
|
389
447
|
transformed.set(file.path, {
|
|
390
|
-
code: stripRolldownRegionComments(chunk.code).replace(
|
|
448
|
+
code: stripRolldownRegionComments(restoreGlobalRequire(chunk.code)).replace(
|
|
391
449
|
/\n?\/\/# sourceMappingURL=.*(?:\n|$)/g,
|
|
392
450
|
''
|
|
393
451
|
),
|
|
@@ -1017,7 +1075,7 @@ async function pruneStaleDeclarations(targetDir, allFiles) {
|
|
|
1017
1075
|
}
|
|
1018
1076
|
|
|
1019
1077
|
async function emitDeclarationsWithTsgo(targetDir, allFiles) {
|
|
1020
|
-
const tsgoPath =
|
|
1078
|
+
const tsgoPath = getTypeScriptPath()
|
|
1021
1079
|
const declarationProject = `.tamagui-build-tsconfig-${process.pid}.json`
|
|
1022
1080
|
const sourceProject = path
|
|
1023
1081
|
.relative(process.cwd(), path.resolve(tsProject || 'tsconfig.json'))
|
|
@@ -1057,7 +1115,9 @@ async function emitDeclarationsWithTsgo(targetDir, allFiles) {
|
|
|
1057
1115
|
|
|
1058
1116
|
try {
|
|
1059
1117
|
await new Promise((resolve, reject) => {
|
|
1060
|
-
const child = childProcess.spawn(tsgoPath, args, {
|
|
1118
|
+
const child = childProcess.spawn(process.execPath, [tsgoPath, ...args], {
|
|
1119
|
+
stdio: 'inherit',
|
|
1120
|
+
})
|
|
1061
1121
|
child.once('error', reject)
|
|
1062
1122
|
child.once('exit', (code, signal) => {
|
|
1063
1123
|
if (code === 0) {
|
|
@@ -1676,7 +1736,12 @@ async function esbuildWriteIfChanged(
|
|
|
1676
1736
|
const shouldPreserveJsAlias =
|
|
1677
1737
|
preserveJsPathSet.has(path) || preserveJsPathAbsoluteSet.has(path)
|
|
1678
1738
|
|
|
1679
|
-
if (
|
|
1739
|
+
if (
|
|
1740
|
+
!path.includes('.native.') &&
|
|
1741
|
+
!path.includes('.android.') &&
|
|
1742
|
+
!path.includes('.ios.') &&
|
|
1743
|
+
!shouldPreserveJsAlias
|
|
1744
|
+
) {
|
|
1680
1745
|
cleanupNonMjsFiles.push(path)
|
|
1681
1746
|
cleanupNonMjsFiles.push(path + '.map')
|
|
1682
1747
|
}
|
package/tamagui-tsgo.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
|
|
3
3
|
const { spawnSync } = require('node:child_process')
|
|
4
|
-
const {
|
|
4
|
+
const { getTypeScriptPath } = require('./typescript-path')
|
|
5
5
|
|
|
6
|
-
const result = spawnSync(
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
const result = spawnSync(
|
|
7
|
+
process.execPath,
|
|
8
|
+
[getTypeScriptPath(), ...process.argv.slice(2)],
|
|
9
|
+
{
|
|
10
|
+
stdio: 'inherit',
|
|
11
|
+
}
|
|
12
|
+
)
|
|
9
13
|
|
|
10
14
|
if (result.error) {
|
|
11
15
|
throw result.error
|
package/typescript-native.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
const path = require('node:path')
|
|
2
|
-
|
|
3
|
-
function getTypeScriptNativePath() {
|
|
4
|
-
const packageName = `@typescript/typescript-${process.platform}-${process.arch}`
|
|
5
|
-
const packagePath = require.resolve(`${packageName}/package.json`)
|
|
6
|
-
return path.join(
|
|
7
|
-
path.dirname(packagePath),
|
|
8
|
-
'lib',
|
|
9
|
-
process.platform === 'win32' ? 'tsc.exe' : 'tsc'
|
|
10
|
-
)
|
|
11
|
-
}
|
|
12
|
-
|
|
13
|
-
module.exports = { getTypeScriptNativePath }
|