Skip to content

Any of of 'requirejs' breaks build. #34

@shadowmint

Description

@shadowmint

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions