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

Unable to import module from across PNPM workspace #762

Open
gabrielecirulli opened this issue May 2, 2024 · 0 comments
Open

Unable to import module from across PNPM workspace #762

gabrielecirulli opened this issue May 2, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@gabrielecirulli
Copy link

gabrielecirulli commented May 2, 2024

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/typesafe-i18n@5.26.2_typescript@5.4.2/node_modules/typesafe-i18n/temp-output/1/en/index.js
[typesafe-i18n] ERROR: could not read default export from base locale file 'en'

Reproduction

  1. Set up a PNPM monorepo with the following structure

pnpm-workspaces.yaml:

packages:
  - "apps/frontend"
  - "logic/core"
  1. Set up typesafe-i18n in apps/frontend
  2. Export an enum from somewhere in logic/core

Logs

No response

Config

No response

Additional information

No response

@gabrielecirulli gabrielecirulli added the bug Something isn't working label May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant