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

Allow non-relative imports starting with src/ or vendor/ #825

Merged
merged 7 commits into from
Jan 22, 2025

Conversation

fredrikekelund
Copy link
Contributor

@fredrikekelund fredrikekelund commented Jan 21, 2025

Related issues

Proposed Changes

There's currently no way to use absolute import paths in Studio. This PR changes that by updating the Typescript, ESLint and Webpack configs to allow import paths starting with src/ or vendor/.

This enables us to use a similar approach as Calypso, where import paths can start with calypso/.

This was something I set up while working on #826. That PR introduces a new folder—src/stores—and I figured having a consistent import path for it would be nice.

Testing Instructions

  1. Restart your editor after running npm install
  2. Pick a file and change the import paths to be absolute
  3. Ensure that the editor doesn't complain and that npm start works as expected

Pre-merge Checklist

  • Have you checked for TypeScript, React or other console errors?

@fredrikekelund fredrikekelund requested a review from a team January 21, 2025 11:25
@fredrikekelund fredrikekelund self-assigned this Jan 21, 2025
Copy link
Contributor

@wojtekn wojtekn left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change looks correct, and works as expected. IDE allows for both type of paths.

Also, it shows where path could be shortened e.g.:

Screenshot 2025-01-21 at 16 54 42

Thanks for that improvement!

@fredrikekelund fredrikekelund merged commit 9970144 into trunk Jan 22, 2025
6 checks passed
@fredrikekelund fredrikekelund deleted the f26d/absolute-imports branch January 22, 2025 09:05
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 this pull request may close these issues.

2 participants