Code Monkey home page Code Monkey logo

Comments (8)

metonym avatar metonym commented on June 18, 2024

I don't think 'carbon-icons-svelte/Home16' is a valid import.

The JS import path should be "carbon-icons-svelte/lib/Home16".

from carbon-preprocess-svelte.

Perturbatio avatar Perturbatio commented on June 18, 2024

Just a typo, I manually typed this up. Updated my comment

from carbon-preprocess-svelte.

metonym avatar metonym commented on June 18, 2024

you get the same problem that would occur when not using optimizeImports in your preprocess section

Are you using optimizeImports? It should automatically optimize imports from carbon-components-svelte, carbon-icons-svelte, and carbon-pictograms-svelte.

from carbon-preprocess-svelte.

Perturbatio avatar Perturbatio commented on June 18, 2024

Yep, I'm using optimizeImports.

	preprocess: [
		sveltePreprocess({
			scss: {
				includePaths: ['src']
			},
			postcss: {
				plugins: [autoprefixer]
			}
		}),
		optimizeImports()
	]

The issue is I think that this isn't invoked when it's not parsing svelte files directly, I have a svelte file that references a store, the store references a service which will build a nav based on the current user and some other state related things.

Importing an icon in a .svelte file works fine, importing via the service causes extreme lag (unless I manually change the import to the full path)

With a brief look at the source, optimizeImports uses svelte's createPreprocessorFromVitePlugin to create a Preprocessor specifically for the svelte compiler. I think what I need is something that does the equivalent for TS / JS files.

from carbon-preprocess-svelte.

metonym avatar metonym commented on June 18, 2024

With a brief look at the source, optimizeImports uses svelte's createPreprocessorFromVitePlugin

Could you clarify this?

from carbon-preprocess-svelte.

Perturbatio avatar Perturbatio commented on June 18, 2024

Looking at /node_modules/carbon-preprocess-svelte/dist/index.js@22895 optimizeImports returns the result of the call to script

I assumed (probably incorrectly now that I look closer) that it used the script prop from createVitePreprocessorGroup, I am not overly familiar with the code so am most likely making bad assumptions.

In fact, I'm now assuming that's declaring a script method for the returned object which gets invoked by svelte's compiler at some point.

from carbon-preprocess-svelte.

metonym avatar metonym commented on June 18, 2024

In fact, I'm now assuming that's declaring a script method for the returned object which gets invoked by svelte's compiler at some point.

This is the correct assumption.

The optimizeImports will preprocess script blocks: https://github.com/carbon-design-system/carbon-preprocess-svelte/blob/main/src/preprocessors/optimize-imports.ts#L13

from carbon-preprocess-svelte.

Perturbatio avatar Perturbatio commented on June 18, 2024

Ok, in which case, what I need is a way to do the same for script files

from carbon-preprocess-svelte.

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.