Skip to content

Commit a74f625

Browse files
author
Ives van Hoorne
committed
Fix transpile queue getting ahead of itself
1 parent e6abfd6 commit a74f625

File tree

3 files changed

+50
-48
lines changed

3 files changed

+50
-48
lines changed

src/sandbox/eval/presets/index.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,12 @@ import type { Module } from 'common/types';
55
import Transpiler from '../transpilers';
66

77
export type TranspiledModule = Module & {
8-
transpiledCode: string,
8+
transpiledCode: string
99
};
1010

1111
type TranspilerDefinition = {
1212
transpiler: Transpiler,
13-
config?: Object,
13+
options: ?Object
1414
};
1515

1616
/**
@@ -27,7 +27,7 @@ type TranspilerDefinition = {
2727
export default class Preset {
2828
loaders: Array<{
2929
test: (module: Module) => boolean,
30-
transpilers: Array<TranspilerDefinition>,
30+
transpilers: Array<TranspilerDefinition>
3131
}>;
3232
transpilers: Set<Transpiler>;
3333
name: string;
@@ -37,7 +37,7 @@ export default class Preset {
3737
constructor(
3838
name: string,
3939
ignoredExtensions: ?Array<string>,
40-
alias: { [path: string]: string },
40+
alias: { [path: string]: string }
4141
) {
4242
this.loaders = [];
4343
this.transpilers = new Set();
@@ -57,7 +57,7 @@ export default class Preset {
5757
// Find matching aliases
5858
const matchingAliases = aliases.filter(a => path.startsWith(a));
5959
const orderedAliases = orderBy(matchingAliases, alias => alias.length, [
60-
'desc',
60+
'desc'
6161
]);
6262

6363
const foundAlias = orderedAliases[0];
@@ -72,11 +72,11 @@ export default class Preset {
7272

7373
registerTranspiler(
7474
test: (module: Module) => boolean,
75-
transpilers: Array<TranspilerDefinition>,
75+
transpilers: Array<TranspilerDefinition>
7676
) {
7777
this.loaders.push({
7878
test,
79-
transpilers,
79+
transpilers
8080
});
8181

8282
transpilers.forEach(t => this.transpilers.add(t.transpiler));
@@ -104,7 +104,7 @@ export default class Preset {
104104
const [name, options] = loaderName.split('?');
105105

106106
const transpiler = Array.from(this.transpilers).find(
107-
t => t.name === name,
107+
t => t.name === name
108108
);
109109

110110
if (!transpiler) {

src/sandbox/eval/transpiled-module.js

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
// @flow
2-
import type { Module } from 'common/types';
32
import { flattenDeep } from 'lodash';
3+
4+
import type { Module } from 'common/types';
45
import getModulePath from 'common/sandbox/get-module-path';
56

67
import type { SourceMap } from './transpilers/utils/get-source-map';
@@ -35,7 +36,7 @@ export type LoaderContext = {
3536
title: string,
3637
code: string,
3738
directoryShortid: ?string
38-
) => TranspiledModule,
39+
) => TranspiledModule, // eslint-disable-line no-use-before-define
3940
emitFile: (name: string, content: string, sourceMap: SourceMap) => void,
4041
options: {
4142
context: '/'
@@ -51,13 +52,13 @@ export type LoaderContext = {
5152
options: ?{
5253
isAbsolute: boolean
5354
}
54-
) => TranspiledModule,
55+
) => TranspiledModule, // eslint-disable-line no-use-before-define
5556
addDependenciesInDirectory: (
5657
depPath: string,
5758
options: {
5859
isAbsolute: boolean
5960
}
60-
) => Array<TranspiledModule>,
61+
) => Array<TranspiledModule>, // eslint-disable-line no-use-before-define
6162
_module: TranspiledModule // eslint-disable-line no-use-before-define
6263
};
6364

@@ -168,7 +169,7 @@ export default class TranspiledModule {
168169

169170
getLoaderContext(
170171
manager: Manager,
171-
transpilerOptions: Object = {}
172+
transpilerOptions: ?Object = {}
172173
): LoaderContext {
173174
const path = getModulePath(
174175
manager.getModules(),
@@ -329,6 +330,7 @@ export default class TranspiledModule {
329330
if (this.errors.length) {
330331
throw this.errors[0];
331332
}
333+
332334
code = transpiledCode;
333335
finalSourceMap = sourceMap;
334336
} catch (e) {
@@ -348,7 +350,8 @@ export default class TranspiledModule {
348350
code = `${code}\n//# sourceURL=${path}`;
349351

350352
this.source = new ModuleSource(this.module.title, code, finalSourceMap);
351-
await Promise.all(
353+
354+
return Promise.all(
352355
flattenDeep([
353356
...Array.from(this.transpilationInitiators).map(t =>
354357
t.transpile(manager)
@@ -357,8 +360,6 @@ export default class TranspiledModule {
357360
...this.childModules.map(t => t.transpile(manager))
358361
])
359362
);
360-
361-
return this;
362363
}
363364

364365
getChildTranspiledModules(): Array<TranspiledModule> {

src/sandbox/react-error-overlay/styles.js

Lines changed: 33 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ const iframeStyle = {
2424
width: '100%',
2525
height: '100%',
2626
border: 'none',
27-
'z-index': 2147483647 - 1, // below the compile error overlay
27+
'z-index': 2147483647 - 1 // below the compile error overlay
2828
};
2929

3030
const overlayStyle = {
@@ -40,7 +40,7 @@ const overlayStyle = {
4040
'text-rendering': 'optimizeLegibility',
4141
'font-smooth': 'always',
4242
'-webkit-tap-highlight-color': 'transparent',
43-
'-webkit-touch-callout': 'none',
43+
'-webkit-touch-callout': 'none'
4444
};
4545

4646
const containerStyle = {
@@ -60,16 +60,16 @@ const containerStyle = {
6060
'white-space': 'pre-wrap',
6161
'word-break': 'break-word',
6262
'line-height': 1.5,
63-
color: black,
63+
color: black
6464
};
6565

6666
const hintsStyle = {
67-
color: darkGray,
67+
color: darkGray
6868
};
6969

7070
const hintStyle = {
7171
padding: '0.5em 1em',
72-
cursor: 'pointer',
72+
cursor: 'pointer'
7373
};
7474

7575
const closeButtonStyle = {
@@ -80,11 +80,11 @@ const closeButtonStyle = {
8080
cursor: 'pointer',
8181
position: 'absolute',
8282
right: 0,
83-
top: 0,
83+
top: 0
8484
};
8585

8686
const additionalChildStyle = {
87-
'margin-bottom': '0.5rem',
87+
'margin-bottom': '0.5rem'
8888
};
8989

9090
const headerStyle = {
@@ -98,59 +98,60 @@ const headerStyle = {
9898
flex: '0 0 auto',
9999
'max-height': '50%',
100100
overflow: 'auto',
101-
'font-weight': '400',
101+
'font-weight': '400'
102102
};
103103

104104
const messageHeaderStyle = {
105105
...headerStyle,
106106
color: 'black',
107107
'font-weight': '300',
108-
'font-size': '1.75em',
108+
'font-size': '1.5em',
109+
'font-family': 'Consolas, Menlo, monospace',
109110
margin: 0,
110111
'padding-bottom': '1rem',
111-
'border-bottom': '1px solid #ddd',
112+
'border-bottom': '1px solid #ddd'
112113
};
113114

114115
const functionNameStyle = {};
115116

116117
const linkStyle = {
117118
'font-size': '0.9em',
118-
'margin-bottom': '0.9em',
119+
'margin-bottom': '0.9em'
119120
};
120121

121122
const anchorStyle = {
122123
'text-decoration': 'none',
123-
color: darkGray,
124+
color: darkGray
124125
};
125126

126127
const traceStyle = {
127128
'font-size': '1em',
128129
flex: '0 1 auto',
129130
'min-height': '0px',
130131
overflow: 'auto',
131-
'padding-top': '1rem',
132+
'padding-top': '1rem'
132133
};
133134

134135
const depStyle = {};
135136

136137
const primaryErrorStyle = {
137-
'background-color': lightRed,
138+
'background-color': lightRed
138139
};
139140

140141
const secondaryErrorStyle = {
141-
'background-color': yellow,
142+
'background-color': yellow
142143
};
143144

144145
const omittedFramesCollapsedStyle = {
145146
color: black,
146147
cursor: 'pointer',
147-
'margin-bottom': '1.5em',
148+
'margin-bottom': '1.5em'
148149
};
149150

150151
const omittedFramesExpandedStyle = {
151152
color: black,
152153
cursor: 'pointer',
153-
'margin-bottom': '0.6em',
154+
'margin-bottom': '0.6em'
154155
};
155156

156157
const _preStyle = {
@@ -160,31 +161,31 @@ const _preStyle = {
160161
'margin-bottom': '0.5em',
161162
'overflow-x': 'auto',
162163
'white-space': 'pre-wrap',
163-
'border-radius': '0.25rem',
164+
'border-radius': '0.25rem'
164165
};
165166
const primaryPreStyle = Object.assign({}, _preStyle, {
166-
'background-color': redTransparent,
167+
'background-color': redTransparent
167168
});
168169
const secondaryPreStyle = Object.assign({}, _preStyle, {
169-
'background-color': yellowTransparent,
170+
'background-color': yellowTransparent
170171
});
171172

172173
const toggleStyle = {
173174
'margin-bottom': '1.5em',
174175
color: darkGray,
175-
cursor: 'pointer',
176+
cursor: 'pointer'
176177
};
177178

178179
const codeStyle = {
179-
'font-family': 'Consolas, Menlo, monospace',
180+
'font-family': 'Consolas, Menlo, monospace'
180181
};
181182

182183
const hiddenStyle = {
183-
display: 'none',
184+
display: 'none'
184185
};
185186

186187
const groupStyle = {
187-
'margin-right': '1em',
188+
'margin-right': '1em'
188189
};
189190

190191
const _groupElemStyle = {
@@ -193,35 +194,35 @@ const _groupElemStyle = {
193194
border: 'none',
194195
'border-radius': '4px',
195196
padding: '3px 6px',
196-
cursor: 'pointer',
197+
cursor: 'pointer'
197198
};
198199

199200
const groupElemLeft = Object.assign({}, _groupElemStyle, {
200201
'border-top-right-radius': '0px',
201202
'border-bottom-right-radius': '0px',
202-
'margin-right': '1px',
203+
'margin-right': '1px'
203204
});
204205

205206
const groupElemRight = Object.assign({}, _groupElemStyle, {
206207
'border-top-left-radius': '0px',
207-
'border-bottom-left-radius': '0px',
208+
'border-bottom-left-radius': '0px'
208209
});
209210

210211
const footerStyle = {
211212
'font-family': 'sans-serif',
212213
color: darkGray,
213214
'margin-top': '0.5rem',
214-
flex: '0 0 auto',
215+
flex: '0 0 auto'
215216
};
216217

217218
const suggestionsContainerStyle = {
218219
'font-family': 'Roboto, sans-serif',
219-
'padding-top': '1rem',
220+
'padding-top': '1rem'
220221
};
221222

222223
const suggestionsTitleStyle = {
223224
'font-size': '1rem',
224-
'font-weight': '300',
225+
'font-weight': '300'
225226
};
226227

227228
const suggestionsButtonStyle = {
@@ -234,7 +235,7 @@ const suggestionsButtonStyle = {
234235
'font-size': '.75rem',
235236
'border-radius': '4px',
236237
border: '1px solid #6CAEDD',
237-
cursor: 'pointer',
238+
cursor: 'pointer'
238239
};
239240

240241
export {
@@ -267,5 +268,5 @@ export {
267268
footerStyle,
268269
suggestionsContainerStyle,
269270
suggestionsTitleStyle,
270-
suggestionsButtonStyle,
271+
suggestionsButtonStyle
271272
};

0 commit comments

Comments
 (0)