Git Product home page Git Product logo

Comments (6)

yuanchuan avatar yuanchuan commented on June 15, 2024 1

Yeah of course, I'd like to have this feature supported.

from sveltekit-autoimport.

kkortes avatar kkortes commented on June 15, 2024

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.

yuanchuan avatar yuanchuan commented on June 15, 2024

Good proposal!

Though It might be a little complex to parse each js or ts file to get export names.

from sveltekit-autoimport.

yuanchuan avatar yuanchuan commented on June 15, 2024

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.

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.

kkortes avatar kkortes commented on June 15, 2024

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.

Mohamed-Kaizen avatar Mohamed-Kaizen commented on June 15, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.