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 Support - BaseURL and Configuration #291

Closed
iammerrick opened this issue Jan 11, 2013 · 3 comments
Closed

Require.js Support - BaseURL and Configuration #291

iammerrick opened this issue Jan 11, 2013 · 3 comments

Comments

@iammerrick
Copy link
Contributor

One major problem with the current Require.js adapter is that it enforces you to call requirejs.config to configure the baseURL. This is unfortunate because Require.js allows you set up a global object called require which it will than read in as configuration. This is a much more flexible way of configuring your loader as it allows you to do overrides for different environments.

Say I have a config.js file that I include in my HTML above the require.js file.

var require = { baseUrl : '...', paths: {...}};

When Require.js gets loaded onto the page it will load in that require configuration, this allows me to override configuration options for my testing environment.

<script src="config.js"></script>
<script src="testing/config.js"></script>
<script src="require.js"></script>

The problem is that the Require adapter calls:

requirejs.config({ baseUrl : '/base'})

Which unfortunately overrides whatever baseUrl someone might have configured. This also doesn't account for multiple require.js contexts. See Squire.js for an example of cloning require configuration.

One idea for a workaround is to concatenate the existing baseUrl onto '/base' though like I said this doesn't support multiple contexts very well... Perhaps we should implement testacular to prepend '/base' to all the existing configured baseUrls consequently supporting multiple contexts and require configuration.

Thoughts?

@jgrund
Copy link

jgrund commented Jan 17, 2013

+1

@vojtajina
Copy link
Contributor

So I think the best will be just not touch the baseUrl at all and let users do it. It means people need to understand that Testacular serves files under /base/* (which is the basePath from config file) or under /absolute/* (for files that are outside the basePath of the project. However, I think it's gonna be less magical and less confusing.

Here it is vojtajina/testacular@63f3f40

What do you think ?

@iammerrick
Copy link
Contributor Author

Beautiful, I think its much better to leave this in the hands of the consumer. And no worries, the code is straightforward enough I've just been using my patched adapter since I filed the bug. :-)

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

3 participants