Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

libSQL Bundling Error with Expo Router v3 API Routes #97

Open
fe-franco opened this issue Apr 7, 2024 · 3 comments
Open

libSQL Bundling Error with Expo Router v3 API Routes #97

fe-franco opened this issue Apr 7, 2024 · 3 comments

Comments

@fe-franco
Copy link

Hello everyone,
I'm currently in the process of building an Expo app utilizing the Expo Router v3 API routes. Previously, I had been using Planetscale without any issues. However, upon attempting to migrate to Turso, I've encountered a bundling error:

Metro error: Unable to resolve module ./.targets from /Users/fefranco/code/libsql-expo/node_modules/libsql/index.js: 

None of these files exist:
  * node_modules/libsql/.targets(.web.ts|.ts|.web.tsx|.tsx|.web.js|.js|.web.jsx|.jsx|.web.json|.json|.web.cjs|.cjs|.web.mjs|.mjs|.web.scss|.scss|.web.sass|.sass|.web.css|.css)
  * node_modules/libsql/.targets/index(.web.ts|.ts|.web.tsx|.tsx|.web.js|.js|.web.jsx|.jsx|.web.json|.json|.web.cjs|.cjs|.web.mjs|.mjs|.web.scss|.scss|.web.sass|.sass|.web.css|.css)
   6 | // Static requires for bundlers.
   7 | if (0) {
>  8 |   require("./.targets");
     |            ^
   9 | }
  10 |
  11 | let target = currentTarget();


Call Stack
  Object.requireFileContentsWithMetro (node_modules/@expo/cli/src/start/server/getStaticRenderFunctions.ts:190:13)
  processTicksAndRejections (node:internal/process/task_queues)
  bundleAsync (node_modules/@expo/cli/src/start/server/metro/bundleApiRoutes.ts:39:26)
  getApiRoute (node_modules/@expo/cli/src/start/server/metro/createServerRouteMiddleware.ts:138:36)
  handler (node_modules/@expo/server/src/index.ts:178:20)
  <unknown> (node_modules/@expo/server/src/vendor/http.ts:36:24)
TypeError: Cannot read properties of null (reading 'GET')
    at handler (/Users/fefranco/code/libsql-expo/node_modules/@expo/server/src/index.ts:184:32)
    at processTicksAndRejections (node:internal/process/task_queues:95:5)
    at /Users/fefranco/code/libsql-expo/node_modules/@expo/server/src/vendor/http.ts:36:24
Unable to resolve "./.targets" from "node_modules/libsql/index.js"

I've created a minimal reproduction of the issue in CodeSandbox

@Ableez
Copy link

Ableez commented Jul 27, 2024

I encountered the same problem using Turso,
Android Bundling failed 12919ms C:\Users\ableez\Documents\Repos\askerisk\node_modules\expo-router\entry.js (3444 modules)
Unable to resolve "@libsql/core/config" from "node_modules@libsql\client\lib-cjs\node.js"

@coffey-dev
Copy link

I encountered the same problem using Turso, Android Bundling failed 12919ms C:\Users\ableez\Documents\Repos\askerisk\node_modules\expo-router\entry.js (3444 modules) Unable to resolve "@libsql/core/config" from "node_modules@libsql\client\lib-cjs\node.js"

I am experiencing the same issue! Any libsql-js dev can solve this? We can't connect Turso databases with an expo-react native app!

@khuezy
Copy link

khuezy commented Aug 22, 2024

Expo is doing its static analysis on the libsql file.

if (0) {
   require("./.targets");
}

This is suppose to only load when it's in "dev" mode:

  if (process.env.LIBSQL_JS_DEV) {
    return load(__dirname)
  }

Turso can add a try/catch, or you can create a temporary .targets file in node_modules/libsql/.targets

If that doesn't work, try monkey patching that library.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants