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

RequireJS issue v1.1.0 #51

Open
genericandy opened this issue Jun 2, 2016 · 2 comments
Open

RequireJS issue v1.1.0 #51

genericandy opened this issue Jun 2, 2016 · 2 comments

Comments

@genericandy
Copy link

genericandy commented Jun 2, 2016

Starting with v1.1.0 of PxLoader, I am now getting the following error when including it in my code.

require.js:168 Uncaught Error: Script error for "pxloader", needed by: app/Sounds, utils/resizer

Neither of the scripts listed use PxLoader in anyway, so I am a little confused by the error.

I have a path set to point to pxloader's folder in my requirejs config.

paths: { jquery: '../bower_components/jquery/dist/jquery.min', greensock: '../bower_components/greensock/src/minified', pxloader: '../bower_components/PxLoader/dist' },

And in the file that produces the error....

if (typeof define === 'function' && define.amd) { define( [ 'jquery', 'pxloader/pxloader-all' ], function () {...

PxLoader 1.0.2 and backwards work ok. This error is new to 1.1.0.

Anyone suggestions of how to resolve it would be appreciated.

@joelfillmore
Copy link
Member

@robinnorth - any ideas? It seems like the new export should work with this RequireJS syntax.

@robinnorth
Copy link
Contributor

robinnorth commented Jun 2, 2016

@genericandy Now that all the PxLoader plugins have a UMD wrapper which defines an AMD module (or a CommonJS module or a browser global, depending on the environment they're used in), you'll need to define the path to PxLoader and its plugins in your RequireJS config separately. The pxloader-all.js file concatenates PxLoader and all its plugins together, which means that it can't be used with an AMD or CommonJS script loader, as you can only export one module per file.

So, instead, use this RequireJS config:

require.config( {
    paths : {
        pxloader: '../bower_components/PxLoader/PxLoader',
        pxloaderimage:  '../bower_components/PxLoader/PxLoaderImage'
    }
} );

...and then require your dependencies like so:

define( [ 'pxloader', 'pxloaderimage' ], function( PxLoader, PxLoaderImage ) {
    // Use PxLoader and PxLoaderImage as usual
} );

Hope this helps!

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