diff --git a/assets/example/routes/+page.svelte b/assets/example/routes/+page.svelte
index 4730d9a..2f68f34 100644
--- a/assets/example/routes/+page.svelte
+++ b/assets/example/routes/+page.svelte
@@ -1,7 +1,11 @@
-
+
{$i18n('intro')}
diff --git a/package.json b/package.json
index e42aeed..cffc8c0 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "@vardario/svelte-i18next",
- "version": "0.1.12",
+ "version": "0.1.13",
"description": "",
"license": "MIT",
"author": "Sahin Vardar",
diff --git a/src/i18n-preprocessor.test.ts b/src/i18n-preprocessor.test.ts
index 3d5783c..afc5f2d 100644
--- a/src/i18n-preprocessor.test.ts
+++ b/src/i18n-preprocessor.test.ts
@@ -4,19 +4,24 @@ import * as compiler from 'svelte/compiler';
import { describe, expect, test } from 'vitest';
import { i18nProcessor } from './i18n-preprocessor.js';
import { __dirname } from './utils.js';
+//@ts-expect-error
+import { vitePreprocess } from '@sveltejs/kit/vite';
const examplePath = path.resolve(__dirname(import.meta), '../assets/example');
-const preprocessor = i18nProcessor({
- indent: {
- indent: '',
- lineEnd: ''
- }
-});
+const preprocessors = [
+ vitePreprocess(),
+ i18nProcessor({
+ indent: {
+ indent: '',
+ lineEnd: ''
+ }
+ })
+];
async function testComponent(filename: string, expectation: string) {
const componentPath = path.resolve(examplePath, filename);
const componentContent = (await fs.readFile(componentPath)).toString('utf-8');
- const preprocessed = await compiler.preprocess(componentContent, preprocessor, { filename });
+ const preprocessed = await compiler.preprocess(componentContent, preprocessors, { filename });
expect(preprocessed.code).toBe(expectation);
}
diff --git a/src/i18n-preprocessor.ts b/src/i18n-preprocessor.ts
index 206336c..13f0b31 100644
--- a/src/i18n-preprocessor.ts
+++ b/src/i18n-preprocessor.ts
@@ -129,7 +129,7 @@ export const i18nProcessor = (options?: I18nProcessorOptions): PreprocessorGroup
},
async script({ content, filename }) {
return preprocess(content, filename, async () => {
- const program = parse(content, { ecmaVersion: 'latest' }) as Node;
+ const program = parse(content, { ecmaVersion: 'latest', sourceType:'module' }) as Node;
const keyPath = extractKeyPathFromFile(filename!);
adjustI18nCall(program, keyPath, callIdentifier);
return { code: generate(program) };