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

Vite does not cache deps with resolved node_modules path #10

Open
brawaru opened this issue Apr 26, 2023 · 1 comment
Open

Vite does not cache deps with resolved node_modules path #10

brawaru opened this issue Apr 26, 2023 · 1 comment
Labels
type: bug Something isn't working

Comments

@brawaru
Copy link
Member

brawaru commented Apr 26, 2023

This makes it impossible to add dependency like @vintl/compact-number/locale-data/en, because it resolves to a full path, and then there are two modules: cached @vintl/compact-number and that locale data file, plus everything that it imports (including non-cached @vintl/compact-number)...

@brawaru brawaru changed the title Vite does not cache deps with resolved node path Vite does not cache deps with resolved node_modules path Apr 26, 2023
@brawaru brawaru added the type: bug Something isn't working label Apr 26, 2023
@brawaru
Copy link
Member Author

brawaru commented Apr 26, 2023

Relevant lines:

for (const importPath of locale.additionalImports ?? []) {
const resolvedPath = await resolve(importPath)
if (isDefaultLocale) {
// import "<import path>"
imports.push(new ImportDeclaration(new Literal(resolvedPath)))
} else {
// l.i(import("<import path>"))
importFunctionBody.body.push(
new ExpressionStatement(
new CallExpression(exp$addImport, [
webpackMagicImportAST(resolvedPath, { chunkName }),
]),
),
)
}
}

Maybe we can like accept an object (transform strings to objects) with properties from (string) and resolve (boolean)?

Otherwise I am not sure about the solution. Bailing the resolution if result contains node_modules sounds like a bad idea for whatever reason.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
type: bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant