brillout / telefunc

Remote Functions. Instead of API.
https://telefunc.com
MIT License
688 stars 31 forks source link

Error when importing telefunc that is outside sub-project root in monorepo (metro already configured, and RN is 0.72 which supports symlink) #94

Closed pencilcheck closed 10 months ago

pencilcheck commented 10 months ago

Folder structure:

error: ../func/hello.telefunc.ts: /Users/pencilcheck/Projects/project-new-expo/apps/func/hello.telefunc.ts: [telefunc@0.1.67][Bug] You stumbled upon a bug in Telefunc's source code. Reach out at https://github.com/brillout/telefunc/issues/new or https://discord.com/invite/3DYWwk4xRQ and include this error stack (the error stack is usually enough to fix the problem). A maintainer will fix the bug (usually under 24 hours). Don't hesitate to reach out as it makes Telefunc more robust.
Error: [telefunc@0.1.67][Bug] You stumbled upon a bug in Telefunc's source code. Reach out at https://github.com/brillout/telefunc/issues/new or https://discord.com/invite/3DYWwk4xRQ and include this error stack (the error stack is usually enough to fix the problem). A maintainer will fix the bug (usually under 24 hours). Don't hesitate to reach out as it makes Telefunc more robust.
    at transformTelefuncFileClientSideSync (/Users/pencilcheck/Projects/project-new-expo/apps/expo/node_modules/telefunc/dist/cjs/node/transformer/transformTelefuncFileClientSideSync.js:10:24)
    at PluginPass.Program (/Users/pencilcheck/Projects/project-new-expo/apps/expo/node_modules/telefunc/dist/cjs/node/babel/plugin.js:69:115)
    at newFn (/Users/pencilcheck/Projects/project-new-expo/apps/expo/node_modules/@babel/traverse/lib/visitors.js:160:14)
    at NodePath._call (/Users/pencilcheck/Projects/project-new-expo/apps/expo/node_modules/@babel/traverse/lib/path/context.js:46:20)
    at NodePath.call (/Users/pencilcheck/Projects/project-new-expo/apps/expo/node_modules/@babel/traverse/lib/path/context.js:36:17)
    at NodePath.visit (/Users/pencilcheck/Projects/project-new-expo/apps/expo/node_modules/@babel/traverse/lib/path/context.js:82:31)
    at TraversalContext.visitQueue (/Users/pencilcheck/Projects/project-new-expo/apps/expo/node_modules/@babel/traverse/lib/context.js:86:16)
    at TraversalContext.visitSingle (/Users/pencilcheck/Projects/project-new-expo/apps/expo/node_modules/@babel/traverse/lib/context.js:65:19)
    at TraversalContext.visit (/Users/pencilcheck/Projects/project-new-expo/apps/expo/node_modules/@babel/traverse/lib/context.js:109:19)
    at traverseNode (/Users/pencilcheck/Projects/project-new-expo/apps/expo/node_modules/@babel/traverse/lib/traverse-node.js:22:17)
    at traverse (/Users/pencilcheck/Projects/project-new-expo/apps/expo/node_modules/@babel/traverse/lib/index.js:52:34)
    at transformFile (/Users/pencilcheck/Projects/project-new-expo/apps/expo/node_modules/@babel/core/lib/transformation/index.js:82:31)
    at transformFile.next (<anonymous>)
    at run (/Users/pencilcheck/Projects/project-new-expo/apps/expo/node_modules/@babel/core/lib/transformation/index.js:24:12)
    at run.next (<anonymous>)
    at /Users/pencilcheck/Projects/project-new-expo/apps/expo/node_modules/@babel/core/lib/transform-ast.js:23:33
    at Generator.next (<anonymous>)
    at evaluateSync (/Users/pencilcheck/Projects/project-new-expo/apps/expo/node_modules/gensync/index.js:251:28)
    at sync (/Users/pencilcheck/Projects/project-new-expo/apps/expo/node_modules/gensync/index.js:89:14)
    at stopHiding - secret - don't use this - v1 (/Users/pencilcheck/Projects/project-new-expo/apps/expo/node_modules/@babel/core/lib/errors/rewrite-stack-trace.js:47:12)
    at transformFromAstSync (/Users/pencilcheck/Projects/project-new-expo/apps/expo/node_modules/@babel/core/lib/transform-ast.js:43:83)
    at Object.transform (/Users/pencilcheck/Projects/project-new-expo/apps/expo/node_modules/metro-react-native-babel-transformer/src/index.js:201:20)
    at transformJSWithBabel (/Users/pencilcheck/Projects/project-new-expo/apps/expo/node_modules/metro-transform-worker/src/index.js:330:45)
    at transform (/Users/pencilcheck/Projects/project-new-expo/apps/expo/node_modules/metro-transform-worker/src/index.js:461:18)
    at transform (/Users/pencilcheck/Projects/project-new-expo/apps/expo/node_modules/react-native-css-interop/dist/metro/transformer.js:15:16)
    at Object.transform (/Users/pencilcheck/Projects/project-new-expo/apps/expo/node_modules/nativewind/dist/metro/transformer.js:25:40)
    at transformFile (/Users/pencilcheck/Projects/project-new-expo/apps/expo/node_modules/metro/src/DeltaBundler/Worker.flow.js:73:36)
    at Object.transform (/Users/pencilcheck/Projects/project-new-expo/apps/expo/node_modules/metro/src/DeltaBundler/Worker.flow.js:48:10)
    at execFunction (/Users/pencilcheck/Projects/project-new-expo/apps/expo/node_modules/jest-worker/build/workers/processChild.js:137:17)
    at execHelper (/Users/pencilcheck/Projects/project-new-expo/apps/expo/node_modules/jest-worker/build/workers/processChild.js:116:5)
    at execMethod (/Users/pencilcheck/Projects/project-new-expo/apps/expo/node_modules/jest-worker/build/workers/processChild.js:120:5)
    at process.messageListener (/Users/pencilcheck/Projects/project-new-expo/apps/expo/node_modules/jest-worker/build/workers/processChild.js:38:7)
brillout commented 10 months ago

Insert the following line before line 10 of /Users/pencilcheck/Projects/project-new-expo/apps/expo/node_modules/telefunc/dist/cjs/node/transformer/transformTelefuncFileClientSideSync.js and report back the log results.

    const telefuncFilePath = '/' + path_1.posix.relative(appRootDir, id);
+   console.log('telefuncFilePath', telefuncFilePath);
    (0, utils_1.assert)(!telefuncFilePath.startsWith('/.'));
pencilcheck commented 10 months ago

Only include the relevant logs, the rest are metro and expo stuff

transform[stdout]: telefuncFilePath /../func/hello.telefunc.mjs
Android Bundling failed 1937ms
error: ../func/hello.telefunc.mjs: /Users/pencilcheck/Projects/project-new-expo/apps/func/hello.telefunc.mjs: [telefunc@0.1.67][Bug] You stumbled upon a bug in Telefunc's source code. Reach out at https://github.com/brillout/telefunc/issues/new or https://discord.com/invite/3DYWwk4xRQ and include this error stack (the error stack is usually enough to fix the problem). A maintainer will fix the bug (usually under 24 hours). Don't hesitate to reach out as it makes Telefunc more robust.
brillout commented 10 months ago

Fixed. You should now get an helpful error message instead.