cibernox / svelte-intl-precompile

I18n library for Svelte.js that analyzes your keys at build time for max performance and minimal footprint
https://svelte-intl-precompile.com
ISC License
274 stars 13 forks source link

Failed to resolve import "$locales/en.js" #35

Closed gzimbron closed 2 years ago

gzimbron commented 2 years ago

Hello, I'm following first steps configuration https://svelte-intl-precompile.com/es/docs/getting-started

but I'm getting this error from __layout.svelte

Failed to resolve import "$locales/en.js" from "src/routes/__layout.svelte". Does the file exist?
3  |  
4  |  import { init, waitLocale } from 'svelte-intl-precompile';
5  |  register('en', () => import('$locales/en.js'));
   |                              ^
6  |  register('es', () => import('$locales/es.js'));
7  | 

$locales path is not working..

Any other configuration to do ?

SOLVED: Added to config.kit.vite level instead config.vite level image

cibernox commented 2 years ago

Glad you found it so quick!

MordragT commented 1 year ago

I am getting the same error, but as svelte kit does not expose vite configuration anymore, i added the plugin to vite.config.ts:

import { sveltekit } from '@sveltejs/kit/vite';
import type { UserConfig } from 'vite';
import precompileIntl from "svelte-intl-precompile/sveltekit-plugin";

const config: UserConfig = {
    plugins: [
        precompileIntl("locales"),
        sveltekit()
    ]
};

export default config;

Specifically its says:

failed to load module for ssr: $locales/en Error: failed to load module for ssr: $locales/en

And I resolved it within one minute after writing here :D, sorry for the noise. I had the locales folder in the /src directory but it needs to be in root