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

almond integration #3

Closed
jzaefferer opened this issue May 21, 2012 · 8 comments
Closed

almond integration #3

jzaefferer opened this issue May 21, 2012 · 8 comments

Comments

@jzaefferer
Copy link
Contributor

This is more of a support request then a bug report. I've got pretty far along, though can't get the almond integration working.

My config looks like this:

requirejs: {
    almond: true,
    replaceRequireScript: [{
        files: ['index.html'],
        module: '/js/main-built'
    }],
    baseUrl: "js",
    paths: {
        'hbs': 'libs/hbs',
        'Handlebars': 'libs/Handlebars',
        'Backbone': 'libs/backbone',
        'underscore': 'libs/underscore',
        'bootstrap': 'libs/bootstrap',
        'json2': 'libs/json2',
        'Rickshaw': 'libs/rickshaw',
        'validate': 'libs/jquery.validate'
    },
    hbs: {
        templateExtension : 'hbs',
        stylesDir : '/static/css/',
        disableI18n: true
    },
    modules: [{name: 'main'}],
    out: "js/main-built.js"
}

There are multiple issues:

  • replaceRequireScript with almond:true has no effect, even though it would still be useful in this setup
  • the module property of items in the replaceRequireScript array is ignored, though I'd like that to be used for the src-attribute in tasks/require.js:146
  • Once the above works, I end up with a main-built.js. When loading that, I get a script error about window.require being undefined. My main.js calls require. If I change that to use define, I don't get an error, but nothing is executed.

So close...

@asciidisco
Copy link
Owner

Mhh,

could you try to replace the "module" property in the "replaceRequireScript" property with the name of the main module?!

Yours:

    replaceRequireScript: [{
        files: ['index.html'],
        module: '/js/main-built'
    }]

How i think that it should look like:

    replaceRequireScript: [{
        files: ['index.html'],
        module: 'main'
    }]

Please tell me if that helped.
Else i will look deeper into that issue ;)

Regards.

@jzaefferer
Copy link
Contributor Author

That doesn't help. Currently that property is ignored, only the files property is used.

@asciidisco
Copy link
Owner

Ahh, got it.
Lets see if i can fix this within the next hour ;)
Hold on...

@asciidisco
Copy link
Owner

You are now able to add a 'modulePath' configuration setting to your replaceRequireScript config.
I´ve also added this to the README, that´s something you have to do, when specifying the 'out' property.

Hopefully that helps:

    replaceRequireScript: [{
        files: ['index.html'],
        module: 'main',
        modulePath: '/js/main-built'
    }]

I don´t know if we get rid off all your issues, but this might be a step towards.
I tested it roughly with a configuration similar to yours.

@jzaefferer
Copy link
Contributor Author

That fixes the almond aspect, but I still have the other problem mentioned above:

  • Once the above works, I end up with a main-built.js. When loading that, I get a script error about window.require being undefined. My main.js calls require. If I change that to use define, I don't get an error, but nothing is executed.

Actually require exists, but isn't a function. No idea yet why that isn't working.

@asciidisco
Copy link
Owner

Just a guess,
have you tried to wrap your generated file like shown here:

https://github.com/jrburke/almond#usage

@jzaefferer
Copy link
Contributor Author

That works! Dunno why, but that's okay. Maybe add wrap:true to the example in the readme?

@asciidisco
Copy link
Owner

Yeah, snd. time a hear from someone using the plugin successfully :D

I don´t know why, in my configuration, if i add wrap=true, i get some weird errors.
Maybe it´s about the layout of my main.js module file...

Nevertheless,
i added some info to the readme about the wrap issue,
closing this one here.

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

No branches or pull requests

2 participants