whitespace after "require" changes behavior #265

Closed
shovemedia opened this Issue May 11, 2012 · 5 comments

Projects

None yet

2 participants

@shovemedia

A very simple test case at http://shovemedia.com/requirejsissue.zip

See /js/Main.js for two lines you can swap back and forth.
The only difference is the whitespace.

If you bring up index.html in Chrome with the javascript console, you'll
see an alert when the extra space is removed (correct behavior),
and the following error when it's present:
Uncaught Error: Module name 'SomeModule' has not been loaded yet for context:

Tested with the latest version before sending, both commented and minified.

@jrburke
Member
jrburke commented May 11, 2012

Right now I'm getting a 404 for that zip file, just let me know when it is working, and I'll give it a try.

@shovemedia

http://shovemedia.com/requirejsIssue.zip

Silly capitalization. Knew I should have double-checked my link

:j

On May 11, 2012, at 1:23 PM, James Burke reply@reply.github.com wrote:

Right now I'm getting a 404 for that zip file, just let me know when it is working, and I'll give it a try.


Reply to this email directly or view it on GitHub:
#265 (comment)

@jrburke jrburke closed this in e8fc01a May 11, 2012
@jrburke
Member
jrburke commented May 11, 2012

Ouch, yeah, just a regexp problem. Looks like there was a recent change in the behavior of Function.prototype.toString() in at least Chrome, probably all latest WebKit browsers. For what it is worth, this is only an issue in source form, after a build it, the optimizer would have found it correctly. But the source form is super important to have working, and the regexp should have allowed for this anyway.

It is fixed now in the dev2.0 branch, and I updated the errors page to mention this problem in 1.0.x, may do a backport if a 1.0.9 release gets scheduled.

@shovemedia

I'm not sure I follow the "build" workflow you mention. Can you point me to a resource that explains?

and thanks!
:j

On May 11, 2012, at 2:15 PM, James Burke wrote:

Ouch, yeah, just a regexp problem. Looks like there was a recent change in the behavior of Function.prototype.toString() in at least Chrome, probably all latest WebKit browsers. For what it is worth, this is only an issue in source form, after a build it, the optimizer would have found it correctly. But the source form is super important to have working, and the regexp should have allowed for this anyway.

It is fixed now in the dev2.0 branch, and I updated the errors page to mention this problem in 1.0.x, may do a backport if a 1.0.9 release gets scheduled.


Reply to this email directly or view it on GitHub:
#265 (comment)

@jrburke
Member
jrburke commented May 11, 2012

I meant the requirejs optimizer, r.js, would have found the dependency, but normally that is just used for when doing a build to combine your resources together, not helpful for dev/source loading:

http://requirejs.org/docs/optimization.html

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment