Skip to content

Instantly share code, notes, and snippets.

@elliotdavies
Created August 10, 2019 15:18
Show Gist options
  • Save elliotdavies/c95af3693fe92dfd48a96d1dd2fdbd11 to your computer and use it in GitHub Desktop.
Save elliotdavies/c95af3693fe92dfd48a96d1dd2fdbd11 to your computer and use it in GitHub Desktop.
PureScript async imports
var PS = {};
// Either need to rename FFI modules (e.g. `$PS["Effect.Console.FFI"]`) or else
// combine them as shown here to avoid recursive promise calls
(function($PS) {
$PS["Effect.Console"] = $PS["Effect.Console"] || Promise.resolve({});
$PS["Effect.Console"] = $PS["Effect.Console"].then(exports => {
exports["log"] = function(s) {
return function() {
console.log(s);
return {};
};
};
return exports;
});
})(PS);
(function($PS) {
$PS["Main"] = $PS["Main"] || Promise.resolve({});
$PS["Main"] = $PS["Main"].then(exports => {
return $PS["Effect.Console"].then(Effect_Console => {
var main = Effect_Console.log("\ud83c\udf5d");
exports["main"] = main;
return exports;
});
});
})(PS);
module.exports = PS;
const PS = require('./output/bundle.js');
PS.Main.then(Main => {
Main.main();
});
//-> "🍝"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment