-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
[Bug] Absolute imports with React CRA #782
Comments
What did you do by "try to use an absolute import"? Maybe you can write a repro in your issue: https://next.yarnpkg.com/advanced/sherlock ```js repro
const {promises: {writeFile}} = require(`fs`);
await yarn(`dlx`, `create-react-app`)
await writeFile("jsconfig.json", `
{
"compilerOptions": {
"baseUrl": "src/"
}
}
`)
await writeFile("src/App.jsx", `
// demo your "absolute imports"
`)
await expect(yarn(`build`)).rejects.not.toThrow(
/Module not found/
);
``` |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
I think it's worth to try
|
This comment has been minimized.
This comment has been minimized.
2 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
await yarn(`dlx`, `create-react-app`, `test`)
process.chdir(path.resolve(process.cwd(), 'test')); (ref: #689 (comment)) |
Would be nice to have a Sherlock playground ... not sure how to do that though 🤔 |
I'm really struggling with this sherlock thing here. A playground would be nice. Probably a more detailed documentation could also help. |
This comment has been minimized.
This comment has been minimized.
Note that you can work on the repro locally - it's a bit faster to iterate: |
This issue reproduces on master:
|
off-topic?: What about something like this CodeSandbox template? |
I just ran into this issue with one of my projects and see this is closed now. Was there a solution found? |
There was no valid reproduction (the last one published was bogus), so hard to say. Open a new issue with a repro if needed. |
Ok, referencing facebook/create-react-app#7996 and https://next.yarnpkg.com/advanced/migration#dont-use-resolvealiasmodules-webpack-or-modulenamemapper-jest for anyone else stumbling here in the meantime |
Describe the bug
Absolute imports doesn't work in CRA.
import App from 'folder-in-src/App'
To Reproduce
npx create-react-app test
add a jsconfig.json
try to use an absolute import (supported in CRA + works fine in yarn1)
import App from 'folder-in-src/App'
You get
Works fine with yarn 1
The text was updated successfully, but these errors were encountered: