Comments (6)
Yeah of course, I'd like to have this feature supported.
from sveltekit-autoimport.
I'm aware of mapping
in the autoImport
config.
However it asks me to add properties whenever there is a new javascript function I want to expose in my components. This, to me, defeats the purpose a little bit.
I would want sveltekit-autoimport
to automatically expose functionality added within specified directories.
from sveltekit-autoimport.
Good proposal!
Though It might be a little complex to parse each js
or ts
file to get export names.
from sveltekit-autoimport.
I'm aware of
mapping
in theautoImport
config.However it asks me to add properties whenever there is a new javascript function I want to expose in my components. This, to me, defeats the purpose a little bit.
I would want
sveltekit-autoimport
to automatically expose functionality added within specified directories.
The inconvenience is sort of by design. JS files tend to have multiple exports and may be used for unit tests only. It's way more harder to exclude than to include the function you actually need.
from sveltekit-autoimport.
Yea so I don't know how Nuxt3 does it: but they aren't optimistically importing everything preemptively: only what is being used ends up being imported in the final build.
I guess their composibles
-directory-solution is a way to reduce complexity for the parser (knowing where to look), but as you say: the hard / expensive part isn't knowing where to look but to actually scan files for types of exports.
But then again: if we go through the trouble of auto importing svelte components: wouldn't it make sense to take the feature all the way? :)
from sveltekit-autoimport.
Nuxt3 use a package called unplugin-auto-import for composables, if we can make sveltekit-autoimport use unplugin-auto-import that will decrease the time of build something like that from scratch, in case if we couldn't do that we can still use both of the package separately, working eg.
import adapter from '@sveltejs/adapter-auto';
import preprocess from 'svelte-preprocess';
import AutoImport from 'unplugin-auto-import/vite';
import autoImport from 'sveltekit-autoimport';
/** @type {import('@sveltejs/kit').Config} */
const config = {
// Consult https://github.com/sveltejs/svelte-preprocess
// for more information about preprocessors
preprocess: preprocess(),
kit: {
adapter: adapter(),
vite: {
plugins: [
AutoImport({
dts: './src/auto-imports.d.ts',
imports: ['svelte', 'svelte/store', 'svelte/transition'],
dirs: ['./src/lib']
}),
autoImport({
components: [{ name: './src/components'}]
})
]
}
}
};
export default config;
from sveltekit-autoimport.
Related Issues (20)
- How to auto-import from component library in node_modules? HOT 10
- Should it better be called "sveltekit-autoimport"?
- Import Fails with SCSS nesting HOT 6
- TS let statement breaking import HOT 3
- Broken for sveltekit version >= 1.0.0-next.346
- Doesn't auto-import for svelte auto-subscriptions
- Doesn't auto-import for Object indented Components
- Support for auto-import inside <script context="module">
- Error: Failed to parse source for import analysis because the content contains invalid JS syntax. HOT 5
- Make it compatible with SK version >= 1.0.0-next.359 HOT 2
- Sveltekit: missing-declaration HOT 6
- VSCode support HOT 8
- Typescript Support
- Error with auto-import and mdsvex Layout component.
- Is it possible to auto import 'svelte/transition'? HOT 6
- How can I make this work with MDsveX? HOT 34
- Nested Components HOT 2
- Import Broken When lang="ts HOT 9
- Importing '$app/stores' : ['page'] brings about crbug HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from sveltekit-autoimport.