These are chat archives for systemjs/systemjs

10th
May 2018
Avanish Pathak
@5punk
May 10 2018 01:15
Is there a way I can prevent systemjs from polluting the global window environment?
I am trying to get Systemjs to play well with requirejs, for legacy reasons
SystemJS always overwrites window.define, causing requirejs to fail
is there a way I can run system js and all the scripts I use it to dynamically import in a sandbox/fake environment? (So no 1 can pollute the global/window environment)
Removing these lines does not work
OptimusGhandi
@OptimusGhandi_twitter
May 10 2018 01:20
No, having investigated that, don't bother.
Just make the switch and drop require all together.
Avanish Pathak
@5punk
May 10 2018 01:21
it's a massive application, there is no way I can just move. It has to be in iterations
OptimusGhandi
@OptimusGhandi_twitter
May 10 2018 01:21
Tough. You're out of luck.
Avanish Pathak
@5punk
May 10 2018 01:24
if only there was a way to local eval (sandbox)
I feel there has to be a way
OptimusGhandi
@OptimusGhandi_twitter
May 10 2018 01:28
There is not yet, JavaScript is a mess.
Feel free to investigate ecma proposals, there is a trial implemention of realms but it only works for strict, so no good for your purpose. Maybe you can hack iframes for your purposes and do async message passing.
@guybedford had provided a mechanism
OptimusGhandi
@OptimusGhandi_twitter
May 10 2018 01:36
You might also look at treating require legacy code explicitly as a "global" module and shim in global define from require, where require is registered. You might run into that not working due to regexes and ... Stuff ... . Systemjs manipulates the global namespace because there really is no other way. Running require 100% in system would be a ton of specific, non generalizable debugging work.
I have looked into your problem extensively, fwiw.
Avanish Pathak
@5punk
May 10 2018 01:38
  1. The legacy code is explicitly global
  2. I'm using a very basic implementation of SystemJS, namely just the config and import function
  3. I really appreciate your help
This message was deleted
I am totally fine with systemjs polluting the global environment, just as long as it is in a random hash global variable/or in nontraditional global variable (window.System.hsgdckfuygeskufygsefk={}). Since, SystemJS is standalone and self-sufficient; I think this should be possible
It is trying to take over the window.define function, additionally every script I import through system is registering to the global namespace (even though it is umd). Because define is always available
It would be nice if I could literally search and replace define to SystemDefine
Avanish Pathak
@5punk
May 10 2018 01:44
even in every script that gets parsed
that way every script I import, registers to SystemDefine, instead of window.define
OptimusGhandi
@OptimusGhandi_twitter
May 10 2018 01:49
It is very complicated, and require is prone to breaking stuff if you use it at all. I recommend changing your own code. Perhaps you could write a custom plugin to "translate" your old code programmatically, rewriting it. But your best bet for no unintended rabbit holes of undebuggable magic is still to switch, for which there are a lot of tools and resources.
Avanish Pathak
@5punk
May 10 2018 02:53
systemjs/systemjs#159
Avanish Pathak
@5punk
May 10 2018 03:38
wondering if there's still a compatibility mode
I cannot window.require = SystemJS.amdRequire. I get the error require.config is not a function. SystemJS is exposing a nontraditional require API