-
Notifications
You must be signed in to change notification settings - Fork 67
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
Fatal error: Generate is not a function #163
Comments
Moved to grunt-modernizr since that is what you are using, Which version of grunt / grunt-modernizr are you using? |
(The failing modernizr build is unrelated) |
thanks @rejas im on version 1.0.3 |
Could you try the latest master branch of this repo where we updated all the dependencies? Just use "grunt-modernizr": "https://github.com/Modernizr/grunt-modernizr#master" in your package.json (and do a npm install) to try it out. Edited the wrong package name :-D |
(I dont have publishing rights on npm so the latest v2 cannot be published yet). Also: which node and grunt versions are you using? |
Hi @rejas still the same issue unfortunately... Grunt - 1.0.3 strangely it runs if only |
I just bumped customizr's modernizr dependency down to 3.6.0 and its now working again, seems theres an issue with modernizr 3.7.0 |
Hrmpf... Is your grunt file somewhere publicly visible for me to check out? And what tests are expected for it to be found? |
sure, see below. i suspect because modernizr is currently broken and its a dependency of customizr that its all bubbling up to that. var remapify = require('remapify');
var path = require('path');
module.exports = function (grunt) {
var scriptsPattern = ['patterns/**/*.js', 'components/**/*.js', 'assets/scripts/*.js'];
var scriptsPatternMain = ['patterns/**/*.main.js', 'components/**/*.main.js', 'assets/scripts/**/*.main.js'];
var stylesPattern = ['patterns/**/*.scss', 'components/**/*.scss', 'assets/styles/**/*.scss', '!**/*_scsslint_tmp*.scss'];
var sasslintIgnorePattern = ['!assets/styles/{vendor,mixins}/*.scss'];
var sasslintPattern = stylesPattern.concat(sasslintIgnorePattern);
var imagesPattern = ['assets/images/**/*'];
var fontsPattern = ['assets/fonts/**/*'];
var iconsPattern = ['assets/icons/**/*'];
var stylesPatternMain = ['./assets/styles/build.scss'];
var stylesPatternSecondary = ['./assets/styles/build-secondary.scss'];
var fontsPatternDist = ['./dist/fonts/**/*'];
var stylesPatternDist = ['./dist/styles/build.css'];
var stylesPatternSecondaryDist = ['./dist/styles/build-secondary.css'];
var scriptsPatternDist = ['./dist/scripts/build.js'];
var scriptsLibsPatternDist = ['./dist/scripts/libs/**/*.js'];
var svgPattern = ['assets/icons/svg/*.svg'];
grunt.config.init({
watch: {
options: {
cwd: './',
interval: 200,
spawn: false
},
fabric: {
files: ['package.json'],
tasks: ['version']
},
scripts: {
files: scriptsPattern,
tasks: ['scripts']
},
styles: {
files: stylesPattern,
tasks: ['styles']
},
fonts: {
files: fontsPattern,
tasks: ['copy:fonts']
},
images: {
files: imagesPattern,
tasks: ['copy:images']
},
icons: {
files: iconsPattern,
tasks: ['svg', 'copy:icons']
},
sasslint: {
files: sasslintPattern
},
jscs: {
files: scriptsPattern
}
},
sass: {
build: {
files: [
{ './dist/styles/build.css': stylesPatternMain },
{ './dist/styles/build-secondary.css': stylesPatternSecondary }
]
}
},
/*
Copy files to dist folder
*/
copy: {
fabric: {
files: [{
expand: true,
cwd: './assets/',
src: 'version.txt',
dest: './dist/'
}]
},
fonts: {
files: [{
expand: true,
cwd: './assets/fonts/',
src: '**/*',
dest: './dist/fonts/'
}]
},
images: {
files: [{
expand: true,
cwd: './assets/images/',
src: '**/*',
dest: './dist/images/'
}]
},
icons: {
files: [{
expand: true,
cwd: './assets/icons/',
src: '**/*',
dest: './dist/icons/'
}]
},
scripts: {
files: [{
expand: true,
cwd: './assets/scripts/libs/',
src: '**/*',
dest: './dist/scripts/libs/'
}]
},
data: {
files: [{
expand: true,
cwd: './assets/data/',
src: '**/*',
dest: './dist/data/'
}]
}
},
/*
Apply vendor prefixed properties to generated css using 'Can I use' db
*/
postcss: {
options: {
processors: [
require('autoprefixer')({ browsers: ['last 5 versions', 'ie 8', 'ie 9'] })
]
},
build: {
src: stylesPatternDist
},
buildSecondary: {
src: stylesPatternSecondaryDist
}
},
/*
Minify css - keep fonts and build seperate for now
*/
cssmin: {
options: {
keepSpecialComments: 0
},
dist: {
expand: true,
cwd: './dist/',
src: ['styles/*.css', 'fonts/**/*.css'],
dest: './dist/',
ext: '.css'
}
},
/*
Build JS bundle using requiresJS optimizer
*/
requirejs: {
dev: {
options: {
optimize: 'none',
mainConfigFile: 'config/require.config.js',
name: 'node_modules/almond/almond',
include: ['assets/scripts/build.main'],
insertRequire: ['assets/scripts/build.main'],
out: 'dist/scripts/build.js'
}
}
},
/*
Minify JS - only does the build file until a decision is made on browserify/RequireJS
*/
uglify: {
dist: {
files: {
'./dist/scripts/build.js': [scriptsPatternDist]
}
}
},
/*
Generate a modernizr build based on requirements
*/
modernizr: {
dist: {
'dest': './dist/scripts/modernizr.custom.js',
'parseFiles': true,
'customTests': [],
'tests': ['cssanimations', 'svg'],
'options': [
'setClasses',
'mq'
],
'uglify': false,
"files": {
"src": [scriptsPatternDist, stylesPatternDist]
},
}
},
/*
* JSCS Linting - for definition's see config and http://jscs.info/rules
*/
jscs: {
src: '{components,patterns}/**/assets/scripts/**.main.js',
options: {
config: 'config/.jscsrc',
esnext: true,
verbose: true,
fix: false,
force: true
}
},
/*
Quality check for SCSS
*/
sasslint: {
target: sasslintPattern,
options: {
configFile: 'config/.sass-lint.yml'
}
},
/*
SVG management
*/
svgstore: {
options: {
prefix: 'icon-',
cleanup: true,
cleanupdefs: true,
includeTitleElement: false,
svg: {
viewBox: '0 0 100 100',
xmlns: 'http://www.w3.org/2000/svg'
},
formatting: {
indent_size: 2
}
},
your_target: {
files: {
'assets/icons/svg/dist/defs.svg': [svgPattern]
}
}
}
});
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.registerTask('styles', [], function () {
grunt.loadNpmTasks('grunt-sass');
grunt.loadNpmTasks('grunt-postcss');
grunt.task.run('sass', 'postcss:build', 'postcss:buildSecondary');
});
grunt.registerTask('modernizr', [], function () {
grunt.loadNpmTasks("grunt-modernizr");
grunt.task.run('modernizr');
});
grunt.registerTask('scripts', [], function () {
grunt.loadNpmTasks('grunt-contrib-requirejs');
grunt.task.run('requirejs');
});
grunt.registerTask('dist', [], function () {
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-cssmin');
//TODO redo this sequence
grunt.task.run('styles', 'cssmin', 'scripts', 'modernizr', 'uglify', 'svg', 'version', 'copy');
});
grunt.registerTask('ie8', [], function () {
grunt.loadNpmTasks('grunt-stripmq');
grunt.task.run('stripmq');
});
grunt.registerTask('lintjs', [], function () {
grunt.loadNpmTasks('grunt-jscs');
grunt.task.run('jscs');
});
grunt.registerTask('lintscss', [], function () {
grunt.loadNpmTasks('grunt-sass-lint');
grunt.task.run('sasslint');
});
grunt.registerTask('lint', [], function () {
grunt.task.run('lintscss', 'lintjs');
});
grunt.registerTask('svg', [], function () {
grunt.loadNpmTasks('grunt-svgstore');
grunt.task.run('svgstore');
});
grunt.registerTask('version', [], function () {
version(grunt);
});
grunt.registerTask('default', [], function () {
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-contrib-cssmin');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.task.run('styles', 'cssmin', 'scripts', 'modernizr', 'svg', 'version', 'copy', 'watch');
});
/*
* With SCSS/JSCS linting enabled, we want to only check the currently changed file/s
*/
var changed_files = Object.create(null);
var onChange = grunt.util._.debounce(function (ext) {
if (ext === '.scss') {
var target = Object.keys(changed_files).concat(sasslintIgnorePattern);
grunt.config('sasslint.target', target);
grunt.task.run('lintscss');
}
if (ext === '.js') {
grunt.config('jscs.src', Object.keys(changed_files));
grunt.task.run('lintjs');
}
changed_files = Object.create(null);
}, 200);
grunt.event.on('watch', function (action, filepath) {
var ext = path.extname(filepath);
changed_files[filepath] = action;
onChange(ext);
});
};
/*
* Write a version file for Backend, states working project version.
*/
function version(grunt) {
var package = grunt.file.readJSON('package.json');
var version = package.version;
var project = package.name;
var filePath = './assets/version.txt';
grunt.log.writeln('Version: ' + project.cyan + ' @ ' + version.magenta);
grunt.log.oklns('Logged to file: ' + filePath.cyan);
grunt.file.write(filePath, version);
}
/*
set up aliases used in build process
*/
function preBrowserifyBundle(b) {
b.plugin(remapify, [
{
cwd: './assets/scripts/',
src: '**/*.js',
expose: 'build'
},
{
cwd: './components/',
src: '**/*.main.js',
expose: 'component'
},
{
cwd: './patterns/',
src: '**/*.main.js',
expose: 'pattern'
}
]);
} |
I am a little baffled now... Tried out grunt-config on my project and it worked fine with this dependencies:
and this config
What also is weird is that your config says But really weird is that nowhere in Modernizr or customizr (the middleware between) there is a function or call by the name of As for the broken builds of Modrnizr in travis: That has something to do with travis as I already said. The tests run fine on my windows machine locally and Modernizr is sucessfully build and used in gulp-modernizr. |
its only different as i was trying to test why it was breaking... so uglify was turned off just incase :) I created a fork and dropped the customizr dependancy to 1.0.0 and it seems to be working as expected. have you tried nuking your npm cache etc then try a fresh install? my local build was fine until i did this. its also worth noting that the modernizr task alone works fine, its when its in a pipeline of other tasks it fails. if i remove grunt-modernizr from the pipeline it works as expected as does using the forked version :( have you done any changes in the past day? theres a excerpt below: function build(generate, generateBanner, pkg) {
return function build(config, cb) {
var requireConfig = {};
var banner;
config = config || {};
cb = cb || function noop() {};
_extend(requireConfig, baseRequireConfig);
requireConfig.rawText = {
'modernizr-init': generate(config)
}; |
You're right, there is indeed that one generate call (I can only say as an excuse that i am a little under the weather these days). |
@rejas no worries, thank you for your assistance so far! im just highlighting my findings, to help hopefully find the issue. I will try with v1.1.0 and feedback. |
@rejas customizr 1.1.0 also works as expected. |
@jamie-l-robertson next try: coudl you rename your task from modenrizr to something else since grunt.modernizr itself defines a "mnodernizr"-grunt task? (a shot in the dark sicne I dont know if grunt has a problem with that .... |
@rejas will give that try and feedback, will be this evening before i get time though. only difference i can see is 1.1.0 uses Modernizr 3.6.0 too. |
was there any updates on this? |
@shayneoneill ended up forking and downgrading version. Works fine. |
@jamie-l-robertson so renaming the task didnt help to solve your problem? |
Unfortunately not... will try give it another look. |
I have the same error "Building your customized ModernizrFatal error: generate is not a function". package.json: bower.json: |
hi @devprojectsapps unfortunatly I cannot help you with these old and outdated versions of grunt-modernizr and modernizr. Is upgrading to v2 of grunt-modernizr (and therefor v3 of modernizr too) an option for you? |
Hi @rejas . If i update modernizr and grunt-modernizr to actual version i got the same error :-(. |
mhhh.... what node version are you using? |
I am using node -v: Hmmm is it maybe the thing that i have to change this block: modernizr: { to modernizr: { |
Narrows this down to build.js in modernizr/libs... it seems these 3 required modules arent resolving for some reason:
if i do a npm i within the modernizr directory, it fixes it. any ideas? |
ok... so we are using 'grunt-contrib-requirejs' which runs before 'grunt-modernizr'. it seems to be conflicting, once we changed the order they are ran it works fine with the latest version. will test further. |
Good luck folks, I'm unsubbing from this as I don't work anymore in the job where this stack was an issue. I sort of managed to solve this by not havign modnernizr work as a step in watch. Its not clear at all why it needed to be part of that particular cycle. Devs: Thankyou for your work, its an awesome project. |
Ok this "Building your customized ModernizrFatal error: generate is not a function" happens if i update the npm grunt-modernizr package to actual version 2.1.1 . |
thanks for the infos. could you try out @devprojectsapps which version breaks the build? so if 0.4.0 works but not 2.1.1 which one still works and which starts to show the error? |
@rejas "Running "modernizr:uglify" (modernizr) task So from version 0.5.0 its not working with my configuration :-( My configuration in Gruntfile for modernizr is |
Oh, thats a different error... Could you try the fix from above: 'ok... so we are using 'grunt-contrib-requirejs' which runs before 'grunt-modernizr'. it seems to be conflicting, once we changed the order they are ran it works fine with the latest version. will test further.' if that helps? To be honest, with grunt and its plugins being more or less in maintainance mode I cannot devote much of my spare time in debugging this :-( |
Ok it runs threw that is good. Thats the out if i use command grunt modernizr in my old version: Running "modernizr" task Enabled Extras
Looking for Modernizr references Downloading source files
Done, without errors. In my new version it is: Running "modernizr:dist" (modernizr) task Looking for Modernizr references
Building your customized Modernizr...OK Done. You see the difference? Thats really strange, because the config of modernizr is the same. |
sorry @devprojectsapps for the delay was traveling. can you post your grunt config where you configure grunt-modernizr? |
Thanks for your answer @rejas In the old versions in the modernizr task a vendor file is copied in the www/js/vendor path. |
This issue only started a day ago, when running grunt-modernizr im getting
Fatal error: Generate is not a function
at the Building your customized Modernizr stage. Looks like Modernizr is failing to build - https://travis-ci.org/Modernizr/ModernizrThis is on a clean install of grunt-modernizr and therefor Modernizr too, i can take a previous install and it works.
any help would be appreciated.
Screenshot of the error.
The text was updated successfully, but these errors were encountered: