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 aliasing require calls #1910

Closed
4 tasks done
sheremet-va opened this issue Aug 24, 2022 · 0 comments · Fixed by #5618
Closed
4 tasks done

Allow aliasing require calls #1910

sheremet-va opened this issue Aug 24, 2022 · 0 comments · Fixed by #5618
Labels
p2-to-be-discussed Enhancement under consideration (priority)

Comments

@sheremet-va
Copy link
Member

sheremet-va commented Aug 24, 2022

Clear and concise description of the problem

Currently alias option works in several situations:

  • Inside source code
  • For import calls, if module is inlined, using deps.inline
  • For import calls, if registerNodeLoader is enabled

Unfortunately there is no way to make it work for require calls inside source code or external libraries code. This might be useful for aliasing react with preact, for example.

Suggested solution

Use Module to allow aliasing require calls. Example: https://github.com/ilearnio/module-alias/blob/dev/index.js

We cannot reuse resolveId function from Vite for this, because it is asynchronous. We should only use resolve.alias and test.alias for this, not resolveId hook of plugins.

Alternative

No response

Additional context

No response

Validations

@sheremet-va sheremet-va added the enhancement New feature or request label Aug 24, 2022
@sheremet-va sheremet-va added p2-to-be-discussed Enhancement under consideration (priority) and removed enhancement New feature or request labels Feb 16, 2024
@github-actions github-actions bot locked and limited conversation to collaborators May 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
p2-to-be-discussed Enhancement under consideration (priority)
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant