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

Compiled build not running #44

Open
mhluska opened this issue Dec 17, 2012 · 4 comments
Open

Compiled build not running #44

mhluska opened this issue Dec 17, 2012 · 4 comments
Assignees
Labels
Milestone

Comments

@mhluska
Copy link

mhluska commented Dec 17, 2012

I recently updated grunt-requirejs via NPM and my compiled JavaScript no longer runs. The main file loads but the callback passed to define is not executed. However, everything works fine when I don't compile and just load the modules dynamically. I've created a test project so you can hopefully reproduce the error.

Here's the compiled file found in build/js after running $ grunt

My directory structure:

node_modules
test.html
grunt.js
src/
src/js
src/js/test.js

Contents of test.js:

// Generated by CoffeeScript 1.4.0

define(function() {
  return console.log('loaded');
});

Contents of grunt.js:

// Generated by CoffeeScript 1.4.0

module.exports = function(grunt) {
  grunt.loadNpmTasks('grunt-requirejs');
  grunt.initConfig({
    requirejs: {
      compile: {
        options: {
          almond: true,
          modules: [
            {
              name: 'test'
            }
          ],
          dir: 'build',
          appDir: 'src',
          baseUrl: 'js',
          optimize: 'none'
        }
      }
    }
  });
  return grunt.registerTask('default', 'requirejs');
};

Contents of test.html:

<!DOCTYPE html>
<html>
    <head>
        <meta charset="UTF-8" />
        <title>Test</title>
        <script src="build/js/test.js"></script>
    </head>
    <body>
    </body>
</html>

Versions:

$ grunt -version
grunt v0.3.17

$ npm view grunt-requirejs version
0.3.1
@asciidisco
Copy link
Owner

First of all, thanks for your detailed bug description, if everyone would do that, debugging would be so much easier :)
I think I know the problem, but I don´t have much time to adress this today.
I will try to release version 0.3.2 tomorrow which will contain a fix (hopefully) ;)

Thanks for your patience.
Regards
Sebastian

@ghost ghost assigned asciidisco Dec 17, 2012
@mhluska
Copy link
Author

mhluska commented Dec 25, 2012

Hi Sebastian,

If I manually insert require('test') at the end of build/js/test.js everything loads fine. RequireJS actually supports this feature with the insertRequire option. It doesn't seem to do anything when I use it in my Gruntfile though.

@svnlto
Copy link
Contributor

svnlto commented Feb 17, 2013

@asciidisco @mhluska is correct, it's todo with the insertRequire option. Just bumped into the same issue and adding the trigger has fixed it.

@asciidisco
Copy link
Owner

Fortunately I have some time to look into this issue today & tomorrow, after a long time where I didn't had any time at all for OS projects. Thanks for your patience & your error descriptions, will try my best to fix it.

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

3 participants