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 aliases in node_modules to be processed by vite plugins #16606

Closed
4 tasks done
maitlandmarshall opened this issue May 6, 2024 · 3 comments
Closed
4 tasks done

Comments

@maitlandmarshall
Copy link

Description

I'm developing a framework where a file is generated at runtime called "data-models.ts". I have aliases to data-models.ts via "#data-models". Because the files which reference "#data-models" are within the node_modules directory when packaged, vite will not process these files to replace the alias.

Suggested solution

Allow vite to process specific files within node_modules with plugins.

Alternative

No response

Additional context

No response

Validations

@elias-pap
Copy link

Might be related: #16512

@hi-ogawa
Copy link
Collaborator

hi-ogawa commented May 7, 2024

@maitlandmarshall Can you provide an example project to show the alias issue? From a quick guess, it might be due to deps optimization and you might need to do optimizeDeps.exclude: ["your-package-which-uses-alias"].

@maitlandmarshall
Copy link
Author

maitlandmarshall commented May 8, 2024

@hi-ogawa thank you, that led me in the right direction to resolve my problem. I had to do this:

// Exclude @webui/lib from optimizeDeps so that the #data-models alias may be resolved
optimizeDeps: {
    exclude: ["@webui/lib"],
    include: ["@webui/lib > lodash", "@webui/lib > numeral", "@webui/lib > guid-typescript"]
},

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

No branches or pull requests

3 participants