Skip to content

Commit

Permalink
fix(sandpack-react): make entry field optional, as bundler relies on …
Browse files Browse the repository at this point in the history
…package.json (#660)
  • Loading branch information
danilowoz authored Dec 12, 2022
1 parent 035d1b9 commit 3d12b6e
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
6 changes: 3 additions & 3 deletions sandpack-client/src/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,8 @@ describe(normalizePath, () => {
});

it("doesn't tranform invalid values", () => {
expect(normalizePath(null)).toBe(undefined);
expect(normalizePath(undefined)).toBe(undefined);
expect(normalizePath(123)).toBe(undefined);
expect(normalizePath(undefined)).toBe(null);
expect(normalizePath(null)).toBe(null);
expect(normalizePath(123)).toBe(null);
});
});
2 changes: 1 addition & 1 deletion sandpack-client/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -202,5 +202,5 @@ export const normalizePath = <R extends any>(path: R): R => {
);
}

return undefined as R;
return null as R;
};
2 changes: 1 addition & 1 deletion sandpack-react/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -610,7 +610,7 @@ export interface SandboxTemplate {
files: Record<string, SandpackFile>;
dependencies: Record<string, string>;
devDependencies?: Record<string, string>;
entry: string;
entry?: string;
main: string;
environment: SandboxEnvironment;
}
Expand Down
4 changes: 2 additions & 2 deletions sandpack-react/src/utils/sandpackUtils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ export const getSandpackStateFromProps = (
}

// Make sure it resolves the entry file
if (!projectSetup.files[projectSetup.entry]) {
if (projectSetup.entry && !projectSetup.files[projectSetup.entry]) {
/* eslint-disable */
// @ts-ignore
projectSetup.entry = resolveFile(projectSetup.entry, projectSetup.files);
Expand Down Expand Up @@ -222,7 +222,7 @@ const combineTemplateFilesToSetup = ({
...baseTemplate.devDependencies,
...customSetup?.devDependencies,
},
entry: normalizePath(customSetup?.entry || baseTemplate.entry),
entry: normalizePath(customSetup?.entry),
main: baseTemplate.main,
environment: customSetup?.environment || baseTemplate.environment,
} as SandboxTemplate;
Expand Down

0 comments on commit 3d12b6e

Please sign in to comment.