Open Alexandre-Fernandez opened 1 year ago
Apparently the problem are not monorepos but PNPM. I made a new reproduction here : https://github.com/Alexandre-Fernandez/astro-i18next-issue-48
If you install with npm install
it works, but if you install with pnpm install
you get the module not defined
error.
Add this file to your root :
/.npmrc
public-hoist-pattern[]="*deepmerge*"
public-hoist-pattern[]="*proload*"
public-hoist-pattern[]="*locale-emoji*"
While I haven't used the module yet, I'm a big fan of both astro and pnpm so I had a quick look at the source.
First thing I notice is these 2 imports:
cli/utils.ts:import { AstroI18nextConfig } from "types"; cli/generate.ts:import { AstroI18nextConfig } from "types";
Both should probably import from "./types" (or ./types.ts - I never know if the extension is required).
Other than that, I see these imports, all from dev deps. Probably should be regular deps:
cli/utils.ts:import { fdir, PathsOutput } from "fdir"; // dev dep
index.ts:import { AstroIntegration } from "astro"; // dev dep
cli/middlewares.ts:import { MiddlewareFunction } from "yargs"; // dev dep
cli/index.ts:import yargs from "yargs"; // dev dep
cli/index.ts:import { hideBin } from "yargs/helpers"; // dev dep
cli/utils.ts:import fsExtra from "fs-extra"; // dev dep
cli/utils.ts:import ts from "typescript"; // dev dep
With those fixes, pnpm might be happy without resorting to public-hoist-patterns
.
When I try to use
<Trans />
,<HeadHrefLangs />
,<LanguageSelector />
,interpolate
, etc I get the following error :I'm using
pnpm
andturborepo
, reproduction (error atapps/frontend/src/layouts/Layout.astro
line 2 & 19): https://github.com/Alexandre-Fernandez/turborepo-astro-nestjsAstro app is located in
/apps/frontend
, commands to get the error :pnpm install
pnpm dev --filter frontend
EDIT:
This might happen because it's trying to load from the monorepo root
/node_modules
instead of its corresponding workspace/apps/frontend/node_modules
. I say that because I get a different error (another missing dependency) when I installdeepmerge@4.2.2
in the rootpackage.json
(pnpm add deepmerge@4.2.2 -w
). This only happens withastro-i18next
and not withi18next
.