Describe the bug I have an error with pnpm and react-native. It's seems error come with @tamagui/babel-plugin, I use DEBU=tamagui

transform[stdout]: loadModule @paymium/cross-ui /srv/paymium/paymium-client-united/node_modules/.pnpm/file+packages+cross-ui_7gbltcwyxr34w4n2afpp5rr5z4/node_modules/@paymium/cross-ui/src/index.tsx
transform[stderr]: Tamagui failed loading the pre-built tamagui.config.ts
transform[stderr]:   
transform[stderr]:   Unexpected token 'export'
transform[stderr]:   SyntaxError: Unexpected token 'export'
transform[stderr]:     at Object.compileFunction (node:vm:352:18)
transform[stderr]:     at wrapSafe (node:internal/modules/cjs/loader:1033:15)
transform[stderr]:     at Module._compile (node:internal/modules/cjs/loader:1069:27)
transform[stderr]:     at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
transform[stderr]:     at Object.newLoader [as .tsx] (/srv/paymium/paymium-client-united/node_modules/.pnpm/[email protected][email protected]/node_modules/esbuild-register/dist/node.js:2262:9)
transform[stderr]:     at Module.load (node:internal/modules/cjs/loader:981:32)
transform[stderr]:     at Function.Module._load (node:internal/modules/cjs/loader:822:12)
transform[stderr]:     at Module.require (node:internal/modules/cjs/loader:1005:19)
transform[stderr]:     at Module.require (/srv/paymium/paymium-client-united/node_modules/.pnpm/@[email protected]_yxd22sqrp33j7uuzr7amtlditi/node_modules/@tamagui/static/dist/require.js:55:22)
transform[stderr]:     at require (node:internal/modules/cjs/helpers:102:18)
transform[stderr]:     at attemptLoad (/srv/paymium/paymium-client-united/node_modules/.pnpm/@[email protected]_yxd22sqrp33j7uuzr7amtlditi/node_modules/@tamagui/static/dist/extractor/loadTamagui.js:334:34)
transform[stderr]:     at /srv/paymium/paymium-client-united/node_modules/.pnpm/@[email protected]_yxd22sqrp33j7uuzr7amtlditi/node_modules/@tamagui/static/dist/extractor/loadTamagui.js:342:21
transform[stderr]:     at Array.flatMap (<anonymous>)
transform[stderr]:     at loadComponents (/srv/paymium/paymium-client-united/node_modules/.pnpm/@[email protected]_yxd22sqrp33j7uuzr7amtlditi/node_modules/@tamagui/static/dist/extractor/loadTamagui.js:308:36)
transform[stderr]:     at loadTamaguiSync (/srv/paymium/paymium-client-united/node_modules/.pnpm/@[email protected]_yxd22sqrp33j7uuzr7amtlditi/node_modules/@tamagui/static/dist/extractor/loadTamagui.js:198:26)
transform[stderr]:     at loadSync (/srv/paymium/paymium-client-united/node_modules/.pnpm/@[email protected]_yxd22sqrp33j7uuzr7amtlditi/node_modules/@tamagui/static/dist/extractor/createExtractor.js:79:81)
transform[stderr]:     at Object.parseSync (/srv/paymium/paymium-client-united/node_modules/.pnpm/@[email protected]_yxd22sqrp33j7uuzr7amtlditi/node_modules/@tamagui/static/dist/extractor/createExtractor.js:101:28)
transform[stderr]:     at PluginPass.enter (/srv/paymium/paymium-client-united/node_modules/.pnpm/@[email protected]_yxd22sqrp33j7uuzr7amtlditi/node_modules/@tamagui/babel-plugin/dist/cjs/index.js:87:23)
transform[stderr]:     at newFn (/srv/paymium/paymium-client-united/node_modules/.pnpm/@[email protected]/node_modules/@babel/traverse/lib/visitors.js:143:21)
transform[stderr]:     at NodePath._call (/srv/paymium/paymium-client-united/node_modules/.pnpm/@[email protected]/node_modules/@babel/traverse/lib/path/context.js:45:20)
transform[stderr]:     at NodePath.call (/srv/paymium/paymium-client-united/node_modules/.pnpm/@[email protected]/node_modules/@babel/traverse/lib/path/context.js:35:17)
transform[stderr]:     at NodePath.visit (/srv/paymium/paymium-client-united/node_modules/.pnpm/@[email protected]/node_modules/@babel/traverse/lib/path/context.js:80:31)
transform[stderr]:     at TraversalContext.visitQueue (/srv/paymium/paymium-client-united/node_modules/.pnpm/@[email protected]/node_modules/@babel/traverse/lib/context.js:86:16)
transform[stderr]:     at TraversalContext.visitSingle (/srv/paymium/paymium-client-united/node_modules/.pnpm/@[email protected]/node_modules/@babel/traverse/lib/context.js:65:19)
transform[stderr]:     at TraversalContext.visit (/srv/paymium/paymium-client-united/node_modules/.pnpm/@[email protected]/node_modules/@babel/traverse/lib/context.js:109:19)
transform[stderr]:     at traverseNode (/srv/paymium/paymium-client-united/node_modules/.pnpm/@[email protected]/node_modules/@babel/traverse/lib/traverse-node.js:18:17)
transform[stderr]:     at traverse (/srv/paymium/paymium-client-united/node_modules/.pnpm/@[email protected]/node_modules/@babel/traverse/lib/index.js:49:34)
transform[stderr]:     at transformFile (/srv/paymium/paymium-client-united/node_modules/.pnpm/@[email protected]/node_modules/@babel/core/lib/transformation/index.js:81:29)
transform[stderr]:     at transformFile.next (<anonymous>)
transform[stderr]:     at run (/srv/paymium/paymium-client-united/node_modules/.pnpm/@[email protected]/node_modules/@babel/core/lib/transformation/index.js:24:12)
transform[stderr]:     at run.next (<anonymous>)
transform[stderr]:     at /srv/paymium/paymium-client-united/node_modules/.pnpm/@[email protected]/node_modules/@babel/core/lib/transform-ast.js:23:41
transform[stderr]:     at Generator.next (<anonymous>)
transform[stderr]:     at evaluateSync (/srv/paymium/paymium-client-united/node_modules/.pnpm/[email protected]/node_modules/gensync/index.js:251:28)
transform[stderr]:     at sync (/srv/paymium/paymium-client-united/node_modules/.pnpm/[email protected]/node_modules/gensync/index.js:89:14)
transform[stderr]:     at stopHiding - secret - don't use this - v1 (/srv/paymium/paymium-client-united/node_modules/.pnpm/@[email protected]/node_modules/@babel/core/lib/errors/rewrite-stack-trace.js:46:12)
transform[stderr]:     at transformFromAstSync (/srv/paymium/paymium-client-united/node_modules/.pnpm/@[email protected]/node_modules/@babel/core/lib/transform-ast.js:44:83)
transform[stderr]:     at Object.transform (/srv/paymium/paymium-client-united/node_modules/.pnpm/[email protected][email protected][email protected]/node_modules/metro-react-native-babel-transformer/src/index.js:199:20)
transform[stderr]:     at transformJSWithBabel (/srv/paymium/paymium-client-united/node_modules/.pnpm/[email protected]/node_modules/metro-transform-worker/src/index.js:399:45)
transform[stderr]:     at Object.transform (/srv/paymium/paymium-client-united/node_modules/.pnpm/[email protected]/node_modules/metro-transform-worker/src/index.js:572:18)
transform[stderr]:     at transformFile (/srv/paymium/paymium-client-united/node_modules/.pnpm/[email protected]/node_modules/metro/src/DeltaBundler/Worker.flow.js:82:36)
transform[stderr]:     at Object.transform (/srv/paymium/paymium-client-united/node_modules/.pnpm/[email protected]/node_modules/metro/src/DeltaBundler/Worker.flow.js:55:10)
transform[stderr]:     at execFunction (/srv/paymium/paymium-client-united/node_modules/.pnpm/[email protected]/node_modules/jest-worker/build/workers/processChild.js:137:17)
transform[stderr]:     at execHelper (/srv/paymium/paymium-client-united/node_modules/.pnpm/[email protected]/node_modules/jest-worker/build/workers/processChild.js:116:5)
transform[stderr]:     at execMethod (/srv/paymium/paymium-client-united/node_modules/.pnpm/[email protected]/node_modules/jest-worker/build/workers/processChild.js:120:5)
transform[stderr]:     at process.messageListener (/srv/paymium/paymium-client-united/node_modules/.pnpm/[email protected]/node_modules/jest-worker/build/workers/processChild.js:38:7)
transform[stderr]:     at process.emit (node:events:527:28)
transform[stderr]:     at emit (node:internal/child_process:938:14)
transform[stderr]:     at processTicksAndRejections (node:internal/process/task_queues:84:21)
transform[stderr]:   
transform[stderr]:     You can see if it loads in the node repl:
transform[stderr]:   
transform[stderr]:     require("./@paymium/cross-ui").default
// babel.config.js
[
      require.resolve("babel-plugin-module-resolver"),
      {
        root: ["../.."],
        alias: {
          // "react-native-reanimated": "./node_modules/react-native-reanimated/libe/index.js",
          "@paymium/cross-ui": "../../packages/cross-ui",
          // "@paymium/cross-form": "../../packages/cross-ui/src/index.ts",
          // "@paymium/cross-currencies": "../../packages/cross-ui/src/index.ts",
        },
        extensions: [".js", ".jsx", ".ts", ".tsx", ".ios.js", ".android.js"],
      },
    ],
    [
      "@tamagui/babel-plugin",
      {
        config: "./tamagui.config.ts",
        importsWhitelist: [],
        components: [
          // "tamagui",
          "@paymium/cross-ui",
          // "@paymium/cross-form",
          // "@paymium/cross-currencies",
        ],
      },
    ],

Work good for nextjs. I try to reproduce with starter but not reproductible

If I put empty array in components i have the same error Tamagui failed loading the pre-built tamagui.config.ts. if i change config params for config: "../../packages/cross-ui/src/tamagui.config.ts", with empty components, no error, just this message Ignoring file due to includeExtensions: /srv/paymium/paymium-client-united/apps/paymium-mobile/index.js, includeExtensions: .ts, .tsx, .jsx With config on relative path, i add components: ["tamagui", "@paymium/cross-ui"] and i get this error

transform[stderr]: Tamagui failed getting from @paymium/cross-ui (Disable error by setting environment variable TAMAGUI_DISABLE_WARN_DYNAMIC_LOAD=1)
transform[stderr]: Error: Invalid export from package @paymium/cross-ui: function

image

System Info (please complete the following information):

System:
    OS: Linux 5.15 Ubuntu 22.04.1 LTS 22.04.1 LTS (Jammy Jellyfish)
    CPU: (8) x64 Intel(R) Core(TM) i7-9700K CPU @ 3.60GHz
    Memory: 21.37 GB / 31.27 GB
    Container: Yes
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.15.0 - ~/.nvm/versions/node/v16.15.0/bin/node
    Yarn: 1.22.19 - ~/.local/share/pnpm/yarn
    npm: 8.5.5 - ~/.nvm/versions/node/v16.15.0/bin/npm
    Watchman: 4.9.0 - /usr/bin/watchman
  Browsers:
    Brave Browser: 108.1.46.153
    Chrome: 108.0.5359.124
  npmPackages:
    @babel/runtime: ^7.20.1 => 7.20.13 
    @swc/core: ^1.3.17 => 1.3.28 
    @swc/jest: ^0.2.23 => 0.2.24 
    @testing-library/react-hooks: ^8.0.1 => 8.0.1 
    @types/jest: ^29.2.3 => 29.2.6 
    @types/lodash: ^4.14.189 => 4.14.191 
    @types/node: ^18.11.9 => 18.11.18 
    @types/react: ^18.0.25 => 18.0.27 
    @types/socket.io-client: ^1.4.36 => 1.4.36 
    eslint-config-custom: * => 0.0.0 
    jest: ^29.3.1 => 29.4.0 
    react-dom: ^18.2.0 => 18.2.0 
    react-test-renderer: ^18.2.0 => 18.2.0 
    tslib: ^2.4.1 => 2.4.1 
    turbo: latest => 1.7.0 
    typescript: ^4.8.4 => 4.9.4 
0

I found the issue, i use pnpm and added in package.json this config => https://pnpm.io/fr/package_json#dependenciesmetainjected This break babel plugin, i remove it and it's work

0
© 2022 pullanswer.com - All rights reserved.