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

r.js error - Mismatched anonymous define() module: function () #289

Closed
sudodoki opened this issue Jun 24, 2014 · 9 comments
Closed

r.js error - Mismatched anonymous define() module: function () #289

sudodoki opened this issue Jun 24, 2014 · 9 comments
Labels

Comments

@sudodoki
Copy link

There's an issue with r.js when using jsPDF. For more info, please read this comment: requirejs/r.js#558 (comment)
As I can tell, the

r.js found multiple anonymous defines and skipped naming one of the define()s. This could also be bug

Is an issue, because you have https://github.com/MrRio/jsPDF/blob/master/dist/jspdf.debug.js#L1703-L1705, https://github.com/MrRio/jsPDF/blob/master/dist/jspdf.debug.js#L5673-L5675
https://github.com/MrRio/jsPDF/blob/master/dist/jspdf.debug.js#L5688

Assume that's an issue caused by build setup you're using.

@mbenedettini
Copy link

I have the same problem. As a workaround I'm defining jspdf modules separately:

    shim: {
        'jsPDF-addImage': {
            deps: ['jsPDF-core']
        } 
   },

paths: {
        'jsPDF-core': '../bower_components/jsPDF/jspdf',
        'jsPDF-addImage': '../bower_components/jsPDF/jspdf.plugin.addimage',
        'jsPDF': 'lib/jspdf'
}

And in lib/jspdf.js:

'use strict';
/* Meta module to have the whole jspdf library available at once,
 * just by requiring this module. */

define(function(require) {
    var jsPDF = require('jsPDF-core'),
        addImage = require('jsPDF-addImage');

    return jsPDF;
});

With this configuration, requiring 'jsPDF' is enough. I'm even using almond and works fine.

I'm still trying to find a workaround to the fact that bower will not install the whole repository, thanks to the "ignore" section of bower.json

@mbenedettini
Copy link

I've opened an issue in r.js asking which would be the best solution requirejs/r.js#699

@diegocr
Copy link
Collaborator

diegocr commented Jun 25, 2014

With RequireJS it is needed to use the minimized version, as pointed in #122

@sudodoki
Copy link
Author

Minimized version wouldn't help, in fact, I encountered issue there first. Presence of multiple anonymous defines are not affected by minification.

@mbenedettini
Copy link

@diegocr This happens with both debug and minified version. Using RequireJS was partially addressed in #122 . However, this problem arises when building an optimized version of an application that uses jsPDF.

There should be a single anonymous define() in each file, see requirejs/almond#80 (comment) .

For me it would be just fine to remove "jspdf.js" and "jspdf.plugin.*" from the ignore section of bower.json. This allows jspdf modules to be required separately as I previously described in this same issue.

@diegocr
Copy link
Collaborator

diegocr commented Jun 25, 2014

Right guys, while #122 fixed a conflict with adler32, i missed there's another conflict with FileSaver.js

Commit 82893ba should fix that, i'll check some PRs before building new dist files.

@diegocr diegocr added the Fixed label Jun 28, 2014
@martynchamberlin
Copy link

I'm still getting this error on the latest version of jsPDF.

@VaelVictus
Copy link

Getting this error by merely including the file as follows on a mostly blank page:
script src="scripts/jsPDF-master/dist/jspdf.debug.js"></script

"Error: Mismatched anonymous define() module: function" which seems to be from RequireJS. It does not happen when I include jspdf.min.js in the same way.

@adumat
Copy link

adumat commented Jan 19, 2016

+1, i've same problem with last version.
on same page i have jspdf and d3.layout.cloud, on d3.layout.cloud parsing i've same error reported by @VaelVictus

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

No branches or pull requests

6 participants