linkedin/inject — Issue #92: SyntaxError with minified source
Author: ryanfitz
Created: 2012-03-02 01:27:53+00:00
State: open

After minifying my code (not inject.js) I got the following error SyntaxError: Unexpected token ','

here is an example of my code after it got minified:

define("app",["require","module","exports","vendor/jquery","vendor/backbone","foo"],function(a,b,c){var d=a("vendor/jquery"),e=a("vendor/backbone"),f=a("templates/world"),g=a("templates/hello"),h=a("foo").name;console.log("foo's name is.....",h),console.log("backbone version is",e.VERSION),c.app={foo:"moar...",name:h,template:f,hbarsTemplate:g}})

The minifier renamed the require call to variable 'a', so none of the regexes inside inject can pull out the require calls.

Also with turning variable renaming off, the regexes still couldn't capture var foo=require('foo'),app=require('app');