Vite + pnpm Workspaces: Uncaught SyntaxError: The requested module does not provide an export named '{type}'

77 views Asked by At

I am trying to setup a pnpm workspace where I have the following structure:

packages/

  • backend
  • frontend
  • shared

Both the backend and frontend will consume types from shared. Currently, I can import types from shared from the backend package. However, when I do so in the frontend package I get the following console.error:

Uncaught SyntaxError: The requested module 'app-name/packages/shared/src/auth/jwtToken.dto.ts' does not provide an export named 'JwtAccessTokenType'.

This is my current vite.config.js:

/** @type {import('vite').UserConfig} */

import { resolve } from 'path';

import { defineConfig } from 'vite';
import eslint from 'vite-plugin-eslint';
import svgr from 'vite-plugin-svgr';
import react from '@vitejs/plugin-react';

// https://vitejs.dev/config/
export default defineConfig(() => ({
  plugins: [
    react(),
    svgr(),
    eslint({
      include: ['./src/**/*.{js,jsx,ts,tsx}'],
    }),
  ],
  resolve: {
    alias: {
      '~': resolve(__dirname, './src'),
    },
  },
}));

Do I need to configure something here so that Vite compiles correctly with a pnpm workspace package?

If I hover over the file that consumes the type in frontend I can see that Typescript infers the type correctly (probably not a TS issue).

Any ideas on what I am doing wrong?

0

There are 0 answers