@tamagui/build 1.109.7 → 1.109.9

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 ADDED
@@ -0,0 +1,92 @@
1
+ /**
2
+ * MIT License
3
+
4
+ Copyright (c) 2023 Youbao Nong
5
+
6
+ Permission is hereby granted, free of charge, to any person obtaining a copy
7
+ of this software and associated documentation files (the "Software"), to deal
8
+ in the Software without restriction, including without limitation the rights
9
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
10
+ copies of the Software, and to permit persons to whom the Software is
11
+ furnished to do so, subject to the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be included in all
14
+ copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
22
+ SOFTWARE.
23
+ */
24
+
25
+ /**
26
+ * A plugin for the esbuild
27
+ * convert code to es5 use @swc/core
28
+ */
29
+
30
+ const { transformFile: _transformFile } = require('@swc/core')
31
+
32
+ function transformFile(file, options) {
33
+ const isTs = file.endsWith('.ts') || file.endsWith('.tsx')
34
+ const isReact = file.endsWith('.jsx') || file.endsWith('.tsx')
35
+ let transformOptions = {
36
+ jsc: {
37
+ preserveAllComments: true,
38
+ externalHelpers: false,
39
+ transform: {
40
+ react: {
41
+ runtime: 'automatic',
42
+ development: false,
43
+ },
44
+ },
45
+ parser: {
46
+ syntax: isTs ? 'typescript' : 'ecmascript',
47
+ tsx: isReact && isTs,
48
+ jsx: isReact && !isTs,
49
+ },
50
+ target: 'es5',
51
+ },
52
+ module: { type: 'es6' },
53
+ sourceFileName: file,
54
+ isModule: true,
55
+ ...options,
56
+ }
57
+ return _transformFile(file, transformOptions)
58
+ }
59
+
60
+ exports.es5Plugin = function es5Plugin() {
61
+ return {
62
+ name: 'es5',
63
+ setup(build) {
64
+ const buildOptions = build.initialOptions
65
+ const enableSourcemap = !!buildOptions.sourcemap
66
+
67
+ build.onLoad({ filter: /\.([tj]sx?|mjs)$/ }, (args) => {
68
+ return new Promise((resolve) => {
69
+ transformFile(args.path, {
70
+ /**
71
+ * Generate inline source maps to enable esbuild to properly handle sourcemaps.
72
+ */
73
+ sourceMaps: enableSourcemap ? 'inline' : false,
74
+ })
75
+ .then(({ code }) => {
76
+ resolve({ contents: code, loader: 'js' })
77
+ })
78
+ .catch((error) => {
79
+ resolve({ pluginName: 'es5', errors: [convertError(error)] })
80
+ })
81
+ })
82
+ })
83
+ },
84
+ }
85
+ }
86
+
87
+ const convertError = (error) => {
88
+ return {
89
+ pluginName: 'esbuild-plugin-es5',
90
+ text: error.message,
91
+ }
92
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tamagui/build",
3
- "version": "1.109.7",
3
+ "version": "1.109.9",
4
4
  "bin": {
5
5
  "tamagui-build": "tamagui-build.js",
6
6
  "teesx": "./teesx.sh"
@@ -10,7 +10,8 @@
10
10
  },
11
11
  "dependencies": {
12
12
  "@babel/core": "^7.25.2",
13
- "@tamagui/babel-plugin-fully-specified": "1.109.7",
13
+ "@swc/core": "^1.7.21",
14
+ "@tamagui/babel-plugin-fully-specified": "1.109.9",
14
15
  "@types/fs-extra": "^9.0.13",
15
16
  "babel-plugin-fully-specified": "*",
16
17
  "chokidar": "^3.5.2",
package/tamagui-build.js CHANGED
@@ -1,7 +1,6 @@
1
1
  #!/usr/bin/env node
2
2
  /* eslint-disable no-console */
3
3
 
4
- const { es5Plugin } = require('esbuild-plugin-es5')
5
4
  const { transform } = require('@babel/core')
6
5
  const exec = require('execa')
7
6
  const fs = require('fs-extra')
@@ -11,6 +10,7 @@ const createExternalPlugin = require('./externalNodePlugin')
11
10
  const debounce = require('lodash.debounce')
12
11
  const { basename, dirname } = require('node:path')
13
12
  const alias = require('./esbuildAliasPlugin')
13
+ const { es5Plugin } = require('./esbuild-es5')
14
14
 
15
15
  const jsOnly = !!process.env.JS_ONLY
16
16
  const skipJS = !!(process.env.SKIP_JS || false)
@@ -443,20 +443,7 @@ async function esbuildWriteIfChanged(
443
443
  ...(platform === 'native'
444
444
  ? [
445
445
  // class isnt supported by hermes
446
- es5Plugin({
447
- swc: {
448
- jsc: {
449
- preserveAllComments: true,
450
- externalHelpers: false,
451
- transform: {
452
- react: {
453
- runtime: 'automatic',
454
- development: false,
455
- },
456
- },
457
- },
458
- },
459
- }),
446
+ es5Plugin(),
460
447
  ]
461
448
  : []),
462
449