Skip to content
This repository has been archived by the owner on Mar 23, 2024. It is now read-only.

Add support for defining functions in configuration #177

Closed
wuservices opened this issue Jul 22, 2014 · 1 comment · May be fixed by #179
Closed

Add support for defining functions in configuration #177

wuservices opened this issue Jul 22, 2014 · 1 comment · May be fixed by #179

Comments

@wuservices
Copy link
Contributor

There doesn't seem to be a way to define a JavaScript function to be used for init in a shim: http://requirejs.org/docs/api.html#config-shim.

Because the config is stored in YAML and then converted to JSON, it seems impossible to define a JavaScript function since it will just end up becoming a string. Because YAML and JSON are general data formats, there's no way to even define a JavaScript function.

One possible hack would be to try and detect certain configs that look like a function a strip the quotes after converting to JSON. The non-exhaustive pattern might look like "function\(.*?\)\s*?{.*?}[\s\\n]*". We could also detect certain keys and strip quotes every time, but desired behavior varies across different versions of require.js.

The only other simple alternative I can think of would be to store the config in native JS and just read that in. That might be the simplest and most straightforward.

Thoughts?

@carsomyr
Copy link
Collaborator

Closing this in favor of #179.

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

Successfully merging a pull request may close this issue.

2 participants