@tamagui/build 1.112.0 → 1.112.2

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.
@@ -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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tamagui-build-test-simple-tpackage",
3
- "version": "1.112.0",
4
- "main": "dist/cjs/index.js",
3
+ "version": "1.112.2",
4
+ "main": "dist/cjs",
5
5
  "module": "dist/esm/index.mjs",
6
6
  "types": "dist/types/index.d.ts",
7
7
  "scripts": {
@@ -16,7 +16,7 @@
16
16
  "build:target-native": "TAMAGUI_TARGET=native node ../../../tamagui-build.js"
17
17
  },
18
18
  "devDependencies": {
19
- "@tamagui/build": "1.112.0",
19
+ "@tamagui/build": "1.112.2",
20
20
  "typescript": "^5.5.2"
21
21
  }
22
22
  }
@@ -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.
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "tamagui-build-test-watch-package",
3
- "version": "1.112.0",
4
- "main": "dist/cjs/index.js",
3
+ "version": "1.112.2",
4
+ "main": "dist/cjs",
5
5
  "module": "dist/esm/index.mjs",
6
6
  "types": "dist/types/index.d.ts",
7
7
  "scripts": {
@@ -16,7 +16,7 @@
16
16
  "build:target-native": "TAMAGUI_TARGET=native node ../../../tamagui-build.js"
17
17
  },
18
18
  "devDependencies": {
19
- "@tamagui/build": "1.112.0",
19
+ "@tamagui/build": "1.112.2",
20
20
  "typescript": "^5.5.2"
21
21
  }
22
22
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/build",
3
- "version": "1.112.0",
3
+ "version": "1.112.2",
4
4
  "bin": {
5
5
  "tamagui-build": "tamagui-build.js",
6
6
  "teesx": "./teesx.sh"
@@ -14,11 +14,11 @@
14
14
  "dependencies": {
15
15
  "@babel/core": "^7.25.2",
16
16
  "@swc/core": "^1.7.21",
17
- "@tamagui/babel-plugin-fully-specified": "1.112.0",
17
+ "@tamagui/babel-plugin-fully-specified": "1.112.2",
18
18
  "@types/fs-extra": "^9.0.13",
19
19
  "babel-plugin-fully-specified": "*",
20
20
  "chokidar": "^3.5.2",
21
- "esbuild": "^0.23.1",
21
+ "esbuild": "^0.24.0",
22
22
  "esbuild-plugin-es5": "^2.1.1",
23
23
  "esbuild-register": "^3.6.0",
24
24
  "execa": "^5.0.0",
@@ -29,6 +29,6 @@
29
29
  },
30
30
  "gitHead": "a49cc7ea6b93ba384e77a4880ae48ac4a5635c14",
31
31
  "devDependencies": {
32
- "vitest": "0.34.3"
32
+ "vitest": "2.1.1"
33
33
  }
34
34
  }
package/tamagui-build.js CHANGED
@@ -19,7 +19,7 @@ const shouldSkipTypes = !!(
19
19
  process.argv.includes('--skip-types') || process.env.SKIP_TYPES
20
20
  )
21
21
  const shouldSkipMJS = !!process.argv.includes('--skip-mjs')
22
- const shouldBundle = !!process.argv.includes('--bundle')
22
+ const shouldBundleFlag = !!process.argv.includes('--bundle')
23
23
  const shouldBundleNodeModules = !!process.argv.includes('--bundle-modules')
24
24
  const shouldClean = !!process.argv.includes('clean')
25
25
  const shouldCleanBuildOnly = !!process.argv.includes('clean:build')
@@ -271,17 +271,26 @@ async function buildJs() {
271
271
  return
272
272
  }
273
273
 
274
- const files = shouldBundle
275
- ? [pkgSource || './src/index.ts']
276
- : (await fg(['src/**/*.(m)?[jt]s(x)?', 'src/**/*.css'])).filter(
277
- (x) => !x.includes('.d.ts') && (exclude ? !x.match(exclude) : true)
278
- )
279
-
280
274
  const externalPlugin = createExternalPlugin({
281
275
  skipNodeModulesBundle: true,
282
276
  })
283
277
 
284
- const external = shouldBundle ? ['@swc/*', '*.node'] : undefined
278
+ const bundlePlugin = {
279
+ name: `external-most-modules`,
280
+ setup(build) {
281
+ build.onResolve({ filter: /.*/ }, (args) => {
282
+ if (
283
+ !args.path.startsWith('.') &&
284
+ !args.path.startsWith('/') &&
285
+ !args.path.startsWith('node:')
286
+ ) {
287
+ return { external: /^(esbuild|mdx-bundler)$/.test(args.path) }
288
+ }
289
+ })
290
+ },
291
+ }
292
+
293
+ const external = shouldBundleFlag ? ['@swc/*', '*.node'] : undefined
285
294
 
286
295
  /** @type { import('esbuild').BuildOptions } */
287
296
  const esbuildBundleProps =
