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

An alias '*': ['src/*'] and import '.' in node_modules resolves src/index.tsx unexpectedly #42

Closed
JounQin opened this issue Jun 21, 2022 · 10 comments · Fixed by #47
Closed
Labels
bug Something isn't working outdated released

Comments

@JounQin
Copy link

JounQin commented Jun 21, 2022

As title

More detail prettier/plugin-pug#398

@JounQin JounQin changed the title An alias '*': ['src/*'] and import '.' resolves src/index.tsx unexpectedly An alias '*': ['src/*'] and import '.' in node_modules resolves src/index.tsx unexpectedly Jun 21, 2022
@yi-ge
Copy link

yi-ge commented Jun 21, 2022

esm-loader support index in dir, but it didn't work

@JounQin
Copy link
Author

JounQin commented Jun 21, 2022

Maybe should report to https://github.com/esbuild-kit/esm-loader instead then?

cc @privatenumber

@privatenumber privatenumber added the bug Something isn't working label Jun 21, 2022
@privatenumber
Copy link
Owner

I tried reproducing this but no luck. Also don't know what command you ran to make tsx read from a prettier plugin.

Can you provide a minimal reproduction repository?

@JounQin
Copy link
Author

JounQin commented Jun 22, 2022

Also don't know what command you ran to make tsx read from a prettier plugin.

@privatenumber

I call prettier's API in a script scripts/run.ts:

import prettier from 'prettier'

await prettier.resolveConfig(process.cwd())

Then yarn tsx scripts/run.ts, make sure you have @prettier/plugin-pug installed.

@privatenumber
Copy link
Owner

Yup, works fine for me.

@JounQin
Copy link
Author

JounQin commented Jun 22, 2022

OK, I will try to create a reproduction then.

@JounQin
Copy link
Author

JounQin commented Jun 22, 2022

@privatenumber

https://github.com/JounQin/test/tree/tsx

run yarn && yarn api

$ tsx scripts/api
/Users/JounQin/Workspaces/GitHub/test/src/index.tsx:1
console.log(document)
            ^

ReferenceError: document is not defined
    at Object.<anonymous> (/Users/JounQin/Workspaces/GitHub/test/src/index.tsx:1:13)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.h (/Users/JounQin/Workspaces/GitHub/test/node_modules/@esbuild-kit/cjs-loader/dist/index.js:1:733)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/Users/JounQin/Workspaces/GitHub/test/node_modules/@prettier/plugin-pug/src/options/common.ts:2:1)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Object.h (/Users/JounQin/Workspaces/GitHub/test/node_modules/@esbuild-kit/cjs-loader/dist/index.js:1:733)
error Command failed with exit code 1.

@privatenumber
Copy link
Owner

I'll leave this open till I add a test to prevent this, but should be fixed via https://github.com/privatenumber/get-tsconfig/releases/tag/v4.0.5

Run npm update or reinstall tsx.

@JounQin
Copy link
Author

JounQin commented Jun 22, 2022

@privatenumber Thanks, it's working as expected now.

@privatenumber
Copy link
Owner

🎉 This issue has been resolved in version 3.5.1 🎉

The release is available on:

Your semantic-release bot 📦🚀

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Dec 18, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Something isn't working outdated released
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants