fixed dynamic loader bug
This commit is contained in:
@ -3,12 +3,8 @@ import componentNames from 'virtual:components-list';
|
||||
const components = {};
|
||||
|
||||
componentNames.forEach(path => {
|
||||
// Ensure imports start with ./ or ../ and end with a file extension
|
||||
const name = path.split('/').pop(); // Extract just the file name from the path
|
||||
const componentPath = `../components/${path}.svelte`; // Update the path as per your file structure
|
||||
|
||||
// Suppress warning for dynamic import
|
||||
components[name] = () => import(/* @vite-ignore */ componentPath);
|
||||
const name = path.split('/').pop(); // Extract just the file name from the path
|
||||
components[name] = () => import( /* @vite-ignore */ `/src/lib/components/${path}.svelte`);
|
||||
});
|
||||
|
||||
export default components;
|
||||
export default components;
|
@ -7,10 +7,10 @@ export const dataStore = writable({});
|
||||
|
||||
// Dynamically import the data modules and assign them to the store
|
||||
dataSources.forEach(src => {
|
||||
import(/* @vite-ignore */ `../data/${src}.ts`).then(module => {
|
||||
import(`/src/lib/data/${src}.ts`).then(module => {
|
||||
// Here, explicitly extract the required data or function from the module
|
||||
const moduleData = module[src] || module.default;
|
||||
|
||||
dataStore.update(store => ({ ...store, [src]: moduleData }));
|
||||
});
|
||||
});
|
||||
});
|
@ -1,11 +1,10 @@
|
||||
// servicesLoader.ts
|
||||
import serviceNames from 'virtual:services-list';
|
||||
|
||||
const services: { [key: string]: Function } = {};
|
||||
|
||||
serviceNames.forEach(path => {
|
||||
const serviceName = path.split('/').pop().replace('.ts', '');
|
||||
services[serviceName] = () => import(/* @vite-ignore */ `../services/${path}.ts`)
|
||||
services[serviceName] = () => import(/* @vite-ignore */ `/src/lib/services/${path}`)
|
||||
.then(mod => {
|
||||
console.log(`Loaded service ${serviceName} with the following properties:`, Object.keys(mod));
|
||||
if (mod.default) return mod.default;
|
||||
@ -13,4 +12,4 @@ serviceNames.forEach(path => {
|
||||
});
|
||||
});
|
||||
|
||||
export default services;
|
||||
export default services;
|
Reference in New Issue
Block a user