@@ -341,24 +350,36 @@ async function buildJs() {
341
350
 
342
351
  const start = Date.now()
343
352
 
353
+ const allFiles = (await fg(['src/**/*.(m)?[jt]s(x)?', 'src/**/*.css'])).filter(
354
+ (x) => !x.includes('.d.ts') && (exclude ? !x.match(exclude) : true)
355
+ )
356
+
357
+ const entryPoints = shouldBundleFlag ? [pkgSource || './src/index.ts'] : allFiles
358
+
344
359
  const cjsConfig = {
345
360
  format: 'cjs',
346
- entryPoints: files,
361
+ entryPoints,
347
362
  outdir: flatOut ? 'dist' : 'dist/cjs',
348
- bundle: shouldBundle,
363
+ bundle: shouldBundleFlag,
349
364
  external,
350
- plugins: shouldBundleNodeModules ? [] : [externalPlugin],
365
+ plugins: shouldBundleNodeModules ? [bundlePlugin] : [externalPlugin],
351
366
  minify: !!process.env.MINIFY,
352
367
  platform: 'node',
353
368
  }
354
369
 
370
+ const cjsConfigWeb = {
371
+ ...cjsConfig,
372
+
373
+ // metro cant do platform-specific with cjs :/
374
+ // outExtension: { '.js': '.cjs' },
375
+ }
376
+
355
377
  const esmConfig = {
356
378
  target: 'esnext',
357
379
  format: 'esm',
358
- entryPoints: files,
380
+ entryPoints,
381
+ bundle: shouldBundleFlag,
359
382
  outdir: flatOut ? 'dist' : 'dist/esm',
360
- bundle: shouldBundle,
361
- external,
362
383
  allowOverwrite: true,
363
384
  minify: !!process.env.MINIFY,
364
385
  }
@@ -379,8 +400,10 @@ async function buildJs() {
379
400
  return await Promise.all([
380
401
  // web output to cjs
381
402
  pkgMain
382
- ? esbuildWriteIfChanged(cjsConfig, {
403
+ ? esbuildWriteIfChanged(cjsConfigWeb, {
383
404
  platform: 'web',
405
+ bundle: shouldBundleFlag,
406
+ // specifyCJS: true,
384
407
  })
385
408
  : null,
386
409
 
@@ -422,6 +445,7 @@ async function buildJs() {
422
445
  pkgModule
423
446
  ? esbuildWriteIfChanged(esmConfig, {
424
447
  platform: 'web',
448
+ bundle: shouldBundleFlag,
425
449
  })
426
450
  : null,
427
451
 
@@ -439,8 +463,8 @@ async function buildJs() {
439
463
  // only diff is jsx preserve and outdir
440
464
  jsx: 'preserve',
441
465
  outdir: flatOut ? 'dist' : 'dist/jsx',
442
- entryPoints: files,
443
- bundle: shouldBundle,
466
+ entryPoints,
467
+ bundle: shouldBundleFlag,
444
468
  allowOverwrite: true,
445
469
  target: 'esnext',
446
470
  format: 'esm',
@@ -460,8 +484,8 @@ async function buildJs() {
460
484
  // only diff is jsx preserve and outdir
461
485
  jsx: 'preserve',
462
486
  outdir: flatOut ? 'dist' : 'dist/jsx',
463
- entryPoints: files,
464
- bundle: shouldBundle,
487
+ entryPoints,
488
+ bundle: shouldBundleFlag,
465
489
  allowOverwrite: true,
466
490
  target: 'node16',
467
491
  format: 'esm',
@@ -474,7 +498,11 @@ async function buildJs() {
474
498
  )
475
499
  : null,
476
500
  ]).then(() => {
477
- if (process.env.DEBUG) console.info(`built js in ${Date.now() - start}ms`)
501
+ if (process.env.DEBUG) {
502
+ console.info(`built js in ${Date.now() - start}ms`)
503
+ }
504
+
505
+ void esbuild.stop()
478
506
  })
479
507
  }
480
508
 
@@ -486,13 +514,14 @@ async function buildJs() {
486
514
  async function esbuildWriteIfChanged(
487
515
  /** @type { import('esbuild').BuildOptions } */
488
516
  opts,
489
- { platform, env } = {
517
+ { platform, env, specifyCJS } = {
490
518
  platform: '',
519
+ specifyCJS: false,
491
520
  env: '',
492
521
  }
493
522
  ) {
494
- if (!shouldWatch && !platform) {
495
- return await esbuild.build(opts)
523
+ if (!platform) {
524
+ throw new Error(`Must provide platform of web or native`)
496
525
  }
497
526
 
498
527
  const isESM = opts.target === 'esm' || opts.target === 'esnext'
@@ -513,7 +542,7 @@ async function esbuildWriteIfChanged(
513
542
  const webEsbuildSettings = {
514
543
  target: 'esnext',
515
544
  jsx: 'automatic',
516
- platform: shouldBundle ? 'node' : 'neutral',
545
+ platform: opts.bundle ? 'node' : 'neutral',
517
546
  tsconfigRaw: {
518
547
  compilerOptions: {
519
548
  paths: {
@@ -674,6 +703,32 @@ async function esbuildWriteIfChanged(
674
703
 
675
704
  // path specifics:
676
705
 
706
+ if (specifyCJS) {
707
+ await Promise.all(
708
+ outputs.map(async (file) => {
709
+ if (!file) return
710
+
711
+ const { path, contents } = file
712
+
713
+ if (!path.endsWith('.cjs')) return
714
+
715
+ const result = opts.bundle
716
+ ? { code: contents }
717
+ : transform(contents, {
718
+ filename: path,
719
+ configFile: false,
720
+ sourceMap: true,
721
+ plugins: [
722
+ require.resolve('@tamagui/babel-plugin-fully-specified/commonjs'),
723
+ ].filter(Boolean),
724
+ })
725
+
726
+ await FSE.writeFile(path, result.code)
727
+ })
728
+ )
729
+ return
730
+ }
731
+
677
732
  if (shouldSkipMJS || !isESM) {
678
733
  return
679
734
  }
@@ -691,7 +746,7 @@ async function esbuildWriteIfChanged(
691
746
 
692
747
  // if bundling no need to specify as its all internal
693
748
  // and babel is bad on huge bundled files
694
- const result = shouldBundle
749
+ const result = opts.bundle
695
750
  ? { code: contents }
696
751
  : transform(contents, {
697
752
  filename: mjsOutPath,