almond integration #3

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

Comments

Projects
None yet
2 participants
@jzaefferer
Contributor

jzaefferer commented May 21, 2012

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

This comment has been minimized.

Show comment
Hide comment
@asciidisco

asciidisco May 21, 2012

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.

Owner

asciidisco commented May 21, 2012

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

This comment has been minimized.

Show comment
Hide comment
@jzaefferer

jzaefferer May 21, 2012

Contributor

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

Contributor

jzaefferer commented May 21, 2012

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

@asciidisco

This comment has been minimized.

Show comment
Hide comment
@asciidisco

asciidisco May 21, 2012

Owner

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

Owner

asciidisco commented May 21, 2012

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

@asciidisco asciidisco reopened this May 21, 2012

@asciidisco

This comment has been minimized.

Show comment
Hide comment
@asciidisco

asciidisco May 21, 2012

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.

Owner

asciidisco commented May 21, 2012

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

This comment has been minimized.

Show comment
Hide comment
@jzaefferer

jzaefferer May 21, 2012

Contributor

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.

Contributor

jzaefferer commented May 21, 2012

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

This comment has been minimized.

Show comment
Hide comment
@asciidisco

asciidisco May 21, 2012

Owner

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

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

Owner

asciidisco commented May 21, 2012

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

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

@jzaefferer

This comment has been minimized.

Show comment
Hide comment
@jzaefferer

jzaefferer May 21, 2012

Contributor

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

Contributor

jzaefferer commented May 21, 2012

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

@asciidisco

This comment has been minimized.

Show comment
Hide comment
@asciidisco

asciidisco May 21, 2012

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.

Owner

asciidisco commented May 21, 2012

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.

@asciidisco asciidisco closed this May 21, 2012

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