Skip to content

Commit e7398f7

Browse files
author
Ives van Hoorne
committed
Fix type error
1 parent 322ea09 commit e7398f7

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed

packages/react-sandpack/src/components/OpenInCodeSandbox/OpenInCodeSandbox.tsx

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ import SandpackConsumer from '../SandpackConsumer';
66

77
export default class OpenInCodeSandbox extends React.Component {
88
getFileParameters = (files: IFiles) => {
9-
const normalized = Object.keys(files).reduce(
9+
const normalized: {
10+
[path: string]: { content: string; isBinary: boolean };
11+
} = Object.keys(files).reduce(
1012
(prev, next) => ({
1113
...prev,
1214
[next.replace('/', '')]: {

packages/sandpack/src/manager/index.ts

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,13 +134,27 @@ export default class PreviewManager {
134134

135135
const packageJSON = JSON.parse(files['/package.json'].code);
136136

137+
// TODO move this to a common format
138+
const normalizedModules = Object.keys(files).reduce(
139+
(prev, next) => ({
140+
...prev,
141+
[next]: {
142+
content: files[next].code,
143+
path: next,
144+
},
145+
}),
146+
{}
147+
);
148+
137149
dispatch({
138150
type: 'compile',
139151
codesandbox: true,
140152
version: 3,
141153
modules,
142154
externalResources: [],
143-
template: this.sandboxInfo.template || getTemplate(packageJSON, files),
155+
template:
156+
this.sandboxInfo.template ||
157+
getTemplate(packageJSON, normalizedModules),
144158
showOpenInCodeSandbox: true,
145159
skipEval: this.skipEval,
146160
});

0 commit comments

Comments
 (0)