Skip to content

Commit 5808200

Browse files
committed
temp fix for dynamic import vars
1 parent b2b518e commit 5808200

File tree

1 file changed

+33
-17
lines changed

1 file changed

+33
-17
lines changed

packages/adders/index.ts

Lines changed: 33 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,37 @@
1-
import type { AdderConfig, AdderWithoutExplicitArgs, Question } from '@svelte-cli/core';
2-
1+
// Rolldown doesn't support dynamic import vars yet.
32
export async function getAdderDetails(name: string) {
4-
const adder: { default: AdderWithoutExplicitArgs } = await import(`./${name}/index.ts`);
3+
let adder;
4+
switch (name) {
5+
case 'drizzle':
6+
adder = await import('./drizzle/index');
7+
break;
8+
case 'eslint':
9+
adder = await import('./eslint/index');
10+
break;
11+
case 'mdsvex':
12+
adder = await import('./mdsvex/index');
13+
break;
14+
case 'playwright':
15+
adder = await import('./playwright/index');
16+
break;
17+
case 'prettier':
18+
adder = await import('./prettier/index');
19+
break;
20+
case 'routify':
21+
adder = await import('./routify/index');
22+
break;
23+
case 'storybook':
24+
adder = await import('./storybook/index');
25+
break;
26+
case 'tailwindcss':
27+
adder = await import('./tailwindcss/index');
28+
break;
29+
case 'vitest':
30+
adder = await import('./vitest/index');
31+
break;
32+
default:
33+
throw new Error(`invalid adder name: ${name}`);
34+
}
535

636
return adder.default;
737
}
8-
9-
export async function getAdderConfig(name: string) {
10-
// Mainly used by the website
11-
// Either vite / rollup or esbuild are not able to process the shebangs
12-
// present on the `index.js` file. That's why we directly import the configuration
13-
// for the website here, as this is the only important part.
14-
15-
const adder: Promise<{ adder: AdderConfig<Record<string, Question>> }> = await import(
16-
`./${name}/config/adder.ts`
17-
);
18-
const { adder: adderConfig } = await adder;
19-
20-
return adderConfig;
21-
}

0 commit comments

Comments
 (0)