Skip to content

Commit

Permalink
general idea
Browse files Browse the repository at this point in the history
  • Loading branch information
jacoobes committed Jan 4, 2024
1 parent ad5aa80 commit 18a420a
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 2 deletions.
7 changes: 6 additions & 1 deletion src/core/ioc/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import { Result } from 'ts-results-es';
import { DefaultServices } from '../_internal';
import { AnyFunction } from '../../types/utility';
import type { Logging } from '../contracts/logging';
import { requir } from '../module-loading';

//SIDE EFFECT: GLOBAL DI
let containerSubject: CoreContainer<Partial<Dependencies>>;

Expand Down Expand Up @@ -107,9 +109,12 @@ export async function makeDependencies<const T extends Dependencies>
// well damn i have to go sorry, rip okay dsoo you want me to commit?
//push draft pr okok
const validIncludes = '@sern/localizer';
if(included.includes(validIncludes)) {

if(included.includes(validIncludes)) {
//Would be preferred if we can get away without awaiting
containerSubject.add({ '@sern/localizer': requir('shrimple-locales') });
}

containerSubject.ready();
} else {
composeRoot(containerSubject, conf);
Expand Down
4 changes: 4 additions & 0 deletions src/core/ioc/dependency-injection.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import type { CoreDependencies, DependencyConfiguration, IntoDependencies } from '../../types/ioc';
import { requir } from '../module-loading';
import { insertLogger, useContainerRaw } from './base';
import { CoreContainer } from './container';

Expand Down Expand Up @@ -61,6 +62,9 @@ export function composeRoot(
if (!hasLogger) {
insertLogger(container);
}
if(conf.include?.includes('@sern/localizer')) {
container.add({ '@sern/localizer': requir('shrimple-locales') });
}
//Build the container based on the callback provided by the user
conf.build(container as CoreContainer<Omit<CoreDependencies, '@sern/client'>>);

Expand Down
2 changes: 1 addition & 1 deletion src/core/module-loading.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ async function* readPaths(dir: string): AsyncGenerator<string> {
}
}

const requir = createRequire(import.meta.url);
export const requir = createRequire(import.meta.url);

export function loadConfig(wrapper: Wrapper | 'file'): Wrapper {
if (wrapper !== 'file') {
Expand Down

0 comments on commit 18a420a

Please sign in to comment.