|
| 1 | +// Test TypeScript features that jiti should handle |
| 2 | +interface SharedConfig { |
| 3 | + singleton?: boolean; |
| 4 | + requiredVersion?: string; |
| 5 | + strictVersion?: boolean; |
| 6 | +} |
| 7 | + |
| 8 | +interface RemoteConfig { |
| 9 | + url: string; |
| 10 | + format?: 'esm' | 'var'; |
| 11 | +} |
| 12 | + |
| 13 | +enum ExposedModules { |
| 14 | + Button = './Button', |
| 15 | + Header = './Header', |
| 16 | + Footer = './Footer', |
| 17 | +} |
| 18 | + |
| 19 | +const sharedDependencies: Record<string, SharedConfig> = { |
| 20 | + react: { singleton: true, requiredVersion: '^18.0.0' }, |
| 21 | + 'react-dom': { singleton: true, requiredVersion: '^18.0.0' }, |
| 22 | + lodash: { singleton: false, strictVersion: true }, |
| 23 | +}; |
| 24 | + |
| 25 | +const remoteApps: Record<string, RemoteConfig> = { |
| 26 | + 'remote-app-1': { |
| 27 | + url: 'http://localhost:3001/remoteEntry.js', |
| 28 | + format: 'esm', |
| 29 | + }, |
| 30 | + 'remote-app-2': { |
| 31 | + url: 'http://localhost:3002/remoteEntry.js', |
| 32 | + format: 'var', |
| 33 | + }, |
| 34 | +}; |
| 35 | + |
| 36 | +export default { |
| 37 | + name: 'complex-mf-app', |
| 38 | + filename: 'remoteEntry.js', |
| 39 | + exposes: { |
| 40 | + [ExposedModules.Button]: './src/components/Button.tsx', |
| 41 | + [ExposedModules.Header]: './src/components/Header.tsx', |
| 42 | + [ExposedModules.Footer]: './src/components/Footer.tsx', |
| 43 | + }, |
| 44 | + shared: sharedDependencies, |
| 45 | + remotes: Object.entries(remoteApps).reduce( |
| 46 | + (acc, [name, config]) => { |
| 47 | + acc[name] = `${name}@${config.url}`; |
| 48 | + return acc; |
| 49 | + }, |
| 50 | + {} as Record<string, string>, |
| 51 | + ), |
| 52 | + // Test generic types |
| 53 | + sharedScope: createSharedScope<'default'>(), |
| 54 | +}; |
| 55 | + |
| 56 | +// Test generic function |
| 57 | +function createSharedScope<T extends string>(): T { |
| 58 | + return 'default' as T; |
| 59 | +} |
0 commit comments