@tamagui/build 3.0.0-beta.1216.1 → 3.0.0-beta.1309.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/package.json +4 -12
- package/tamagui-build.js +61 -6
- package/tamagui-tsgo.js +8 -4
- package/typescript-path.js +8 -0
- package/typescript-native.js +0 -13
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/build",
|
|
3
|
-
"version": "3.0.0-beta.
|
|
3
|
+
"version": "3.0.0-beta.1309.1",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
|
|
6
6
|
"files": [
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
"tamagui-build.js",
|
|
13
13
|
"tamagui-build-workspace.js",
|
|
14
14
|
"tamagui-tsgo.js",
|
|
15
|
-
"typescript-
|
|
15
|
+
"typescript-path.js",
|
|
16
16
|
"teesx.sh"
|
|
17
17
|
],
|
|
18
18
|
"bin": {
|
|
@@ -44,16 +44,8 @@
|
|
|
44
44
|
"lodash.debounce": "^4.0.8",
|
|
45
45
|
"oxc-transform": "^0.112.0",
|
|
46
46
|
"picomatch": "4.0.4",
|
|
47
|
-
"rolldown": "1.2.4"
|
|
48
|
-
|
|
49
|
-
"optionalDependencies": {
|
|
50
|
-
"@typescript/typescript-darwin-arm64": "7.1.0-dev.20260722.1",
|
|
51
|
-
"@typescript/typescript-darwin-x64": "7.1.0-dev.20260722.1",
|
|
52
|
-
"@typescript/typescript-linux-arm": "7.1.0-dev.20260722.1",
|
|
53
|
-
"@typescript/typescript-linux-arm64": "7.1.0-dev.20260722.1",
|
|
54
|
-
"@typescript/typescript-linux-x64": "7.1.0-dev.20260722.1",
|
|
55
|
-
"@typescript/typescript-win32-arm64": "7.1.0-dev.20260722.1",
|
|
56
|
-
"@typescript/typescript-win32-x64": "7.1.0-dev.20260722.1"
|
|
47
|
+
"rolldown": "1.2.4",
|
|
48
|
+
"typescript": "7.0.2"
|
|
57
49
|
},
|
|
58
50
|
"peerDependencies": {
|
|
59
51
|
"babel-plugin-react-compiler": ">=1"
|
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,51 @@ 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(
|
|
252
|
+
new RegExp(`\\b${identifier}\\b`, 'g'),
|
|
253
|
+
'require'
|
|
254
|
+
)
|
|
255
|
+
}
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
const runtime = contents.match(
|
|
259
|
+
/\/\/#region \\0rolldown\/runtime\.js\r?\n([\s\S]*?)\/\/#endregion\r?\n?/
|
|
260
|
+
)
|
|
261
|
+
const helper = runtime?.[1].match(
|
|
262
|
+
/var (__require(?:\$\d+)?) = \/\* @__PURE__ \*\/ \(\(x\) =>[\s\S]*?Calling `require`[\s\S]*?\r?\n\}\);\r?\n/
|
|
263
|
+
)
|
|
264
|
+
if (!helper) return contents
|
|
265
|
+
|
|
266
|
+
const remainingRuntime = runtime[1].replace(helper[0], '')
|
|
267
|
+
contents = contents.replace(
|
|
268
|
+
remainingRuntime.trim() ? helper[0] : runtime[0],
|
|
269
|
+
''
|
|
270
|
+
)
|
|
271
|
+
const identifier = helper[1].replace(/[.*+?^${}()|[\]\\]/g, '\\$&')
|
|
272
|
+
return contents.replace(new RegExp(`\\b${identifier}\\b`, 'g'), 'require')
|
|
273
|
+
}
|
|
274
|
+
|
|
230
275
|
async function pruneUnusedImports(contents, filePath) {
|
|
231
276
|
if (!contents.includes('import')) {
|
|
232
277
|
return contents
|
|
@@ -236,9 +281,15 @@ async function pruneUnusedImports(contents, filePath) {
|
|
|
236
281
|
|
|
237
282
|
const bundle = await rolldown({
|
|
238
283
|
input: entryId,
|
|
239
|
-
external: (id) => id !== entryId,
|
|
284
|
+
external: (id) => id !== entryId && id !== preserveRequireModuleId,
|
|
240
285
|
platform: 'neutral',
|
|
286
|
+
transform: {
|
|
287
|
+
inject: {
|
|
288
|
+
require: [preserveRequireModuleId, 'require'],
|
|
289
|
+
},
|
|
290
|
+
},
|
|
241
291
|
plugins: [
|
|
292
|
+
preserveRequirePlugin,
|
|
242
293
|
{
|
|
243
294
|
name: 'tamagui-build-prune-entry',
|
|
244
295
|
resolveId(id) {
|
|
@@ -267,7 +318,9 @@ async function pruneUnusedImports(contents, filePath) {
|
|
|
267
318
|
minify: false,
|
|
268
319
|
})
|
|
269
320
|
const chunk = result.output.find((item) => item.type === 'chunk')
|
|
270
|
-
return chunk?.code
|
|
321
|
+
return chunk?.code
|
|
322
|
+
? stripRolldownRegionComments(restoreGlobalRequire(chunk.code))
|
|
323
|
+
: contents
|
|
271
324
|
} finally {
|
|
272
325
|
await bundle.close?.()
|
|
273
326
|
}
|
|
@@ -387,7 +440,7 @@ async function fullySpecifyOutputs(
|
|
|
387
440
|
}
|
|
388
441
|
|
|
389
442
|
transformed.set(file.path, {
|
|
390
|
-
code: stripRolldownRegionComments(chunk.code).replace(
|
|
443
|
+
code: stripRolldownRegionComments(restoreGlobalRequire(chunk.code)).replace(
|
|
391
444
|
/\n?\/\/# sourceMappingURL=.*(?:\n|$)/g,
|
|
392
445
|
''
|
|
393
446
|
),
|
|
@@ -1017,7 +1070,7 @@ async function pruneStaleDeclarations(targetDir, allFiles) {
|
|
|
1017
1070
|
}
|
|
1018
1071
|
|
|
1019
1072
|
async function emitDeclarationsWithTsgo(targetDir, allFiles) {
|
|
1020
|
-
const tsgoPath =
|
|
1073
|
+
const tsgoPath = getTypeScriptPath()
|
|
1021
1074
|
const declarationProject = `.tamagui-build-tsconfig-${process.pid}.json`
|
|
1022
1075
|
const sourceProject = path
|
|
1023
1076
|
.relative(process.cwd(), path.resolve(tsProject || 'tsconfig.json'))
|
|
@@ -1057,7 +1110,9 @@ async function emitDeclarationsWithTsgo(targetDir, allFiles) {
|
|
|
1057
1110
|
|
|
1058
1111
|
try {
|
|
1059
1112
|
await new Promise((resolve, reject) => {
|
|
1060
|
-
const child = childProcess.spawn(tsgoPath, args, {
|
|
1113
|
+
const child = childProcess.spawn(process.execPath, [tsgoPath, ...args], {
|
|
1114
|
+
stdio: 'inherit',
|
|
1115
|
+
})
|
|
1061
1116
|
child.once('error', reject)
|
|
1062
1117
|
child.once('exit', (code, signal) => {
|
|
1063
1118
|
if (code === 0) {
|
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 }
|