Loaders Do Not Work: traverse is not a function.
If I add the loader to my index page, like this:
import { Image } from '@tamagui/image-next'
import { Text, YStack } from 'tamagui'
import oneBall from '~/public/app-icon.png'
import { useLoader } from 'one'
export async function loader() {
return {
user: 'tamagui'
}
}
export function HomePage() {
const data = useLoader(loader)
return (
<YStack
bg='$color1'
mih='100%'
gap='$4'
ai='center'
jc='center'
f={1}
>
<Text fontSize={20}>Hello, {data.user}</Text>
<Image
src={oneBall}
width={128}
height={128}
/>
</YStack>
)
}
I will get the following error:
[vite] program reload
[vite] An error happened during full reload
[vite] cannot find entry point module 'virtual:one-entry'.
Error: [vite] cannot find entry point module 'virtual:one-entry'.
at <anonymous> (/Users/panda/Desktop/monorepo/node_modules/vite/dist/node/chunks/dep-0AosnpPU.js:51428:13)
at processTicksAndRejections (native)
đȘ app/index.tsx
24 | referenced = findReferencedIdentifiers(ast),
25 | removed = {
26 | loader: !1,
27 | generateStaticParams: !1
28 | };
29 | traverse(ast, {
^
TypeError: traverse is not a function. (In 'traverse(ast, {
ExportNamedDeclaration(path) {
if (path.node.declaration && path.node.declaration.type === "FunctionDeclaration") {
if (!path.node.declaration.id)
return;
const functionName = path.node.declaration.id.name;
(functionName === "loader" || functionName === "generateStaticParams") && (path.remove(), removed[functionName] = !0);
} else
path.node.declaration && path.node.declaration.type === "VariableDeclaration" && path.node.declaration.declarations.forEach((declarator, index) => {
if (declarator.id.type === "Identifier" && (declarator.id.name === "loader" || declarator.id.name === "generateStaticParams")) {
const declaration = path.get("declaration.declarations." + index);
Array.isArray(declaration) || (declaration.remove(), removed[declarator.id.name] = !0);
}
});
}
})', 'traverse' is undefined)
at /Users/panda/Desktop/monorepo/node_modules/one/dist/esm/vite/plugins/clientTreeShakePlugin.mjs:29:3
at transformTreeShakeClient (/Users/panda/Desktop/monorepo/node_modules/one/dist/esm/vite/plugins/clientTreeShakePlugin.mjs:17:3)
at /Users/panda/Desktop/monorepo/node_modules/one/dist/esm/vite/plugins/clientTreeShakePlugin.mjs:15:37
at transform (/Users/panda/Desktop/monorepo/node_modules/one/dist/esm/vite/plugins/clientTreeShakePlugin.mjs:14:21)
at /Users/panda/Desktop/monorepo/node_modules/vite/dist/node/chunks/dep-0AosnpPU.js:47220:19
at processTicksAndRejections (native:1:1)
Bun v1.1.42 (macOS arm64)
error: script "dev" exited with code 1
I use one version 1.1.375, with react 19.
what starter template / what platform / how can we repro?
@natew minimal tamagui template, macO, and using bun. Using latest version of all of them as time of writing.
@natew Just started trying out this framework and I am having the same issue. I am using the tamagui starter and just added a loader to app/index.tsx and got the same error.
I bumped into this issue as well, using Bun 1.2.19 and One 1.1.506.
Hi @gyulavoros @lukeshay - thanks for providing the info, but unfortunately I'm unable to reproduce the issue using npx one, Minimal Tamagui, and bun.
Tried with Node.js versions 22.17.1, 20.18.0, and 24.3.0.
jq .version node_modules/@babel/traverse/package.json shows "7.28.0".
Could you share your Node.js version, along with your package.json and bun.lock files to help troubleshoot further?
Hi @zetavg, thank you for looking into this!
Here's an example project for repro: hello-world.zip
Please note, that I use bun --bun run dev to run the project (--bun). Running bun run dev works. I had the assumption that without the --bun flag, Vite would actually use Node to run the project, but I've just checked the Activity Monitor, and it doesn't seem to be the case. đ€
Hope it helps to investigate!
This was the project setup:
bunx one
warn: incorrect peer dependency "[email protected]"
warn: incorrect peer dependency "[email protected]"
warn: incorrect peer dependency "[email protected]"
warn: incorrect peer dependency "[email protected]"
Hello. Let's create a new â app...
â Name ⊠hello-world
â Template âș Minimal
â Creating...
hello-world created!
â Package Manager: âș bun
Installing with bun...
bun install v1.2.19 (aad3abea)
warn: incorrect peer dependency "[email protected]"
warn: incorrect peer dependency "@expo/[email protected]"
warn: incorrect peer dependency "[email protected]"
+ @react-native-community/[email protected]
+ @types/[email protected] (v19.1.8 available)
+ [email protected]
+ [email protected]
+ [email protected]
+ [email protected] (v19.1.0 available)
+ [email protected] (v0.80.2 available)
+ [email protected] (v4.0.0 available)
+ [email protected]
+ [email protected]
+ [email protected] (v0.21.0 available)
1026 packages installed [3.43s]
Blocked 3 postinstalls. Run `bun pm untrusted` for details.
bun install completed successfully.
Done! Created a new project under ./hello-world
This is how I run the project:
bun --bun run dev
$ one dev
[vite] connected.
10:58:05 AM [vite] (client) Re-optimizing dependencies because vite config has changed
10:58:05 AM [vite] (ssr) Re-optimizing dependencies because vite config has changed
Server running on âȘą
â Local: http://localhost:8081/
â Network: http://192.168.1.112:8081/
âș Press ow â open web
âș Press oi â open app in iOS Simulator
âș Press oa â open app in Android Emulator
âș Press oe â open editor
âș Press qr â show Expo Go QR code
âș Press dt â open React Native DevTools
âș Press ? â show this menu
â” [ssg] http://localhost:8081/ resolved to app/index.tsx
10:58:08 AM [vite] Internal server error: traverse is not a function. (In 'traverse(ast, {
ExportNamedDeclaration(path) {
if (path.node.declaration && path.node.declaration.type === "FunctionDeclaration") {
if (!path.node.declaration.id)
return;
const functionName = path.node.declaration.id.name;
(functionName === "loader" || functionName === "generateStaticParams") && (path.remove(), removed[functionName] = !0);
} else
path.node.declaration && path.node.declaration.type === "VariableDeclaration" && path.node.declaration.declarations.forEach((declarator, index) => {
if (declarator.id.type === "Identifier" && (declarator.id.name === "loader" || declarator.id.name === "generateStaticParams")) {
const declaration = path.get("declaration.declarations." + index);
Array.isArray(declaration) || (declaration.remove(), removed[declarator.id.name] = !0);
}
});
}
})', 'traverse' is undefined)
Plugin: one-client-tree-shake
File: /Users/gyulavoros/Downloads/temp/hello-world/app/index.tsx:33:3
at transformTreeShakeClient (/Users/gyulavoros/Downloads/temp/hello-world/node_modules/one/dist/esm/vite/plugins/clientTreeShakePlugin.mjs:33:3)
at transformTreeShakeClient (/Users/gyulavoros/Downloads/temp/hello-world/node_modules/one/dist/esm/vite/plugins/clientTreeShakePlugin.mjs:22:41)
at handler (/Users/gyulavoros/Downloads/temp/hello-world/node_modules/one/dist/esm/vite/plugins/clientTreeShakePlugin.mjs:18:134)
at handler (/Users/gyulavoros/Downloads/temp/hello-world/node_modules/one/dist/esm/vite/plugins/clientTreeShakePlugin.mjs:17:21)
at transform (/Users/gyulavoros/Downloads/temp/hello-world/node_modules/vite/dist/node/chunks/dep-BHkUv4Z8.js:31274:51)
at transform (/Users/gyulavoros/Downloads/temp/hello-world/node_modules/vite/dist/node/chunks/dep-BHkUv4Z8.js:31256:18)
at loadAndTransform (/Users/gyulavoros/Downloads/temp/hello-world/node_modules/vite/dist/node/chunks/dep-BHkUv4Z8.js:26451:48)
at processTicksAndRejections (native:7:39)
I think this is likely more a bun issue than our issue, in that they have different module resolution. Does it work on the latest bun now? We don't support bun --bun atm, I'm adding that to the docs. If someone wants to help contribute happy to accept it!
@natew with the latest bun (1.2.20), it still doesn't work, but there's a different error:
bun --bun dev
$ one dev
[vite] connected.
â [ERROR] Could not resolve "@babel/runtime/helpers/interopRequireDefault"
../../.bun/install/cache/[email protected]@@@1/dist/cjs/index.js:3:37:
3 â var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
â” ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can mark the path "@babel/runtime/helpers/interopRequireDefault" as external to exclude it
from the bundle, which will remove this error and leave the unresolved path in the bundle. You can
also surround this "require" call with a try/catch block to handle this failure at run-time
instead of bundle-time.
â [ERROR] Could not resolve "@babel/runtime/helpers/interopRequireDefault"
../../.bun/install/cache/[email protected]@@@1/dist/cjs/exports/ProgressBar/index.js:13:37:
13 â var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
â” ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can mark the path "@babel/runtime/helpers/interopRequireDefault" as external to exclude it
from the bundle, which will remove this error and leave the unresolved path in the bundle. You can
also surround this "require" call with a try/catch block to handle this failure at run-time
instead of bundle-time.
â [ERROR] Could not resolve "@babel/runtime/helpers/interopRequireDefault"
../../.bun/install/cache/[email protected]@@@1/dist/cjs/exports/createElement/index.js:13:37:
13 â var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault").default;
â” ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
You can mark the path "@babel/runtime/helpers/interopRequireDefault" as external to exclude it
from the bundle, which will remove this error and leave the unresolved path in the bundle. You can
also surround this "require" call with a try/catch block to handle this failure at run-time
instead of bundle-time.
...
And it continues for ~9000 lines.