Skip to content

Commit

Permalink
optional config
Browse files Browse the repository at this point in the history
  • Loading branch information
Andy Haynes committed Mar 28, 2024
1 parent eff7015 commit 1a0b1f4
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 11 deletions.
8 changes: 4 additions & 4 deletions packages/application/src/hooks/useCompiler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ export function useCompiler({
config,
localComponents,
}: {
config: WebEngineConfiguration;
config?: WebEngineConfiguration;
localComponents?: { [path: string]: BOSModule };
}) {
const [compiler, setCompiler] = useState<CompilerWorker | null>(null);
Expand All @@ -33,13 +33,13 @@ export function useCompiler({
compiler.postMessage({
action: 'init',
localComponents,
enableBlockHeightVersioning: config.flags?.enableBlockHeightVersioning,
enableBlockHeightVersioning: config?.flags?.enableBlockHeightVersioning,
});
}, [
compiler,
config.flags?.bosLoaderUrl,
localComponents,
config.flags?.enableBlockHeightVersioning,
config?.flags?.bosLoaderUrl,
config?.flags?.enableBlockHeightVersioning,
]);

return compiler;
Expand Down
7 changes: 3 additions & 4 deletions packages/application/src/hooks/useComponents.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ export function useComponents({
[components]
);

const hooks = { ...config.hooks } || {};
const { flags } = config;
const hooks = { ...config?.hooks } || {};

useEffect(() => {
setIsValidRootComponentPath(
Expand All @@ -55,7 +54,7 @@ export function useComponents({
}, [rootComponentPath]);

hooks.componentRendered = (componentId: string) => {
config.hooks?.componentRendered?.(componentId);
config?.hooks?.componentRendered?.(componentId);
setComponents((currentComponents) => ({
...currentComponents,
[componentId]: {
Expand Down Expand Up @@ -116,7 +115,7 @@ export function useComponents({
rootComponentSource,
error,
isValidRootComponentPath,
flags?.bosLoaderUrl,
config?.flags?.bosLoaderUrl,
]);

return {
Expand Down
2 changes: 1 addition & 1 deletion packages/application/src/hooks/useWebEngine.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export function useWebEngine({
addComponent,
compiler,
components,
debug: config.debug,
debug: config?.debug,
getComponentRenderCount,
hooks,
});
Expand Down
2 changes: 1 addition & 1 deletion packages/application/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ export interface CompilerWorker extends Omit<Worker, 'postMessage'> {
}

export interface UseWebEngineParams {
config: WebEngineConfiguration;
config?: WebEngineConfiguration;
rootComponentPath?: string;
}

Expand Down
2 changes: 1 addition & 1 deletion packages/compiler/src/import.ts
Original file line number Diff line number Diff line change
Expand Up @@ -308,7 +308,7 @@ export const buildContainerModuleImports = (

// set the Preact import maps
const preactImportPath = `https://esm.sh/stable/preact@${PREACT_VERSION}`;
const preactCompatPath = `${preactImportPath}/compat/X-YS9yZWFjdDpwcmVhY3QvY29tcGF0/es2022/compat.js`;
const preactCompatPath = `${preactImportPath}/X-YS9yZWFjdDpwcmVhY3QvY29tcGF0/es2022/compat.js`;
importedModules.set('preact', preactImportPath);
importedModules.set('react', preactCompatPath);
importedModules.set('react-dom', preactCompatPath);
Expand Down

0 comments on commit 1a0b1f4

Please sign in to comment.