@tamagui/build 1.88.13 → 1.88.15
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/LICENSE +21 -0
- package/package.json +4 -2
- package/tamagui-build.js +65 -21
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2020 Nate Wienert
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tamagui/build",
|
|
3
|
-
"version": "1.88.
|
|
3
|
+
"version": "1.88.15",
|
|
4
4
|
"bin": {
|
|
5
5
|
"tamagui-build": "tamagui-build.js"
|
|
6
6
|
},
|
|
@@ -12,12 +12,14 @@
|
|
|
12
12
|
"access": "public"
|
|
13
13
|
},
|
|
14
14
|
"dependencies": {
|
|
15
|
+
"@babel/core": "^7.23.3",
|
|
15
16
|
"@types/fs-extra": "^9.0.13",
|
|
17
|
+
"babel-plugin-fully-specified": "*",
|
|
16
18
|
"chokidar": "^3.5.2",
|
|
17
19
|
"esbuild": "^0.19.11",
|
|
18
20
|
"execa": "^5.0.0",
|
|
19
21
|
"fast-glob": "^3.2.11",
|
|
20
|
-
"fs-extra": "^11.
|
|
22
|
+
"fs-extra": "^11.2.0",
|
|
21
23
|
"get-tsconfig": "^4.5.0",
|
|
22
24
|
"lodash.debounce": "^4.0.8",
|
|
23
25
|
"typescript": "^5.3.3"
|
package/tamagui-build.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
/* eslint-disable no-console */
|
|
3
3
|
|
|
4
|
+
const { transform } = require('@babel/core')
|
|
4
5
|
const exec = require('execa')
|
|
5
6
|
const fs = require('fs-extra')
|
|
6
7
|
const esbuild = require('esbuild')
|
|
@@ -49,12 +50,12 @@ const flatOut = [pkgMain, pkgModule, pkgModuleJSX].filter(Boolean).length === 1
|
|
|
49
50
|
const replaceRNWeb = {
|
|
50
51
|
esm: {
|
|
51
52
|
from: 'from "react-native"',
|
|
52
|
-
to: 'from "react-native-web"'
|
|
53
|
+
to: 'from "react-native-web"',
|
|
53
54
|
},
|
|
54
55
|
cjs: {
|
|
55
56
|
from: 'require("react-native")',
|
|
56
|
-
to: 'require("react-native-web")'
|
|
57
|
-
}
|
|
57
|
+
to: 'require("react-native-web")',
|
|
58
|
+
},
|
|
58
59
|
}
|
|
59
60
|
|
|
60
61
|
async function clean() {
|
|
@@ -93,12 +94,12 @@ if (shouldClean || shouldCleanBuildOnly) {
|
|
|
93
94
|
process.env.DISABLE_AUTORUN = true
|
|
94
95
|
const rebuild = debounce(build, 100)
|
|
95
96
|
const chokidar = require('chokidar')
|
|
96
|
-
|
|
97
|
+
|
|
97
98
|
// do one js build but not types
|
|
98
99
|
build({
|
|
99
100
|
skipTypes: true,
|
|
100
101
|
})
|
|
101
|
-
|
|
102
|
+
|
|
102
103
|
chokidar
|
|
103
104
|
// prevent infinite loop but cause race condition if you just build directly
|
|
104
105
|
.watch('src', {
|
|
@@ -110,7 +111,7 @@ if (shouldClean || shouldCleanBuildOnly) {
|
|
|
110
111
|
.on('add', rebuild)
|
|
111
112
|
} else {
|
|
112
113
|
build()
|
|
113
|
-
}
|
|
114
|
+
}
|
|
114
115
|
}
|
|
115
116
|
|
|
116
117
|
async function build({ skipTypes } = {}) {
|
|
@@ -268,6 +269,19 @@ async function buildJs() {
|
|
|
268
269
|
minify: process.env.MINIFY ? true : false,
|
|
269
270
|
}
|
|
270
271
|
|
|
272
|
+
if (pkgSource) {
|
|
273
|
+
try {
|
|
274
|
+
const contents = await fs.readFile(pkgSource)
|
|
275
|
+
if (contents.slice(0, 40).includes('GITCRYPT')) {
|
|
276
|
+
// encrypted file, ignore
|
|
277
|
+
console.info(`This package is encrypted, skipping`)
|
|
278
|
+
return
|
|
279
|
+
}
|
|
280
|
+
} catch {
|
|
281
|
+
// ok
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
|
|
271
285
|
return await Promise.all([
|
|
272
286
|
// web output to cjs
|
|
273
287
|
pkgMain
|
|
@@ -314,10 +328,11 @@ async function buildJs() {
|
|
|
314
328
|
pkgModule
|
|
315
329
|
? esbuildWriteIfChanged(esmConfig, {
|
|
316
330
|
platform: 'web',
|
|
331
|
+
mjs: true,
|
|
317
332
|
})
|
|
318
333
|
: null,
|
|
319
334
|
|
|
320
|
-
//
|
|
335
|
+
// native output to esm
|
|
321
336
|
pkgModule
|
|
322
337
|
? esbuildWriteIfChanged(esmConfig, {
|
|
323
338
|
platform: 'native',
|
|
@@ -341,6 +356,7 @@ async function buildJs() {
|
|
|
341
356
|
},
|
|
342
357
|
{
|
|
343
358
|
platform: 'web',
|
|
359
|
+
mjs: true,
|
|
344
360
|
}
|
|
345
361
|
)
|
|
346
362
|
: null,
|
|
@@ -378,7 +394,8 @@ async function buildJs() {
|
|
|
378
394
|
async function esbuildWriteIfChanged(
|
|
379
395
|
/** @type { import('esbuild').BuildOptions } */
|
|
380
396
|
opts,
|
|
381
|
-
{ platform, env } = {
|
|
397
|
+
{ platform, env, mjs } = {
|
|
398
|
+
mjs: false,
|
|
382
399
|
platform: '',
|
|
383
400
|
env: '',
|
|
384
401
|
}
|
|
@@ -393,12 +410,12 @@ async function esbuildWriteIfChanged(
|
|
|
393
410
|
target: 'node16',
|
|
394
411
|
format: 'cjs',
|
|
395
412
|
supported: {
|
|
396
|
-
'logical-assignment': false
|
|
413
|
+
'logical-assignment': false,
|
|
397
414
|
},
|
|
398
415
|
jsx: 'automatic',
|
|
399
416
|
platform: 'node',
|
|
400
417
|
}
|
|
401
|
-
|
|
418
|
+
|
|
402
419
|
/** @type { import('esbuild').BuildOptions } */
|
|
403
420
|
const webEsbuildSettings = {
|
|
404
421
|
target: 'esnext',
|
|
@@ -412,7 +429,7 @@ async function esbuildWriteIfChanged(
|
|
|
412
429
|
},
|
|
413
430
|
},
|
|
414
431
|
}
|
|
415
|
-
|
|
432
|
+
|
|
416
433
|
const built = await esbuild.build({
|
|
417
434
|
...opts,
|
|
418
435
|
|
|
@@ -445,8 +462,8 @@ async function esbuildWriteIfChanged(
|
|
|
445
462
|
sourcemap: true,
|
|
446
463
|
sourcesContent: false,
|
|
447
464
|
logLevel: 'error',
|
|
448
|
-
...platform === 'native' && nativeEsbuildSettings,
|
|
449
|
-
...platform === 'web' && webEsbuildSettings,
|
|
465
|
+
...(platform === 'native' && nativeEsbuildSettings),
|
|
466
|
+
...(platform === 'web' && webEsbuildSettings),
|
|
450
467
|
define: {
|
|
451
468
|
...(platform && {
|
|
452
469
|
'process.env.TAMAGUI_TARGET': `"${platform}"`,
|
|
@@ -520,16 +537,43 @@ async function esbuildWriteIfChanged(
|
|
|
520
537
|
outString = outString.replace(/\nimport "[^"]+";\n/g, '\n')
|
|
521
538
|
}
|
|
522
539
|
|
|
523
|
-
|
|
524
|
-
if (
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
540
|
+
async function flush(contents, path) {
|
|
541
|
+
if (shouldWatch) {
|
|
542
|
+
if (
|
|
543
|
+
!(await fs.pathExists(path)) ||
|
|
544
|
+
(await fs.readFile(path, 'utf8')) !== contents
|
|
545
|
+
) {
|
|
546
|
+
await fs.writeFile(path, contents)
|
|
547
|
+
}
|
|
548
|
+
} else {
|
|
549
|
+
await fs.writeFile(path, contents)
|
|
529
550
|
}
|
|
530
|
-
} else {
|
|
531
|
-
await fs.writeFile(outPath, outString)
|
|
532
551
|
}
|
|
552
|
+
|
|
553
|
+
await Promise.all([
|
|
554
|
+
flush(outString, outPath),
|
|
555
|
+
(async () => {
|
|
556
|
+
if (platform === 'web' && mjs && outPath.endsWith('.js')) {
|
|
557
|
+
const mjsOutPath = outPath.replace('.js', '.mjs')
|
|
558
|
+
const output = transform(outString, {
|
|
559
|
+
filename: mjsOutPath,
|
|
560
|
+
plugins: [
|
|
561
|
+
[
|
|
562
|
+
'babel-plugin-fully-specified',
|
|
563
|
+
{
|
|
564
|
+
ensureFileExists: false,
|
|
565
|
+
esExtensionDefault: '.mjs',
|
|
566
|
+
tryExtensions: ['.mjs', '.js'],
|
|
567
|
+
esExtensions: ['.mjs', '.js'],
|
|
568
|
+
},
|
|
569
|
+
],
|
|
570
|
+
],
|
|
571
|
+
})
|
|
572
|
+
// output to mjs fully specified
|
|
573
|
+
await flush(output.code, mjsOutPath)
|
|
574
|
+
}
|
|
575
|
+
})(),
|
|
576
|
+
])
|
|
533
577
|
})
|
|
534
578
|
)
|
|
535
579
|
}
|