aleclarson / vite-tsconfig-paths

Support for TypeScript's path mapping in Vite
MIT License
1.23k stars 44 forks source link

[plugin externalize-deps] Missing "./dist" specifier in "vite-tsconfig-paths" package #102

Closed quantuminformation closed 1 year ago

quantuminformation commented 1 year ago

anyone seen that error ^

/// <reference types="vitest" />
/// <reference types="vite/client" />

import { defineConfig } from 'vite';
import solid from 'vite-plugin-solid';
import packageJson from './package.json';
import tsconfigPaths from 'vite-tsconfig-paths/dist';

export default defineConfig({
  test: {
    environment: 'jsdom',
    transformMode: {
      web: [/.[jt]sx?/],
    },
    deps: {
      registerNodeLoader: true,
    },
    threads: false,
    isolate: false,
  },
  plugins: [solid(), tsconfigPaths()],
  resolve: {
    conditions: ['development', 'browser'],
  },
  build: {
    target: 'esnext',
  },
  define: {
    __VERSION_NUMBER__: `"${packageJson.version}"`,
  }
});
svobik7 commented 1 year ago

I am facing the same issue. I am developing standalone library and found out that this error appears only when I define "exports" in my package.json.

svobik7 commented 1 year ago

I had to drop the plugin at all and manually set the alias in vitest.config.js. In my case it was:

// tsconfig.json
{
  // …
  "paths": {
    "~/**: ["src/*"]
  }
}
// vitest.config.js
export default defineConfig({
  test: {
    alias: {
      "~: path.join(process.cwd(), “/src”)
    }
  }
})
aleclarson commented 1 year ago

@quantuminformation You should import vite-tsconfig-paths instead of vite-tsconfig-paths/dist.

@svobik7 Your issue seems different. Please open another issue when you can.