Skip to content
This repository has been archived by the owner on Jun 6, 2023. It is now read-only.

Support for CoffeeScript-plugin for require #11

Open
tkallevik opened this issue Nov 22, 2012 · 4 comments
Open

Support for CoffeeScript-plugin for require #11

tkallevik opened this issue Nov 22, 2012 · 4 comments

Comments

@tkallevik
Copy link

Hi,

I am using CoffeeScript for my code, and the CoffeeScript-plugin for RequireJS (https://github.com/jrburke/require-cs). My problem is that I can't get testr.js to play nice with the CoffeeScript-plugin.

One problem is that testr gets its paths with .js extension, which will fail due to the fact that CoffeeScript-files has .coffee as the extension. This I have solved by removing '.js' from the path, in the normalize-function.

Another problem is that testr.js seems to be varying between including the plugin-prefix and not including the plugin-prefix in its paths. This becomes a problem when getting the moduleDef in the buildModule-function. If I have a dependency, 'cs!models/test_model', it will search the moduleMap for 'model/test_model', when the module is stored in the map with key 'cs!models/test_model'. I solved this by adding the depPaths without the plugin-prefix in the "process the dependency ids" part of the define-function.

The third, and last, problem is that the auto loading of specs and stubs looks for .js-versions of these. I have also written these in CoffeeScript, and it would be nice to be able auto load these using the CoffeeScript-plugin for RequireJS.

I was hoping that you could take a look at the first two problems, and make a more permanent solution for supporting plugins and other file extensions than .js.

For the third problem, it would suffice if it somehow was possible to define a plugin to use for loading specs and stubs. It could for example be configured at the same time as the baseUrls are set.

Are these problems something you can help me solve?

Regards
Thomas

@mattfysh
Copy link
Owner

@tkallevik if you can point me to a repo where you're trying to use it with CoffeeScript, I'll take a look. It's strange that you had to modify testr.js for the first two problems, as that functionality is handled by requirejs. Where it can, testr.js passes off control to requirejs so that it doesn't break the native functions.

Send me a link to that repo and I'll check it out.

@tkallevik
Copy link
Author

@mattfysh I have now created a small repo, where I have two implementations of the same code, one in Javascript and one in CoffeeScript. The Javascript version works fine, but the CoffeeScript version does not. The repo can be found here: https://github.com/tkallevik/testr-coffeescript.

To switch between the Javascript implementation and the CoffeeScript implementation you just change the .js-file loaded by RequireJS (main-js.js for the Javascript version, and main-coffee.js for the CoffeeScript version).

Testr is loaded in the main-js.js / main-coffee.js file. This is not necessary for the Javascript version, but for the CoffeeScript version I see no way around since the require-plugin has to be loaded before testr to avoid errors.

If there is anything more you need me to do, or you need some more information, just let me know.

@mattfysh
Copy link
Owner

@tkallevik I've not yet had time to look at that repo, but I have put together a front-end dev stack which includes both CoffeeScript and Require.js/testr.js working together. Take a look at https://github.com/mattfysh/stack to see how it's done.

If this still doens't help, let me know, and I'll go over the code in your repo.

@tkallevik
Copy link
Author

@mattfysh Time is a scarcity for me to, so I know the feeling. As I described earlier I use the CoffeeScript-plugin for RequireJS, so that I do not have to compile the CoffeeScript all the time. The dev stack you have put together doesn't use this, as far as I can see, so it doesn't actually address my problem.

If you find the time to check out my repo that would be great, but take all the time you need as this isn't that urgent for me to get fixed :)

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

No branches or pull requests

2 participants