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

mainConfigFile -> parse.findConfig variable reference problem #693

Closed
DimitarChristoff opened this issue Jun 16, 2014 · 1 comment
Closed

Comments

@DimitarChristoff
Copy link

There may be a slight problem with this:

https://github.com/jrburke/r.js/blob/master/dist/r.js#L23147

When the config has been created to be re-used at runtime as well as under nodejs, it does not seem to be picking it up from mainConfigFile if the format is 'unusual', i.e. not the standard require.config({});

for instance, when this failed to set a config:

(function(){
    var config = { baseUrl: 'foo', .. };

    // simplified umd-like wrap that sets config or preps it for later requirejs use
    if (this.require && this.require.config)
        this.require.config(config);
    else if (typeof module !== 'undefined' && module.exports) 
        module.exports = config;
    else 
        this.require = config;
}.call(this));

... I tried the less ambitious:

var config = { ... };
require.config(config);

which also fails. so the parse.getRequireObjectLiteral may also be at fault here.

I can have a go at fixing this outside of work hours if it's not something that can be worked around or easily fixed.

context: work out a flexible config reuse pattern between multiple pages, components and apps, sharing it for runtime/build and tests, in the style of patterns discussed here: requirejs/requirejs#354

@jrburke
Copy link
Member

jrburke commented Aug 23, 2014

There are no plans to get fancier with the config detection, since it would then mean effectively simulating running code to find out what the config would end up being (at least the expectation would continue to grow over time for that).

The best thing to do is to construct a node program for your project that reads in that file, does a regexp or some other parse to extract that config object literal, evaluate it, then use that to construct build config args to pass to require('requirejs').optimize()](http://requirejs.org/docs/node.html#optimizer).

@jrburke jrburke closed this as completed Aug 23, 2014
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