Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Adding a config option to stop assuming module filenames end in .js #1249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

hudlee
Copy link

@hudlee hudlee commented Dec 11, 2014

Adds a config option to stop assuming module filenames end in .js

When disableAutoJsExt: true, is set you have to pass complete file
names including extension when requiring modules such as foo.js or
foo.njs instead of foo

I am using require.js server side with node.js and I need to name my
modules .njs or .model etc to separate them from static .js files.

The noext plugin does not work serverside with node.js and I feel
assuming a file ext is unwise in general. If I missed an obvious way
to accomplish this, please let me know. Someone more familiar with
requirejs code then me should review and modify this patch as needed.
Making sure it doesn't break anything (like undef etc).

However it is done I think allowing non .js file extensions for
module files is important.

When disableAutoJsExt: true, is set you have to pass complete file
names including extension when requiring modules such as foo.js or
foo.njs instead of foo

I am using require.js server side with node.js and I need to name my
modules .njs or .model etc to separate them from static .js files.

The noext plugin does not work serverside with node.js and I feel
assuming a file ext is unwise in general. If I missed an obvious way
to accomplish this, please let me know. Someone more familiar with
r.js code then me should review and modify this patch as needed.
Making sure it doesn't break anything (like undef etc).

However it is done I think allowing non .js file extensions for
module files is important.
@ogonkov
Copy link

ogonkov commented Dec 12, 2014

Why not use foo.n.js?

@hudlee
Copy link
Author

hudlee commented Dec 13, 2014

Why not use foo.n.js?
Currently I am serving up some of my static .js files with this regex: /.js$/

To use foo.n.js I would need a regex that matched foo.js but not foo.n.js (and my other 4 non static .suffixes) This would make the regex complex enough that I don't know how to write it. Considering that javascript doesn't do negative look-behind and I can't reverse the string and use negative look-ahead since I am passing the regex to code I didn't write.

The regex is simple when I use .njs for non static js files.
Also foo.post looks nicer then foo.post.js or foo.post.n.js especially when I tack on even more .suffixes.
I want to be able to put all files used on a page in one place.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants