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

Any of of 'requirejs' breaks build. #34

Open
shadowmint opened this issue Feb 2, 2016 · 4 comments
Open

Any of of 'requirejs' breaks build. #34

shadowmint opened this issue Feb 2, 2016 · 4 comments

Comments

@shadowmint
Copy link

If any other module uses the requirejs api after gulp-modernizr is imported, eg:

var requirejs = require('requirejs');
requirejs.optimize({
     mainConfigFile: config.js + '/bootstrap.js',
     out: 'app.js',
     name: 'foo'
}, function(err) {
  if (err) {
    console.log(err);
  }
  console.log("Done");
});

Or, for example, using https://github.com/jlouns/gulp-requirejs-optimize ...

Then the build will fail like this:

Looking for Modernizr references

>> 1 match in /Users/doug/dev/empty-coop/foo/static/build/stylesheets/_manifest.css
>> svg

>> 1 match in /Users/doug/dev/empty-coop/foo/static/build/stylesheets/styles-nomq.css
>> svg

>> 1 match in /Users/doug/dev/empty-coop/foo/static/build/stylesheets/styles.css
>> svg

>> Ready to build using these settings:
>>

Building your customized ModernizrGenerate in call: undefined
undefined
TAP version 13
not ok 1 - TypeError: generate is not a function
  ---
  at:
    line: 69
    column: 25
    file: node_modules/modernizr/lib/build.js
    function: build
  stack: >
    build (node_modules/modernizr/lib/build.js:69:25)

    Object.build (node_modules/modernizr/lib/build.js:162:50)

    Object.init (node_modules/customizr/src/builder.js:101:14)

    next (node_modules/promised-io/promise.js:584:17)

    notify (node_modules/promised-io/promise.js:201:22)

    notifyAll (node_modules/promised-io/promise.js:180:5)

    [object Object].Deferred.resolve.callback.emitSuccess
    (node_modules/promised-io/promise.js:223:3)

    [object Object]._onTimeout (node_modules/customizr/src/crawler.js:250:22)

  test: TAP
  message: 'TypeError: generate is not a function'
  source: |
    'modernizr-init': generate(config)
  ...
1..1
# failed 1 of 1 tests
# time=3426.104ms

This is because https://github.com/Modernizr/Modernizr/blob/master/lib/build.js#L154 fails to resolve anything, presumably because requirejs is initialized when the gulp-modernizr package is initially imported, and then somehow screwed up when something uses it.

I don't have any solution to this other than, 'Don't use anything that uses requirejs in your build', but I thought I'd report this here (even though technically the problem is in modernizr, not gulp-modernizr), so that frustrated folks could find it easily.

@cibulka
Copy link

cibulka commented Feb 23, 2016

Same issue here.

@shadowmint
Copy link
Author

@cibulka You can see the workaround we ended up using here https://github.com/hatchddigital/empty-coop/blob/master/gulp/tasks/scripts.js#L72

Basically using exec to invoke the external requirejs builder; but probably a better long term solution is just to stop using requirejs. :P

Anyhow, hope that helps.

@cibulka
Copy link

cibulka commented Feb 24, 2016

@shadowmint Thank you! After the pain I had with the setup of my Requirejs workflow, I think I will have to use it for a while :), so for now, I settled with using Modernizr directly from command line.

Thanks for the info, I'm definitely trying the workaround later!

@cibulka
Copy link

cibulka commented Feb 25, 2016

For now, I've resorted to use https://github.com/shinnn/modernizr-stream, so I can use Modernizr's command line along with my Gulp workflow. Maybe someone finds that useful ...

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

No branches or pull requests

2 participants