klei / gulp-inject

A javascript, stylesheet and webcomponent injection plugin for Gulp
MIT License
811 stars 93 forks source link

Gulp4 - Maximum Call Stack Exceeded #207

Open nathanminarik opened 8 years ago

nathanminarik commented 8 years ago

I've been getting some errors with gulp-inject when using Gulp 4. It's saying that the maximum call stack is being exceeded which leads me to believe some function is calling itself infinitely.

My code is the following:

gulp.task('html', html);

gulp.task('dev', gulp.series(gulp.parallel('dev:scripts', 'dev:styles'), 'html'));

function html () {
    const target = gulp.src('./src/index.html');
    // It's not necessary to read the files (will speed up things), we're only after their paths:
    const sources = gulp.src(['./src/**/*.js', './src/**/*.css'], {read: false});

    return target.pipe(inject(sources))
    .pipe(gulp.dest('./public'));
}

which is rendering the following in the command line:

[10:04:57] Starting 'html'...
[10:05:01] 'html' errored after 3.79 s
[10:05:01] RangeError: Maximum call stack size exceeded
    at String.replace (native)
    at globUnescape (/Users/nathanaelminarik/projects/one-offs/ahrq-search/node_modules/minimatch/minimatch.js:918:12)
    at Minimatch.parse (/Users/nathanaelminarik/projects/one-offs/ahrq-search/node_modules/minimatch/minimatch.js:617:12)
    at Array.map (native)
    at Minimatch.<anonymous> (/Users/nathanaelminarik/projects/one-offs/ahrq-search/node_modules/minimatch/minimatch.js:182:14)
    at Array.map (native)
    at Minimatch.make (/Users/nathanaelminarik/projects/one-offs/ahrq-search/node_modules/minimatch/minimatch.js:181:13)
    at new Minimatch (/Users/nathanaelminarik/projects/one-offs/ahrq-search/node_modules/minimatch/minimatch.js:136:8)
    at setopts (/Users/nathanaelminarik/projects/one-offs/ahrq-search/node_modules/glob/common.js:112:20)
    at new Glob (/Users/nathanaelminarik/projects/one-offs/ahrq-search/node_modules/glob/glob.js:117:3)

This is my package.json file

  "devDependencies": {
    "babel-preset-es2015": "^6.14.0",
    "gulp": "github:gulpjs/gulp#4.0",
    "gulp-autoprefixer": "^3.1.1",
    "gulp-babel": "^6.1.2",
    "gulp-concat": "^2.6.0",
    "gulp-inject": "^4.1.0",
    "gulp-livereload": "^3.8.1",
    "gulp-load-plugins": "^1.3.0",
    "gulp-minify-css": "^1.2.4",
    "gulp-sass": "^2.3.2",
    "gulp-sourcemaps": "^1.6.0",
    "gulp-uglify": "^2.0.0",
    "pump": "^1.0.1",
    "require-dir": "^0.3.0"
  }

Thanks in advance! I've been struggling with this the past day.

ansballard commented 7 years ago

About how many files are you pulling back with those globs? I'm reimplementing with gulp4 at the moment and I haven't run into this so far, but I don't inject more than a few files per call.

ghidello commented 7 years ago

I got the same error then I realized that I didn't put import inject from "gulp-inject"; at the beginning of the file so some other inject function was used. Facepalm!

rejas commented 6 years ago

Is this still an issue with the latest release for you @nathanminarik ? Or did you move on and we can close this issue?

plateniteshow commented 5 years ago

I got the same error then I realized that I didn't put import inject from "gulp-inject"; at the beginning of the file so some other inject function was used. Facepalm!

Can't believe this happened to me. Thank you.