I'm receiving this error in my console when importing a module that does not have an export - it just executes a function. This error is thrown here https://github.com/systemjs/systemjs/blob/9bc693e4114b6d9cb36ac557f0f8a71ba68c7dcd/lib/amd.js#L59. Looking up a few lines I see if (loader.execute !== false) {. What determines the execute flag?
It may be important to know that I am using JSPM, calling import 'component/component'
That error means the module was loaded as an AMD module, but the define function was not run. It's advisable in this case to check if the module really is AMD, and to try and set meta to adjust the format that it is treated as.
Ahh, that makes sense. It is not an AMD module. Is there meta I can set at
System.js or JSPM level to make this work? Or do I need to do update the
library I'm trying to import?
On Wed, 15 Jul 2015 5:02 am Guy Bedford [email protected] wrote:
That error means the module was loaded as an AMD module, but the define
function was not run. It's advisable in this case to check if the module
really is AMD, and to try and set meta to adjust the format that it is
treated as.—
Reply to this email directly or view it on GitHub
https://github.com/systemjs/systemjs/issues/588#issuecomment-121593958.
Yes you can do System.config({ meta: { 'path/to/module.js': { format: 'global' } } }). See https://github.com/systemjs/systemjs/blob/master/docs/module-formats.md for more info.
:100:
This one saved me big time at the last minute. Thanks for thinking of everything!
For Cordova / PhoneGap / Ionic this resolves the issue with loading cordova.js by setting the meta property to force it as a global module.
Given the following:
// plugin.js
define(['jquery'], function ($) {
$('body').css('color', 'hotpink')
});
// main.js
import 'plugin';
Will the call to import plugin execute the code within plugin.js? I'm running into this problem myself.
Most helpful comment
Yes you can do
System.config({ meta: { 'path/to/module.js': { format: 'global' } } }). See https://github.com/systemjs/systemjs/blob/master/docs/module-formats.md for more info.