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

Unresolving of absolute imports (typescript) #6286

Closed
3 tasks done
azinit opened this issue Nov 16, 2021 · 11 comments · Fixed by #6304
Closed
3 tasks done

Unresolving of absolute imports (typescript) #6286

azinit opened this issue Nov 16, 2021 · 11 comments · Fixed by #6304

Comments

@azinit
Copy link

azinit commented Nov 16, 2021

🐛 bug report

Preflight Checklist

  • I have read the Contributing Guidelines for this project.
  • I agree to follow the Code of Conduct that this project
    adheres to.
  • I have searched the issue tracker for an issue that matches the one I want
    to file, without success.

Description of the problem

At November 15 I had noticed, that my existing codesandbox projects had been crashed - because of unresolving of absolute imports

It's interesting that IDE autocomplete "sees" correct and actual imports by tsconfig, but at any time - build of project fails

Unfortunately, it is not reproducible locally and looks like yet one codesandbox bug :(

Error: Could not find dependency: 'pages' relative to '/src/App.tsx'

How has this issue affected you? What are you trying to accomplish?

I've tried:

  • To reproduce error on new React Typescript project (unfortunately I did)
  • To reproduce error on new Typescript project
  • To reproduce error locally
  • To reproduce on another browser (Firefox)
  • To fix error by import aliases (without success)
  • To refresh pages (many times)
  • To update tsconfig options
  • To reinstall different versions of Typescript
  • To search issue solution at codesandbox's issues (one, two)

Error: Could not find module in path: '~/pages' relative to '/src/App.tsx'

To Reproduce

  1. Create any TypeScript project
  2. Add baseUrl for absolute imports
    OR
    Add aliases for imports
  3. Get error of unresolved imports

As a simple example

Link to sandbox: link (optional)

Your Environment

Software Name/Version
Сodesandbox f89852e88
Browser Chrome 95.0.4638.69 (64 bit)
Operating System Windows 10
@rscheuermann
Copy link

➕ Also experiencing this issue! Thanks @azinit for raising it

@CompuIves
Copy link
Member

Thanks for reporting this! We're going to look into it!

@DeMoorJasper
Copy link
Member

Had no clue we supported this so forgot to support it in the new resolver, will implement this as part of the tsconfig and jsconfig support we were planning anyway

Related to #807

@azinit
Copy link
Author

azinit commented Nov 17, 2021

Had no clue we supported this so forgot to support it in the new resolver, will implement this as part of the tsconfig and jsconfig support we were planning anyway

It's strange because it worked correctly before (at least at October) 🤔

@DeMoorJasper
Copy link
Member

DeMoorJasper commented Nov 17, 2021

Had no clue we supported this so forgot to support it in the new resolver, will implement this as part of the tsconfig and jsconfig support we were planning anyway

It's strange because it worked correctly before (at least at October) 🤔

Yup, it's definitely a regression just forgot we supported it, so forgot to include it in the new resolver. Will implement this tomorrow, sorry about this

@omeraplak
Copy link

Had no clue we supported this so forgot to support it in the new resolver, will implement this as part of the tsconfig and jsconfig support we were planning anyway

It's strange because it worked correctly before (at least at October) 🤔

Yup, it's definitely a regression just forgot we supported it, so forgot to include it in the new resolver. Will implement this tomorrow, sorry about this

Our nearly 100 CodeSanboxes were corrupted. We are very happy to see that this will be fixed. 👍

@DeMoorJasper
Copy link
Member

Just merged the fix that re-implements this logic, feel free to let me know (tag me) if any related issues pop up again.

Again sorry about this bug

@yairEO
Copy link

yairEO commented Nov 30, 2021

Still happening

Also, downloading the out-of-the-box basic react project Codesandbox offers, and then running npm install locally, results in a very troubling error:

npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: react-scripts@4.0.0
npm ERR! Found: typescript@4.1.3
npm ERR! node_modules/typescript
npm ERR!   dev typescript@"4.1.3" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peerOptional typescript@"^3.2.1" from react-scripts@4.0.0
npm ERR! node_modules/react-scripts
npm ERR!   react-scripts@"4.0.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: typescript@3.9.10
npm ERR! node_modules/typescript
npm ERR!   peerOptional typescript@"^3.2.1" from react-scripts@4.0.0
npm ERR!   node_modules/react-scripts
npm ERR!     react-scripts@"4.0.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.

@DeMoorJasper
Copy link
Member

Still happening

Please add a way to reproduce this as the examples in here work

@yairEO
Copy link

yairEO commented Nov 30, 2021

@DeMoorJasper - for example, this used to work, and did not change for a long time

https://codesandbox.io/s/ppkid

If you download and run this project locally, it would work. only in codesandbox it does not :(

I have a large supply of such examples.

@DeMoorJasper
Copy link
Member

@yairEO Thanks, this is caused by our pre-packager not including the correct files, now that we support exports we sometimes use files that are not included in the pre-packaged bundle, which we should probably download from unpkg or jsdelivr but instead we error out...

We have a new version of the pre-packager planned, unfortunately that takes a bit of time so this won't be solved quickly, will log this internally and see if I can come up with a quicker fix sometime this week

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants