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

feat: optimize import preprocessor #18

Merged
merged 8 commits into from
Dec 28, 2023
Merged

feat: optimize import preprocessor #18

merged 8 commits into from
Dec 28, 2023

Conversation

haruaki07
Copy link
Owner

This PR add a preprocessor to replace import icons with named export into default export. This processor will only match named import statements using a simple RegEx.

In short, importing icons like this:

<script>
  import { Cube, Heart, Horse } from "phosphor-svelte"
</script>

will be replaced into this:

<script>
  import Cube from "phosphor-svelte/lib/Cube"
  import Heart from "phosphor-svelte/lib/Heart"
  import Horse from "phosphor-svelte/lib/Horse"
</script>

Type Import & Alias

The processor also handles type imports (separated) and import alias, for example:

<script>
  import { Cube as IconCube, type IconContextProps } from "phosphor-svelte"
</script>

will be replaced into this:

<script>
  import IconCube from "phosphor-svelte/lib/Cube";
  import type { IconContextProps } from "phosphor-svelte";
</script>

@haruaki07 haruaki07 merged commit b6b3f32 into main Dec 28, 2023
1 check passed
@haruaki07 haruaki07 deleted the feat/preprocessor branch December 28, 2023 10:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant