Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Regression]: tsconfig.json's compilerOptions.paths no longer working in 1.47 #32480

Closed
mrmckeb opened this issue Sep 6, 2024 · 4 comments · Fixed by #32491
Closed

[Regression]: tsconfig.json's compilerOptions.paths no longer working in 1.47 #32480

mrmckeb opened this issue Sep 6, 2024 · 4 comments · Fixed by #32491
Labels

Comments

@mrmckeb
Copy link

mrmckeb commented Sep 6, 2024

Version

1.47.0

Steps to reproduce

  1. Add paths to tsconfig.json
    {
      "compilerOptions": {
        "paths": {
          "#/*": ["./src/*"]
        }
      }
    }
    
  2. Import something using that path, i.e. #/utils/my-util.

Expected behavior

This worked as expected in 1.46.

Actual behavior

Error:

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '#/utils/my-util' imported from <path>/tests/my-test.ts

Additional context

I assume this is related to the tsconfig option in 1.47, but didn't dig into the issue yet sorry.

Environment

System:
  OS: macOS 14.6.1
  CPU: (8) arm64 Apple M3
  Memory: 256.58 MB / 24.00 GB
Binaries:
  Node: 20.14.0 - ~/.local/state/fnm_multishells/35649_1725599073952/bin/node
  npm: 10.7.0 - ~/.local/state/fnm_multishells/35649_1725599073952/bin/npm
  pnpm: 9.9.0 - ~/.local/state/fnm_multishells/35649_1725599073952/bin/pnpm
IDEs:
  VSCode: 1.93.0 - /usr/local/bin/code
Languages:
  Bash: 3.2.57 - /bin/bash
@dgozman
Copy link
Contributor

dgozman commented Sep 6, 2024

@mrmckeb Could you please share a full repro? We need the project structure, package.json and tsconfig.json at least to make sure we understand your setup.

@nickdbush
Copy link

nickdbush commented Sep 6, 2024

It looks like importing /package/index as /package is causing the problem.

Here's a minimal reproduction: https://github.com/nickdbush/playwright-repro

@rkhomi
Copy link

rkhomi commented Sep 6, 2024

Error: Cannot find package '@src/modules' imported from /qa/Playwright/src/global/home.ts
same here

{
	"compilerOptions": {
		"outDir": "./dist",
		"target": "ES2022",
		"module": "esnext",
		"moduleResolution": "node",
		"esModuleInterop": true,
		"resolveJsonModule": true,
		"noUnusedParameters": true,
		"useDefineForClassFields": false,
		"types": ["node"],
		"noEmit": true,
		"allowJs": true,
		"baseUrl": "./",
		"paths": {
			"@src/*": ["src/*"],
			"@global/*": ["src/global/*"]
		}
	},
	"include": ["./src/**/*.ts", "./*.ts"]
}

@mxschmitt mxschmitt changed the title [Bug]: tsconfig.json's compilerOptions.paths no longer working in 1.47 [Regression]: tsconfig.json's compilerOptions.paths no longer working in 1.47 Sep 6, 2024
@mxschmitt mxschmitt added the v1.47 label Sep 6, 2024
dgozman added a commit that referenced this issue Sep 6, 2024
…ng `index.js` and `package.json` through path mapping (#32078)" (#32492)

This reverts commit effb1ae.

This broke path mapping into directories in ESM mode. References #32480.
@mrmckeb
Copy link
Author

mrmckeb commented Sep 7, 2024

Sorry I didn't supply a repro @dgozman - thanks @nickdbush for beating me to it!

@dgozman dgozman closed this as completed in ae11867 Sep 9, 2024
dgozman added a commit to dgozman/playwright that referenced this issue Sep 11, 2024
…pescript behaviour for resolving `index.js` and `package.json` through path mapping (microsoft#32078)"

This reverts commit effb1ae.

This broke path mapping into directories in ESM mode. References microsoft#32480.
dgozman added a commit that referenced this issue Sep 11, 2024
#32560)

…behaviour for resolving `index.js` and `package.json` through path
mapping (#32078)"

This reverts commit effb1ae.

This broke path mapping into directories in ESM mode. References #32480.
dgozman added a commit to dgozman/playwright that referenced this issue Sep 11, 2024
…ts with path mapping

We now hopefully align with `moduleResolution: bundler` tsconfig option,
allowing directory imports in every scenario, and allowing proper module
imports when not going through the type mapping.

This regressed in microsoft#32078. Fixes microsoft#32480, fixes microsoft#31811.
dgozman added a commit that referenced this issue Sep 12, 2024
…ath mapping (#32571)

We now hopefully align with `moduleResolution: bundler` tsconfig option,
allowing directory imports in every scenario, and allowing proper module
imports when not going through the type mapping.

This regressed in #32078. Fixes #32480, fixes #31811.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants