opral / inlang-paraglide-js

Tree-shakable i18n library build on the inlang ecosystem.
https://inlang.com/m/gerre34r/library-inlang-paraglideJs
52 stars 1 forks source link

How to Import a Module Globally in SvelteKit #239

Closed kenzWeb closed 1 month ago

kenzWeb commented 1 month ago

Hello,

I'm working on a SvelteKit project and using a module frequently across multiple files, specifically messages.js from $lib/paraglide. Currently, I have to import it manually in each file like this:

import * as m from '$lib/paraglide/messages.js';

Is there a way to make this module available globally throughout the project, so I don't have to import it every time?

Any advice or recommended best practices would be greatly appreciated.

Thank you!

samuelstroschein commented 1 month ago

hi @kenzWeb,

i am unaware of a possibility to make modules global without breaking tree-shaking.

i also advice you against globals. the imports might be annoying but it works. global magic will likely introduce regressions bugs.

in terms of achieving global modules, check the vite docs https://vitest.dev/. paraglide js emits regular javascript code.


closing because not directly related to paraglide js