tursodatabase / tursodatabase/libsql-js

libSQL Bundling Error with Expo Router v3 API Routes

Open
#97 5 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
335
Forks
48
Avg merge
3d 2h
Merged PRs (30d)
3

Description

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

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the linked CodeSandbox minimal reproduction and the Metro error from node_modules/libsql/index.js, focusing on the unresolved ./.targets import during Expo Router API-route bundling. Done means the reproduction bundles successfully without the unresolved-module error and the API route handler no longer fails while reading GET.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, nodejs, react-native
Domain
api, build-system, databases
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.