LinkedInAttic/inject

First array found in a definition being parsed as dependency list, even if it isn't an argument to define

noyesa opened this issue · 2 comments

Hey all.

I found a bug today using inject 0.6.1. If I define a module like so:

define(function() {
  var someThings = ['one', 'two', 'three'];
});

It will try to download modules named one, two, and three. I'm guessing this is a bug with whatever regexp parses the body of the define method looking for its dependency list. If I change it to have an empty array I'll see no more errors.

define([], function() {
  var someThings = ['one', 'two', 'three'];
});

Here's the logs I see for the problem code:

## RequireContext for null ##
AMD require.run(string) of ./app inject.min.js:7
## RequireContext for null ##
CommonJS require.ensure(array) of ./app inject.min.js:7
## Communicator (app/app.js) ##
requesting inject.min.js:7
## Communicator (app/app.js) ##
queued inject.min.js:7
XHR finished loading: GET "http://localhost:63343/public/app/app.js". inject.min.js:7
## Communicator (app/app.js) ##
status 200. Length: 59 inject.min.js:7
SharedContentScript::onBackgroundPageMessage: init {"oktaDomain":"https://linkedin.okta.com","settings":{"pluginFormFillCaptureEnabled":false,"pluginOfflineToolbarEnabled":true},"matchedFullCredSitesNoPw":[]} log.js:1
## Communicator (app/one.js) ##
requesting inject.min.js:7
## Communicator (app/one.js) ##
queued inject.min.js:7
## Communicator (app/two.js) ##
requesting inject.min.js:7
## Communicator (app/two.js) ##
queued inject.min.js:7
## Communicator (app/three.js) ##
requesting inject.min.js:7
## Communicator (app/three.js) ##
queued inject.min.js:7
GET http://localhost:63343/public/app/one.js 404 (Not Found) inject.min.js:7
XHR finished loading: GET "http://localhost:63343/public/app/one.js". inject.min.js:7
## Communicator (app/one.js) ##
status 404. Length: 143 inject.min.js:7
GET http://localhost:63343/public/app/two.js 404 (Not Found) inject.min.js:7
XHR finished loading: GET "http://localhost:63343/public/app/two.js". inject.min.js:7
## Communicator (app/two.js) ##
status 404. Length: 143 inject.min.js:7
GET http://localhost:63343/public/app/three.js 404 (Not Found) inject.min.js:7
XHR finished loading: GET "http://localhost:63343/public/app/three.js". inject.min.js:7
## Communicator (app/three.js) ##
status 404. Length: 143

Thanks for the test case. I'll see if it is happening in 0.7.0 as well. Because it's regex based, there's a chance it isn't fixed in 0.7.0 and needs to be addressed.

This has been resolved in head and will be put into the 0.7.0 build.