LinkedInAttic/inject

CommonJS Scan Shouldn't Occur if dependencies [] is set

jakobo opened this issue · 3 comments

Sample code:

// program.js
define(['foo'], function(foo) {
  equal(foo.name, 'foo', 'foo.name was set properly');
});
// foo.js
define('foo', [], function() {
  var fooName = 'foo';

  // the bar module should not be loaded per the AMD spec
  try {
    fooName = require('bar').name;
  }
  catch(e) {}

  return {
    name: fooName
  };
});
// bar.js
define('bar', function() {
  return {
    name: 'bar'
  };
});

Possible places we could fix:

  • RequireContext - change the way define() works?
  • Analyzer / TreeDownloader? - argument to not scan dependencies?

#268 fixes this

Fixed by @apmadhani