@tamagui/build 1.92.1 → 1.93.0

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,33 @@
1
+ const hasReplaced = Symbol()
2
+
3
+ module.exports = function viteMetaEnvBabelPlugin({ template, types: t }) {
4
+ return {
5
+ name: 'vite-process-to-meta-env',
6
+ visitor: {
7
+ MemberExpression(path) {
8
+ if (path[hasReplaced]) return
9
+
10
+ const envNode = t.isMemberExpression(path.node.object) && path.node.object
11
+ const variableName = t.isIdentifier(path.node.property) && path.node.property.name
12
+
13
+ if (!envNode || !variableName) {
14
+ return
15
+ }
16
+
17
+ const isProcess =
18
+ t.isIdentifier(envNode.object) && envNode.object.name === 'process'
19
+ const isEnvVar =
20
+ t.isIdentifier(envNode.property) && envNode.property.name === 'env'
21
+
22
+ if (!isProcess || !isEnvVar) {
23
+ return
24
+ }
25
+
26
+ path.replaceWith(
27
+ template.expression('import.meta.env.%%variableName%%')({ variableName })
28
+ )
29
+ path[hasReplaced] = true
30
+ },
31
+ },
32
+ }
33
+ }
@@ -0,0 +1,35 @@
1
+ import type babelCore from '@babel/core'
2
+
3
+ export default function viteMetaEnvBabelPlugin({
4
+ template,
5
+ types: t,
6
+ }: typeof babelCore): babelCore.PluginObj {
7
+ return {
8
+ name: 'vite-process-to-meta-env',
9
+ visitor: {
10
+ MemberExpression(path) {
11
+ const envNode = t.isMemberExpression(path.node.object) && path.node.object
12
+ const variableName = t.isIdentifier(path.node.property) && path.node.property.name
13
+
14
+ if (!envNode || !variableName) {
15
+ return
16
+ }
17
+
18
+ const isProcess =
19
+ t.isIdentifier(envNode.object) && envNode.object.name === 'process'
20
+ const isEnvVar =
21
+ t.isIdentifier(envNode.property) && envNode.property.name === 'env'
22
+
23
+ if (!isProcess || !isEnvVar) {
24
+ return
25
+ }
26
+
27
+ path.replaceWith(
28
+ template.expression('process.env.%%variableName%%')({
29
+ variableName: variableName === 'NODE_ENV' ? 'MODE' : variableName,
30
+ })
31
+ )
32
+ },
33
+ },
34
+ }
35
+ }
package/package.json CHANGED
@@ -1,8 +1,9 @@
1
1
  {
2
2
  "name": "@tamagui/build",
3
- "version": "1.92.1",
3
+ "version": "1.93.0",
4
4
  "bin": {
5
- "tamagui-build": "tamagui-build.js"
5
+ "tamagui-build": "tamagui-build.js",
6
+ "teesx": "./teesx.sh"
6
7
  },
7
8
  "scripts": {
8
9
  "build": "true",
@@ -16,8 +17,9 @@
16
17
  "@types/fs-extra": "^9.0.13",
17
18
  "babel-plugin-fully-specified": "*",
18
19
  "chokidar": "^3.5.2",
19
- "esbuild": "^0.19.11",
20
+ "esbuild": "^0.20.2",
20
21
  "esbuild-plugin-es5": "^2.1.0",
22
+ "esbuild-register": "^3.5.0",
21
23
  "execa": "^5.0.0",
22
24
  "fast-glob": "^3.2.11",
23
25
  "fs-extra": "^11.2.0",
package/tamagui-build.js CHANGED
@@ -616,7 +616,10 @@ async function esbuildWriteIfChanged(
616
616
  esExtensions: ['.mjs', '.js'],
617
617
  },
618
618
  ],
619
- ],
619
+ // pkg.tamagui?.build?.skipEnvToMeta
620
+ // ? null
621
+ // : require.resolve('./babel-plugin-process-env-to-meta'),
622
+ ].filter(Boolean),
620
623
  }).code
621
624
  // output to mjs fully specified
622
625
  await flush(output, mjsOutPath)
package/teesx.sh ADDED
@@ -0,0 +1,3 @@
1
+ #!/usr/bin/env bash
2
+
3
+ node --loader esbuild-register/loader -r esbuild-register "$@"