-
Notifications
You must be signed in to change notification settings - Fork 8
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
Plugin Config #61
Comments
Hey!
When using this glob pattern, you're actually telling this plugin that all three files ( What you're probably looking to achieve here is to solely set the Using the following config should get you on the right track: targets: [
{
glob: 'src/utils/index.ts',
}
], Please let me know :) |
That being said, while my above suggestion is likely to help in your scenario, this shouldn't fail like that and the original (aka non-cleaned-up) version of |
Hi @Dschungelabenteuer, |
Here's a simple example using the information you provided! Hopefully this helps spot any difference between both your scenario and my repro attempt? EDIT:
Also, just for the record, if you're having that error after specifically setting |
@Dschungelabenteuer, no, I don't have any other config options except But, I've found the reason why it doesn't work. There is only one difference between my code and your example. Is there an option to config the |
Unfortunately it 100% relies on Vite's own resolvers: they do all the path resolution work and this plugin never actually interacts with the |
Here is our {
"compilerOptions": {
"baseUrl": "./src",
"target": "ES2020",
"useDefineForClassFields": true,
"lib": ["ES2023", "DOM", "DOM.Iterable"],
"module": "ESNext",
"skipLibCheck": true,
/* Bundler mode */
"moduleResolution": "bundler",
"allowImportingTsExtensions": false, // disallow file extensions in imports
"allowSyntheticDefaultImports": true,
"isolatedModules": true,
"moduleDetection": "force",
"noEmit": true,
"jsx": "react-jsx",
"incremental": true,
/* Linting */
"strict": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"noFallthroughCasesInSwitch": true,
"useUnknownInCatchVariables": true,
"verbatimModuleSyntax": true // require `type` keyword for imports
},
"include": ["src"],
"exclude": ["dist", "node_modules", "public"],
} |
I solved the issue above by adding an alias: resolve: {
alias: {
utils: '/src/utils',
hooks: '/src/hooks',
// .....
},
}, But next we have more difficult structure with components:
And, it's imported with I tried the glob pattern with wildcard |
Hey! I'm sorry I couldn't look into it further last week. I've been trying to reproduce the issue for while now and didn't get any result. Are you using by any chance some metaframework? Would it be possible for you to set up a simple repro? |
Hi @Dschungelabenteuer, Unfortunately, I couldn't make your plugin to work on our structure. So, I've used your code as an example to write my own simple vite plugin. It works as expected and reduces the amount of loaded files from ~790 to ~360. |
Hi Alexander! I'm sorry you couldn't make it work out-of-the-box, but I'm glad you came up with a working solution and that this plugin still helped a little bit in some way :) Also, thank you for still taking the time to set up that repro, much appreciated! 🙏 I'll definitely dig into it soon! |
What does the bug relate to?
Describe the bug
Hi there,
I have the following files in the project in
./src/utils
:Then it's imported with
import {util1} from 'utils';
in other files.I've tried this config -
But I got an error
Uncaught SyntaxError: The requested module '/src/utils/index.ts' does not provide an export named 'util1'
. And it really doesn't provideutil1
because index.ts is empty.To Reproduce
What am I doing wrong? Is it possible to use this plugin on my file/import/export file structure?
Vite version
5.4.11
Additional context
No response
The text was updated successfully, but these errors were encountered: