Skip to content

Commit

Permalink
rename require() to requirejs() on flow.org
Browse files Browse the repository at this point in the history
Summary:
js_of_ocaml 3.0 assumes that if `require` is in global scope, then the
environment is node and tries to use the `fs` module.
ocsigen/js_of_ocaml#626

as a workaround, rename `require` to `requirejs` using the pattern discussed in
the requirejs docs linked from the comments.

Reviewed By: samwgoldman

Differential Revision: D6140213

fbshipit-source-id: 7818d9a21ccd686b5454a0a2f07933a685526f70
  • Loading branch information
mroch authored and facebook-github-bot committed Oct 25, 2017
1 parent d1b86e1 commit e64b1fe
Show file tree
Hide file tree
Showing 7 changed files with 10 additions and 8 deletions.
2 changes: 1 addition & 1 deletion website/_assets/js/flow-loader.js.es6
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ export function load(version) {
`/static/${version}/flowlib/react.js`,
];
const flowLoader = new Promise(function(resolve) {
require([`/static/${version}/flow.js`], resolve);
requirejs([`/static/${version}/flow.js`], resolve);
});
return Promise.all([flowLoader, ...libs.map(get)])
.then(function([_flow, ...contents]) {
Expand Down
2 changes: 2 additions & 0 deletions website/_assets/js/require_2_3_3.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion website/_assets/js/tryFlow.js.es6.liquid
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ function createEditor(
) {
const defaultFlow = initFlow(flowVersion);

require([
requirejs([
'codemirror/addon/lint/lint',
'codemirror/mode/javascript/javascript',
'codemirror/mode/xml/xml',
Expand Down
2 changes: 1 addition & 1 deletion website/_assets/js/tryFlowWorker.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ this.onmessage = function(e) {
function getFlow(version) {
if (!(version in versionCache)) {
versionCache[version] = new Promise(function(resolve) {
require(['flow-loader'], function(FlowLoader) {
requirejs(['flow-loader'], function(FlowLoader) {
resolve(FlowLoader.load(version));
});
});
Expand Down
6 changes: 3 additions & 3 deletions website/_layouts/default.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
{% endif %}
<script type="text/javascript" src="{% asset_path 'require_2_3_3.js' %}"></script>
<script type="text/javascript">
require.config({
requirejs.config({
baseUrl: '/assets',
waitSeconds: 30,
shim: {
Expand Down Expand Up @@ -78,12 +78,12 @@
return tether;
});

require([
requirejs([
'bootstrap',
{% if page.search or layout.search %}'{% asset_name "search" %}',{% endif %}
]);
{% if page.editor or layout.editor %}
require(['{% asset_name "editor" %}'], function(Editor) {
requirejs(['{% asset_name "editor" %}'], function(Editor) {
Editor.init();
});
{% endif %}
Expand Down
2 changes: 1 addition & 1 deletion website/en/docs/install.html
Original file line number Diff line number Diff line change
Expand Up @@ -65,5 +65,5 @@
</div>

<script type="text/javascript">
require(['{% asset_name install %}']);
requirejs(['{% asset_name install %}']);
</script>
2 changes: 1 addition & 1 deletion website/try.html
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
</div>

<script type="text/javascript">
require(['{% asset_name "tryFlow" %}'], function(tryFlow) {
requirejs(['{% asset_name "tryFlow" %}'], function(tryFlow) {
tryFlow.createEditor(
'{{ site.flow.version }}',
document.getElementById("code"),
Expand Down

0 comments on commit e64b1fe

Please sign in to comment.