SvelteKit PNPM Monorepo TS Errors Reproduction
Created as a tiny-repro to which I will link from a StackOverflow question I'll be posting.
Steps I followed to create this repro:
- mkdir example
- cd example
- pnpm init
- update package.json changing name to
@example/root
- mkdir
packages/app
- mkdir
packages/pkg
- create pnpm-workspace.yaml
- cd
packages/pkg
- pnpm init
- pnpm add @redis/client
- pnpm add -D typescript tsup
- update package.json changing name to
@example/pkg
, remove main
key, add type=module
, exports
, and types
. Add some useful scripts.
- create
packages/pkg/index.ts
(content visible in repo^)
- pnpm tsc --init
- pnpm run build (no errors, generated files seem reasonable.)
- cd
../app
npm create svelte@latest .
//suggested by https://kit.svelte.dev
- use current directory
- skeleton project
- use TS syntax
- no eslint, prettier, playwright, or vitest since they're not necessary for repro
- update package.json changing name to
@example/app
- manually add pnpm workspace dependency to package.json:
"@example/pkg": "workspace:^"
- pnpm install
- create
packages/app/src/routes/+page.server.ts
(content visible in repo^)
- cd
packages/app
&& pnpm run dev
- navigate to http://localhost:5173/
- Note that the same error appears: Internal server error: exports is not defined
- git init
- echo "node_modules" > .gitignore
- git add .
- git commit