typesafe-i18n
typesafe-i18n copied to clipboard
Unable to import module from across PNPM workspace
Version
5.26.2
Describe the bug
I have a PNPM workspaces repository with the following structure
apps/
- frontend/
logic/
- core/
I've set up typesafe-i18n
in my frontend
package. From this package, I can usually import stuff in core
using @my-repo/core
.
However, the typesafe-i18n
watcher does not seem able to work with this setup. Within my en/index.ts
file I'm importing an enum from core
in order to populate a set of translations corresponding to each enum entry. Here's an example:
import { MyEnum } from "@my-repo/core";
import type { BaseTranslation } from "../i18n-types";
const en = {
stuff: {
[MyEnum.First]: {
title: "First thing",
},
[MyEnum.Second]: {
title: "Second thing",
},
// etc.
},
} satisfies BaseTranslation;
export default en;
Here's the error I get:
[typesafe-i18n] ERROR: import failed for /Users/user/my-repo/apps/frontend/node_modules/typesafe-i18n/temp-output/1/en/index.js Error: Cannot find module '@my-repo/core'
Require stack:
- /Users/user/my-repo/node_modules/.pnpm/[email protected][email protected]/node_modules/typesafe-i18n/temp-output/1/en/index.js
[typesafe-i18n] ERROR: could not read default export from base locale file 'en'
Reproduction
- Set up a PNPM monorepo with the following structure
pnpm-workspaces.yaml
:
packages:
- "apps/frontend"
- "logic/core"
- Set up typesafe-i18n in
apps/frontend
- Export an enum from somewhere in
logic/core
Logs
No response
Config
No response
Additional information
No response
Same issue here, moving back the client to frontend.