Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Closed
sudodoki opened this Issue · 6 comments

3 participants

@sudodoki

There's an issue with r.js when using jsPDF. For more info, please read this comment: jrburke/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

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

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

@diegocr
Collaborator

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

@sudodoki

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

@mbenedettini

@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 jrburke/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 diegocr closed this in 82893ba
@diegocr
Collaborator

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.