Skip to content
Snippets Groups Projects
Commit 777f108f authored by Serge S. Gulin's avatar Serge S. Gulin :construction_worker:
Browse files

JS: fs module imported twice (by emscripten and by ghc-internal). ghc-internal import wrapped

in a closure to prevent conflict with emscripten (fixes #24602)

Better solution is to use some JavaScript module system like AMD, CommonJS or even UMD. It will be investigated at other issues.
At first glance we should try UMD (See https://github.com/umdjs/umd)
parent 3db54f9b
No related branches found
No related tags found
No related merge requests found
......@@ -46,18 +46,36 @@ function h$isGHCJSi() {
}
// load all required node.js modules
if(typeof process !== 'undefined' && (typeof h$TH !== 'undefined' || (typeof require !== 'undefined' && typeof module !== 'undefined' && module.exports))) {
if(typeof global !== 'undefined' && typeof process !== 'undefined' && (typeof h$TH !== 'undefined' || (typeof require !== 'undefined' && typeof module !== 'undefined' && module.exports))) {
h$isNode_ = true;
// we have to use these names for the closure compiler externs to work
var fs = require('fs');
var path = require('path');
var os = require('os');
var child_process = require('child_process');
var h$fs = fs;
var h$path = path;
var h$os = os;
var h$child = child_process;
// we have to put fs var into closure to prevent name clashes with emscripten compiler code injections
// we use additional suffix to have more guarantees over possible clashes
// we should use amd/commonjs module wrappers to avoid such ugly things
global.h$nodeOS_modules_qvsKGchAmE = (function() {
var fs = require('fs');
var path = require('path');
var os = require('os');
var child_process = require('child_process');
return {
'fs' : fs,
'path': path,
'os': os,
'child_process': child_process
};
})();
// we dictionary-like access strictly prevents
// google closure compiler names mangling
var h$fs = global.h$nodeOS_modules_qvsKGchAmE['fs'];
var h$path = global.h$nodeOS_modules_qvsKGchAmE['path'];
var h$os = global.h$nodeOS_modules_qvsKGchAmE['os'];
var h$child = global.h$nodeOS_modules_qvsKGchAmE['child_process'];
// we forcibly delete temporary lexical environment variable
// to prevent any clashes
delete global.h$nodeOS_modules_qvsKGchAmE;
var h$process = process;
function h$getProcessConstants() {
// this is a non-public API, but we need these values for things like file access modes
var cs = process['binding']('constants');
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment