aleclarson / vite-tsconfig-paths

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

Couldnot correct load `ESM` module NodeNext with '.js' endfix. #70

Closed tianyingchun closed 1 year ago

tianyingchun commented 1 year ago
"compilerOptions": {
  "esModuleInterop": true,
    "module": "NodeNext",
    "target": "ESNext",
    "moduleResolution": "NodeNext",
    "baseUrl": "./src",
    "noImplicitAny": false,
    "allowJs": false,
    "noEmit": false,
    "incremental": true,
    "paths": {
      "@/test-utils": ["./test-utils/index.js"],
      "@/test-utils/*": ["./test-utils/*"],

import { runCliMock } from '@/test-utils/cli-run-mock.js';

it will throw Error: [vite-node] Failed to load @/test-utils/cli-run-mock.js

if use import { runCliMock } from '@/test-utils/cli-run-mock without .js endfix it works

but in type:module nodeNext we must always using .js

aleclarson commented 1 year ago

Duplicate of #54