Skip to content

Commit e6e9c28

Browse files
authored
1 parent a80453d commit e6e9c28

File tree

12 files changed

+485
-7
lines changed

12 files changed

+485
-7
lines changed

packages/app/src/app/pages/Sandbox/Editor/Workspace/Files/DirectoryEntry/Entry/EntryIcons/elements.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import reactSvg from 'common/components/icons/react.svg';
77
import folderSvg from 'common/components/icons/folder.svg';
88
import folderOpenSvg from 'common/components/icons/folder-open.svg';
99
import jsonSvg from 'common/components/icons/json.svg';
10+
import reasonSvg from 'common/components/icons/reason.svg';
1011
import yarnSvg from 'common/components/icons/yarn.svg';
1112
import markdownSvg from 'common/components/icons/markdown.svg';
1213
import faviconSvg from 'common/components/icons/favicon.svg';
@@ -41,6 +42,7 @@ const icons = {
4142
codesandbox: codesandboxSvg,
4243
babel: babelSvg,
4344
sass: sassSvg,
45+
reason: reasonSvg,
4446
};
4547

4648
function getIconSvg(type) {

packages/app/src/app/utils/get-type.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ const htmlRegex = /\.html$/;
1313
const mdRegex = /\.md$/;
1414
const vueRegex = /\.vue$/;
1515
const svgRegex = /\.svg$/;
16+
const reasonRegex = /\.re$/;
1617

1718
export function getMode(title: string = '') {
1819
if (title === 'favicon.ico') {
@@ -46,6 +47,7 @@ export function getMode(title: string = '') {
4647
if (vueRegex.test(title)) return 'vue';
4748
if (svgRegex.test(title)) return 'svg';
4849
if (sassRegex.test(title)) return 'sass';
50+
if (reasonRegex.test(title)) return 'reason';
4951
if (!title.includes('.')) return 'raw';
5052

5153
if (isImage(title)) {

packages/app/src/sandbox/compile.js

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ function getDependencies(parsedPackage, templateDefinition, configurations) {
201201
devDependencies = {},
202202
} = parsedPackage;
203203

204-
const returnedDependencies = { ...peerDependencies, ...d };
204+
let returnedDependencies = { ...peerDependencies, ...d };
205205

206206
const foundWhitelistedDevDependencies = [...WHITELISTED_DEV_DEPENDENCIES];
207207

@@ -247,6 +247,13 @@ function getDependencies(parsedPackage, templateDefinition, configurations) {
247247
];
248248
}
249249

250+
if (templateDefinition.name === 'reason') {
251+
returnedDependencies = {
252+
...returnedDependencies,
253+
'@jaredly/bs-core': '3.0.0-alpha.2',
254+
};
255+
}
256+
250257
preinstalledDependencies.forEach(dep => {
251258
if (returnedDependencies[dep]) {
252259
delete returnedDependencies[dep];

packages/app/src/sandbox/eval/index.js

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ import {
1010
cxjs,
1111
babel,
1212
dojo,
13+
reason,
1314
} from 'common/templates';
1415

1516
import reactPreset from './presets/create-react-app';
@@ -21,6 +22,7 @@ import angularPreset from './presets/angular-cli';
2122
import parcelPreset from './presets/parcel';
2223
import babelPreset from './presets/babel-repl';
2324
import cxjsPreset from './presets/cxjs';
25+
import reasonPreset from './presets/reason';
2426
import dojoPreset from './presets/dojo';
2527

2628
export default function getPreset(template: string) {
@@ -29,6 +31,8 @@ export default function getPreset(template: string) {
2931
return reactPreset();
3032
case reactTs.name:
3133
return reactTsPreset();
34+
case reason.name:
35+
return reasonPreset();
3236
case vue.name:
3337
return vuePreset();
3438
case preact.name:
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
import Preset from '../';
2+
3+
import stylesTranspiler from '../../transpilers/style';
4+
import babelTranspiler from '../../transpilers/babel';
5+
import jsonTranspiler from '../../transpilers/json';
6+
import rawTranspiler from '../../transpilers/raw';
7+
import reasonTranspiler from '../../transpilers/reason';
8+
9+
import reasonRemap from './reason-remap';
10+
11+
export default function initialize() {
12+
const preset = new Preset(
13+
'reason',
14+
['web.js', 'js', 're', 'json', 'web.jsx', 'jsx'],
15+
reasonRemap,
16+
{ hasDotEnv: true }
17+
);
18+
19+
preset.registerTranspiler(module => /\.css$/.test(module.path), [
20+
{ transpiler: stylesTranspiler },
21+
]);
22+
23+
preset.registerTranspiler(module => /\.jsx?$/.test(module.path), [
24+
{ transpiler: babelTranspiler },
25+
]);
26+
27+
preset.registerTranspiler(module => /\.json$/.test(module.path), [
28+
{ transpiler: jsonTranspiler },
29+
]);
30+
31+
preset.registerTranspiler(module => /\.re$/.test(module.path), [
32+
{ transpiler: reasonTranspiler },
33+
{ transpiler: babelTranspiler, options: { simpleRequire: true } },
34+
]);
35+
36+
preset.registerTranspiler(() => true, [{ transpiler: rawTranspiler }]);
37+
38+
return preset;
39+
}
Lines changed: 180 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,180 @@
1+
module.exports = {
2+
'stdlib/reasonReact': '@jaredly/reason-react/lib/js/src/ReasonReact.js',
3+
'stdlib/reasonReactOptimizedCreateClass':
4+
'@jaredly/reason-react/lib/js/src/ReasonReactOptimizedCreateClass.js',
5+
'stdlib/reactEventRe': '@jaredly/reason-react/lib/js/src/ReactEventRe.js',
6+
'stdlib/reactDOMServerRe':
7+
'@jaredly/reason-react/lib/js/src/ReactDOMServerRe.js',
8+
'stdlib/reactDOMRe': '@jaredly/reason-react/lib/js/src/ReactDOMRe.js',
9+
'stdlib/belt_MutableSet': '@jaredly/bs-core/lib/js/belt_MutableSet.js',
10+
'stdlib/belt_MutableStack': '@jaredly/bs-core/lib/js/belt_MutableStack.js',
11+
'stdlib/js_unsafe': '@jaredly/bs-core/lib/js/js_unsafe.js',
12+
'stdlib/caml_string': '@jaredly/bs-core/lib/js/caml_string.js',
13+
'stdlib/belt_internalMapString':
14+
'@jaredly/bs-core/lib/js/belt_internalMapString.js',
15+
'stdlib/belt_Id': '@jaredly/bs-core/lib/js/belt_Id.js',
16+
'stdlib/caml_module': '@jaredly/bs-core/lib/js/caml_module.js',
17+
'stdlib/js_internal': '@jaredly/bs-core/lib/js/js_internal.js',
18+
'stdlib/char': '@jaredly/bs-core/lib/js/char.js',
19+
'stdlib/js': '@jaredly/bs-core/lib/js/js.js',
20+
'stdlib/caml_gc': '@jaredly/bs-core/lib/js/caml_gc.js',
21+
'stdlib/js_null': '@jaredly/bs-core/lib/js/js_null.js',
22+
'stdlib/belt_HashMapString': '@jaredly/bs-core/lib/js/belt_HashMapString.js',
23+
'stdlib/int64': '@jaredly/bs-core/lib/js/int64.js',
24+
'stdlib/sort': '@jaredly/bs-core/lib/js/sort.js',
25+
'stdlib/belt_SortArrayInt': '@jaredly/bs-core/lib/js/belt_SortArrayInt.js',
26+
'stdlib/caml_basic': '@jaredly/bs-core/lib/js/caml_basic.js',
27+
'stdlib/js_result': '@jaredly/bs-core/lib/js/js_result.js',
28+
'stdlib/caml_utils': '@jaredly/bs-core/lib/js/caml_utils.js',
29+
'stdlib/js_promise': '@jaredly/bs-core/lib/js/js_promise.js',
30+
'stdlib/js_obj': '@jaredly/bs-core/lib/js/js_obj.js',
31+
'stdlib/belt_Map': '@jaredly/bs-core/lib/js/belt_Map.js',
32+
'stdlib/js_console': '@jaredly/bs-core/lib/js/js_console.js',
33+
'stdlib/caml_backtrace': '@jaredly/bs-core/lib/js/caml_backtrace.js',
34+
'stdlib/oo': '@jaredly/bs-core/lib/js/oo.js',
35+
'stdlib/caml_hash': '@jaredly/bs-core/lib/js/caml_hash.js',
36+
'stdlib/belt_SortArray': '@jaredly/bs-core/lib/js/belt_SortArray.js',
37+
'stdlib/random': '@jaredly/bs-core/lib/js/random.js',
38+
'stdlib/stream': '@jaredly/bs-core/lib/js/stream.js',
39+
'stdlib/belt_SetDict': '@jaredly/bs-core/lib/js/belt_SetDict.js',
40+
'stdlib/caml_int32': '@jaredly/bs-core/lib/js/caml_int32.js',
41+
'stdlib/format': '@jaredly/bs-core/lib/js/format.js',
42+
'stdlib/stringLabels': '@jaredly/bs-core/lib/js/stringLabels.js',
43+
'stdlib/belt_MutableSetString':
44+
'@jaredly/bs-core/lib/js/belt_MutableSetString.js',
45+
'stdlib/stdLabels': '@jaredly/bs-core/lib/js/stdLabels.js',
46+
'stdlib/caml_lexer': '@jaredly/bs-core/lib/js/caml_lexer.js',
47+
'stdlib/printf': '@jaredly/bs-core/lib/js/printf.js',
48+
'stdlib/unixLabels': '@jaredly/bs-core/lib/js/unixLabels.js',
49+
'stdlib/bs_obj': '@jaredly/bs-core/lib/js/bs_obj.js',
50+
'stdlib/moreLabels': '@jaredly/bs-core/lib/js/moreLabels.js',
51+
'stdlib/js_mapperRt': '@jaredly/bs-core/lib/js/js_mapperRt.js',
52+
'stdlib/belt_Set': '@jaredly/bs-core/lib/js/belt_Set.js',
53+
'stdlib/js_types': '@jaredly/bs-core/lib/js/js_types.js',
54+
'stdlib/caml_oo': '@jaredly/bs-core/lib/js/caml_oo.js',
55+
'stdlib/belt_internalMapInt':
56+
'@jaredly/bs-core/lib/js/belt_internalMapInt.js',
57+
'stdlib/pervasives': '@jaredly/bs-core/lib/js/pervasives.js',
58+
'stdlib/scanf': '@jaredly/bs-core/lib/js/scanf.js',
59+
'stdlib/std_exit': '@jaredly/bs-core/lib/js/std_exit.js',
60+
'stdlib/belt': '@jaredly/bs-core/lib/js/belt.js',
61+
'stdlib/caml_parser': '@jaredly/bs-core/lib/js/caml_parser.js',
62+
'stdlib/js_cast': '@jaredly/bs-core/lib/js/js_cast.js',
63+
'stdlib/belt_internalAVLset':
64+
'@jaredly/bs-core/lib/js/belt_internalAVLset.js',
65+
'stdlib/belt_HashSetInt': '@jaredly/bs-core/lib/js/belt_HashSetInt.js',
66+
'stdlib/belt_MutableMapString':
67+
'@jaredly/bs-core/lib/js/belt_MutableMapString.js',
68+
'stdlib/caml_array': '@jaredly/bs-core/lib/js/caml_array.js',
69+
'stdlib/belt_MutableSetInt': '@jaredly/bs-core/lib/js/belt_MutableSetInt.js',
70+
'stdlib/digest': '@jaredly/bs-core/lib/js/digest.js',
71+
'stdlib/marshal': '@jaredly/bs-core/lib/js/marshal.js',
72+
'stdlib/belt_List': '@jaredly/bs-core/lib/js/belt_List.js',
73+
'stdlib/caml_weak': '@jaredly/bs-core/lib/js/caml_weak.js',
74+
'stdlib/js_string': '@jaredly/bs-core/lib/js/js_string.js',
75+
'stdlib/callback': '@jaredly/bs-core/lib/js/callback.js',
76+
'stdlib/queue': '@jaredly/bs-core/lib/js/queue.js',
77+
'stdlib/camlinternalMod': '@jaredly/bs-core/lib/js/camlinternalMod.js',
78+
'stdlib/caml_bytes': '@jaredly/bs-core/lib/js/caml_bytes.js',
79+
'stdlib/camlinternalFormatBasics':
80+
'@jaredly/bs-core/lib/js/camlinternalFormatBasics.js',
81+
'stdlib/belt_MutableMap': '@jaredly/bs-core/lib/js/belt_MutableMap.js',
82+
'stdlib/belt_internalSetInt':
83+
'@jaredly/bs-core/lib/js/belt_internalSetInt.js',
84+
'stdlib/belt_Array': '@jaredly/bs-core/lib/js/belt_Array.js',
85+
'stdlib/caml_io': '@jaredly/bs-core/lib/js/caml_io.js',
86+
'stdlib/camlinternalLazy': '@jaredly/bs-core/lib/js/camlinternalLazy.js',
87+
'stdlib/gc': '@jaredly/bs-core/lib/js/gc.js',
88+
'stdlib/belt_HashSetString': '@jaredly/bs-core/lib/js/belt_HashSetString.js',
89+
'stdlib/belt_internalBuckets':
90+
'@jaredly/bs-core/lib/js/belt_internalBuckets.js',
91+
'stdlib/belt_HashMapInt': '@jaredly/bs-core/lib/js/belt_HashMapInt.js',
92+
'stdlib/parsing': '@jaredly/bs-core/lib/js/parsing.js',
93+
'stdlib/js_list': '@jaredly/bs-core/lib/js/js_list.js',
94+
'stdlib/belt_MutableMapInt': '@jaredly/bs-core/lib/js/belt_MutableMapInt.js',
95+
'stdlib/bs_string': '@jaredly/bs-core/lib/js/bs_string.js',
96+
'stdlib/caml_primitive': '@jaredly/bs-core/lib/js/caml_primitive.js',
97+
'stdlib/belt_internalSetString':
98+
'@jaredly/bs-core/lib/js/belt_internalSetString.js',
99+
'stdlib/js_boolean': '@jaredly/bs-core/lib/js/js_boolean.js',
100+
'stdlib/list': '@jaredly/bs-core/lib/js/list.js',
101+
'stdlib/js_float': '@jaredly/bs-core/lib/js/js_float.js',
102+
'stdlib/js_int': '@jaredly/bs-core/lib/js/js_int.js',
103+
'stdlib/unix': '@jaredly/bs-core/lib/js/unix.js',
104+
'stdlib/js_int64': '@jaredly/bs-core/lib/js/js_int64.js',
105+
'stdlib/set': '@jaredly/bs-core/lib/js/set.js',
106+
'stdlib/array': '@jaredly/bs-core/lib/js/array.js',
107+
'stdlib/arrayLabels': '@jaredly/bs-core/lib/js/arrayLabels.js',
108+
'stdlib/bytes': '@jaredly/bs-core/lib/js/bytes.js',
109+
'stdlib/caml_queue': '@jaredly/bs-core/lib/js/caml_queue.js',
110+
'stdlib/caml_missing_polyfill':
111+
'@jaredly/bs-core/lib/js/caml_missing_polyfill.js',
112+
'stdlib/lazy': '@jaredly/bs-core/lib/js/lazy.js',
113+
'stdlib/node': '@jaredly/bs-core/lib/js/node.js',
114+
'stdlib/string': '@jaredly/bs-core/lib/js/string.js',
115+
'stdlib/block': '@jaredly/bs-core/lib/js/block.js',
116+
'stdlib/js_math': '@jaredly/bs-core/lib/js/js_math.js',
117+
'stdlib/js_dict': '@jaredly/bs-core/lib/js/js_dict.js',
118+
'stdlib/arg': '@jaredly/bs-core/lib/js/arg.js',
119+
'stdlib/belt_MapInt': '@jaredly/bs-core/lib/js/belt_MapInt.js',
120+
'stdlib/belt_internalAVLtree':
121+
'@jaredly/bs-core/lib/js/belt_internalAVLtree.js',
122+
'stdlib/belt_HashMap': '@jaredly/bs-core/lib/js/belt_HashMap.js',
123+
'stdlib/js_global': '@jaredly/bs-core/lib/js/js_global.js',
124+
'stdlib/belt_MutableQueue': '@jaredly/bs-core/lib/js/belt_MutableQueue.js',
125+
'stdlib/js_null_undefined': '@jaredly/bs-core/lib/js/js_null_undefined.js',
126+
'stdlib/js_option': '@jaredly/bs-core/lib/js/js_option.js',
127+
'stdlib/caml_format': '@jaredly/bs-core/lib/js/caml_format.js',
128+
'stdlib/printexc': '@jaredly/bs-core/lib/js/printexc.js',
129+
'stdlib/genlex': '@jaredly/bs-core/lib/js/genlex.js',
130+
'stdlib/caml_exceptions': '@jaredly/bs-core/lib/js/caml_exceptions.js',
131+
'stdlib/weak': '@jaredly/bs-core/lib/js/weak.js',
132+
'stdlib/sys': '@jaredly/bs-core/lib/js/sys.js',
133+
'stdlib/filename': '@jaredly/bs-core/lib/js/filename.js',
134+
'stdlib/caml_obj': '@jaredly/bs-core/lib/js/caml_obj.js',
135+
'stdlib/belt_MapDict': '@jaredly/bs-core/lib/js/belt_MapDict.js',
136+
'stdlib/complex': '@jaredly/bs-core/lib/js/complex.js',
137+
'stdlib/js_exn': '@jaredly/bs-core/lib/js/js_exn.js',
138+
'stdlib/hashtbl': '@jaredly/bs-core/lib/js/hashtbl.js',
139+
'stdlib/belt_MapString': '@jaredly/bs-core/lib/js/belt_MapString.js',
140+
'stdlib/js_json': '@jaredly/bs-core/lib/js/js_json.js',
141+
'stdlib/js_vector': '@jaredly/bs-core/lib/js/js_vector.js',
142+
'stdlib/js_date': '@jaredly/bs-core/lib/js/js_date.js',
143+
'stdlib/belt_SetInt': '@jaredly/bs-core/lib/js/belt_SetInt.js',
144+
'stdlib/caml_sys': '@jaredly/bs-core/lib/js/caml_sys.js',
145+
'stdlib/js_nativeint': '@jaredly/bs-core/lib/js/js_nativeint.js',
146+
'stdlib/js_undefined': '@jaredly/bs-core/lib/js/js_undefined.js',
147+
'stdlib/caml_int64': '@jaredly/bs-core/lib/js/caml_int64.js',
148+
'stdlib/caml_md5': '@jaredly/bs-core/lib/js/caml_md5.js',
149+
'stdlib/caml_oo_curry': '@jaredly/bs-core/lib/js/caml_oo_curry.js',
150+
'stdlib/belt_SetString': '@jaredly/bs-core/lib/js/belt_SetString.js',
151+
'stdlib/caml_float': '@jaredly/bs-core/lib/js/caml_float.js',
152+
'stdlib/bigarray': '@jaredly/bs-core/lib/js/bigarray.js',
153+
'stdlib/caml_builtin_exceptions':
154+
'@jaredly/bs-core/lib/js/caml_builtin_exceptions.js',
155+
'stdlib/obj': '@jaredly/bs-core/lib/js/obj.js',
156+
'stdlib/js_typed_array': '@jaredly/bs-core/lib/js/js_typed_array.js',
157+
'stdlib/map': '@jaredly/bs-core/lib/js/map.js',
158+
'stdlib/int32': '@jaredly/bs-core/lib/js/int32.js',
159+
'stdlib/listLabels': '@jaredly/bs-core/lib/js/listLabels.js',
160+
'stdlib/belt_Range': '@jaredly/bs-core/lib/js/belt_Range.js',
161+
'stdlib/belt_Option': '@jaredly/bs-core/lib/js/belt_Option.js',
162+
'stdlib/js_array': '@jaredly/bs-core/lib/js/js_array.js',
163+
'stdlib/camlinternalFormat': '@jaredly/bs-core/lib/js/camlinternalFormat.js',
164+
'stdlib/nativeint': '@jaredly/bs-core/lib/js/nativeint.js',
165+
'stdlib/lexing': '@jaredly/bs-core/lib/js/lexing.js',
166+
'stdlib/js_primitive': '@jaredly/bs-core/lib/js/js_primitive.js',
167+
'stdlib/camlinternalOO': '@jaredly/bs-core/lib/js/camlinternalOO.js',
168+
'stdlib/belt_SortArrayString':
169+
'@jaredly/bs-core/lib/js/belt_SortArrayString.js',
170+
'stdlib/buffer': '@jaredly/bs-core/lib/js/buffer.js',
171+
'stdlib/bytesLabels': '@jaredly/bs-core/lib/js/bytesLabels.js',
172+
'stdlib/belt_internalBucketsType':
173+
'@jaredly/bs-core/lib/js/belt_internalBucketsType.js',
174+
'stdlib/curry': '@jaredly/bs-core/lib/js/curry.js',
175+
'stdlib/belt_internalSetBuckets':
176+
'@jaredly/bs-core/lib/js/belt_internalSetBuckets.js',
177+
'stdlib/belt_HashSet': '@jaredly/bs-core/lib/js/belt_HashSet.js',
178+
'stdlib/stack': '@jaredly/bs-core/lib/js/stack.js',
179+
'bs-platform': '@jaredly/bs-core',
180+
};

packages/app/src/sandbox/eval/transpilers/babel/index.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,11 @@ class BabelTranspiler extends WorkerTranspiler {
4646
// dependencies from the file and return the same code. We get the dependencies
4747
// with a regex since commonjs modules just have `require` and regex is MUCH
4848
// faster than generating an AST from the code.
49-
if (path.startsWith('/node_modules') && !isESModule(code)) {
49+
if (
50+
(loaderContext.options.simpleRequire ||
51+
path.startsWith('/node_modules')) &&
52+
!isESModule(code)
53+
) {
5054
regexGetRequireStatements(code).forEach(dependency => {
5155
if (dependency.isGlob) {
5256
loaderContext.addDependenciesInDirectory(dependency.path);

0 commit comments

Comments
 (0)