Is system.js adding stuff to my javascript?

时间:2016-04-04 17:03:06

标签: javascript systemjs jqwidget

I am trying to get JQWidgets to work. It has a jsxcore.js file that defines the following variable:

 var jqxBaseFramework = window.minQuery || window.jQuery;

Then in other files, this variable is used. But I am getting an error that says jqxBaseFramework is not defined in the very next file.

I noticed that when I system.import a file, this added to the top of it:

  (function(require, exports, module, __filename, __dirname, global, GLOBAL) {

This causes variables that would be in scope to be out of scope.

Is system.js doing this? If so, Is there a work around to the scope issue?

If not, I am going to have to go add that variable to the top of each file.... Not fun as there are quite a few.

1 个答案:

答案 0 :(得分:1)

Is system.js doing this?

Yes

If so, Is there a work around to the scope issue?

Yes. SystemJS is a module loading system. You treat your files as encapsulated modules. You should throw away the concept of globals.

Should you want to expose a value from a module, you export it. Should a module need a value from a certain module, you require it. Read more about CommonJS to know more about how this mechanism works.