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

Add support for defining functions in configuration #177

@wuservices

Description

@wuservices

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions