Urara-Blog/node_modules/.pnpm-store/v3/files/05/9ddf210fad34d224534455082e5646abee694c05d70f0b617a76d3aeefb2a44e686c77954d39cc8431def11ab974a56c3def8d6c27dc62a5d3755845d1982c
2022-08-14 01:14:53 +08:00

52 lines
1.2 KiB
Text

import { adapters } from './adapters.js';
/** @type {import('./index').default} */
let fn;
for (const candidate of adapters) {
if (candidate.test()) {
/** @type {{ default: () => import('@sveltejs/kit').Adapter }} */
let module;
try {
module = await import(candidate.module);
fn = () => {
const adapter = module.default();
return {
...adapter,
adapt: (builder) => {
builder.log.info(`Detected environment: ${candidate.name}. Using ${candidate.module}`);
return adapter.adapt(builder);
}
};
};
break;
} catch (error) {
if (
error.code === 'ERR_MODULE_NOT_FOUND' &&
error.message.startsWith(`Cannot find package '${candidate.module}'`)
) {
throw new Error(
`It looks like ${candidate.module} is not installed. Please install it and try building your project again.`
);
}
throw error;
}
}
}
if (!fn) {
fn = () => ({
name: '@sveltejs/adapter-auto',
adapt: (builder) => {
builder.log.warn(
'Could not detect a supported production environment. See https://kit.svelte.dev/docs/adapters to learn how to configure your app to run on the platform of your choosing'
);
}
});
}
export default fn;