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

Unable to specify file path when using a plugin in data-main attribute #1472

Closed
christowiz opened this issue Jan 12, 2016 · 1 comment
Closed
Milestone

Comments

@christowiz
Copy link

@christowiz christowiz commented Jan 12, 2016

Wondering if there is a specific reason file paths are not supported when using a plugin in the data-main attribute. I created a plugin that bootstraps the application by loading the config object then calling a mediator.

I am initializing the app here passing the mediator name home

<script src="vendor/require.js" data-main="plugins/config!home"></script>

And here is the plugin.

define({
    load: function( name, req, onload, config )  {

        req( [ 'require-config.js' ], function( value ) {

            onload( value );

            require.config( value );

            req( [ 'mediators/' + name ] );

        });
    }
});

This works but it would be simpler to be able to pass the home mediator path (mediators/home) to the plugin so it doesn't have to be hardcoded into the file in case we need to load something outside of the mediators directory.

<script src="vendor/require.js" data-main="plugins/config!mediators/home"></script>

But this throws an error because the data-main attribute is parsing the path after the plugin (!).

I know I can split it into two <script> tags to load the config and then load the mediator but I'd rather have a bootstrap file that can take care of the config object outside of the HTML structure and keep the single entry point.

@jrburke jrburke added this to the 2.1.23 milestone Jan 21, 2016
@jrburke jrburke removed this from the 2.1.23 milestone Mar 15, 2016
@jrburke jrburke added this to the 2.2.0 milestone Mar 15, 2016
@jrburke jrburke added this to the 2.2.0 milestone Mar 15, 2016
@jrburke jrburke removed this from the 2.1.23 milestone Mar 15, 2016
@jrburke jrburke closed this in c5f7735 Mar 15, 2016
@christowiz
Copy link
Author

@christowiz christowiz commented Mar 16, 2016

Thanks for the change!

Loading

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
2 participants