Skip to content
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

Require.js Compatibility #13

Open
bitmage opened this issue Nov 1, 2013 · 2 comments
Open

Require.js Compatibility #13

bitmage opened this issue Nov 1, 2013 · 2 comments

Comments

@bitmage
Copy link

bitmage commented Nov 1, 2013

I'm having trouble getting Require.js to recognize the files loaded by the coffee-script preprocessor. Require.js implicitly adds a '.js' extension to all the referenced locations. It can't find the files loaded by the CS preprocessor because they are loaded into the browser with the '.coffee' extension.

The file contents are being compiled to js... is there any way we can change the extension to match so that everything will act consistently?

@bitmage
Copy link
Author

bitmage commented Nov 1, 2013

Currently I have two workarounds for this:

  1. precompiling all my assets to js, and having karma reference those. This has the disadvantage of slowing down the feedback loop a lot, as I have to run the build script every time, and the karma watcher doesn't work properly with regenerated files, so I end up restarting karma and the browsers as well.
  2. Using an absolute reference to each file. E.G. /base/app/client/js/models/cart.coffee. This lets me use the autowatcher, but isn't a maintainable solution. Any time there are sub-dependencies defined in the application code this approach will break.

Neither one of these are particularly good. I think we'd avoid the whole issue by having the filenames converted to '.js'.

Feedback/suggestions welcome!

@waynegerard
Copy link

I'm confused, I'm pretty sure that's exactly what the preprocessor is doing by default:

// index.js, lines 13-15: 
 var transformPath = args.transformPath || config.transformPath || function(filepath) {
    return filepath.replace(/\.coffee$/, '.js');
  };

All my files get loaded into the browser using a js extension - how are you getting them to load with a .coffee extension?

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

No branches or pull requests

2 participants