Git Product home page Git Product logo

Comments (14)

zlovatt avatar zlovatt commented on July 18, 2024 4

Ran into this myself, and noticed that the line #s reported by the mapping was pretty much exactly 2x what it should be in the resulting post-include file.

Verdict: this is caused by the source file line endings being CRLF. As a result, every line # reference is counted twice.

Not sure how to fix this within gulp-include (@wiledal), but workarounds:

Example of the second below.

var gulp = require('gulp'),
	include = require('gulp-include'),
	sourcemaps = require('gulp-sourcemaps'),
	lec = require("gulp-line-ending-corrector");

gulp.task('preprocess', function () {
	return gulp.src('src/*.js')
		.pipe(lec())
		.pipe(gulp.dest('.temp'));
});

gulp.task('js', ['preprocess'], function() {
	return gulp.src('.temp/app.js')
		.pipe(sourcemaps.init())
		.pipe(include())
		.pipe(sourcemaps.write())
		.pipe(gulp.dest('js'));
});

from gulp-include.

outaTiME avatar outaTiME commented on July 18, 2024 3

any update with this feature? thanks !!!

from gulp-include.

rejhgadellaa avatar rejhgadellaa commented on July 18, 2024 1

+1

from gulp-include.

nicekiwi avatar nicekiwi commented on July 18, 2024

+1

from gulp-include.

jbh avatar jbh commented on July 18, 2024

+1

from gulp-include.

outaTiME avatar outaTiME commented on July 18, 2024

+1

from gulp-include.

chrisdivina avatar chrisdivina commented on July 18, 2024

+1

from gulp-include.

SnitchRUS66 avatar SnitchRUS66 commented on July 18, 2024

+1

from gulp-include.

gsouf avatar gsouf commented on July 18, 2024

+100

from gulp-include.

JoshuaSoileau avatar JoshuaSoileau commented on July 18, 2024

+1

from gulp-include.

skeddles avatar skeddles commented on July 18, 2024

+1

from gulp-include.

skeddles avatar skeddles commented on July 18, 2024

Now I get an error on one of my tasks when I use sourcemapping:

TypeError: resultMap.eachMapping is not a function
    at processInclude (/home/lospec/htdocs/node_modules/gulp-include/index.js:206:39)
    at include (/home/lospec/htdocs/node_modules/gulp-include/index.js:58:26)
    at wrappedMapper (/home/lospec/htdocs/node_modules/map-stream/index.js:83:19)
    at Stream.stream.write (/home/lospec/htdocs/node_modules/map-stream/index.js:95:21)
    at DestroyableTransform.ondata (/home/lospec/htdocs/node_modules/readable-stream/lib/_stream_readable.js:619:20)
    at DestroyableTransform.emit (events.js:188:13)
    at DestroyableTransform.EventEmitter.emit (domain.js:459:23)
    at addChunk (/home/lospec/htdocs/node_modules/readable-stream/lib/_stream_readable.js:291:12)
    at readableAddChunk (/home/lospec/htdocs/node_modules/readable-stream/lib/_stream_readable.js:278:11)
    at DestroyableTransform.Readable.push (/home/lospec/htdocs/node_modules/readable-stream/lib/_stream_readable.js:245:10)
[18:56:53] The following tasks did not complete: js
[18:56:53] Did you forget to signal async completion?

The error goes away and it compiles file if I comment out the sourcemapping parts:


gulp.task("js", function() {
	return gulp.src('scripts/*.js')
		//srcmap
		//.pipe(sourcemaps.init())
		//include other files
		.pipe(include({
			includePaths: [
				'modules/js',
				'modules/frontend',
				'scripts',
			]
		}))
			.on('error', console.log)
		//compress
		.pipe(liveOnly(uglify({compress: {drop_console: true }})))
			.on('error', function (err) { gutil.log(gutil.colors.red('[Error]'), err.toString()); })
		//srcmap
		//.pipe(sourcemaps.write('./maps'))
		//out
		.pipe(gulp.dest("public/javascripts"));
});

Perhaps it's because var resultMap = new SourceMapConsumer(result.map); seems to return a promise? I don't understand promises well enough to fix it unfortunately.

from gulp-include.

callaginn avatar callaginn commented on July 18, 2024

@skeddles Did you ever figure out this issue? Been running into this two years later, over and over again. And like you, if I comment out sourcemaps, it goes away:

TypeError: resultMap.eachMapping is not a function
    at processInclude (/Users/stephen/Sites/templates/twig-site/node_modules/gulp-include/index.js:206:39)
    at include (/Users/stephen/Sites/templates/twig-site/node_modules/gulp-include/index.js:58:26)
    at wrappedMapper (/Users/stephen/Sites/templates/twig-site/node_modules/map-stream/index.js:83:19)
    at Stream.stream.write (/Users/stephen/Sites/templates/twig-site/node_modules/map-stream/index.js:95:21)
    at DestroyableTransform.ondata (/Users/stephen/Sites/templates/twig-site/node_modules/readable-stream/lib/_stream_readable.js:619:20)
    at DestroyableTransform.emit (node:events:527:28)
    at DestroyableTransform.emit (node:domain:537:15)
    at addChunk (/Users/stephen/Sites/templates/twig-site/node_modules/readable-stream/lib/_stream_readable.js:291:12)
    at readableAddChunk (/Users/stephen/Sites/templates/twig-site/node_modules/readable-stream/lib/_stream_readable.js:278:11)
    at DestroyableTransform.Readable.push (/Users/stephen/Sites/templates/twig-site/node_modules/readable-stream/lib/_stream_readable.js:245:10)
[09:29:30] Finished 'scss' after 819 ms
[09:29:40] The following tasks did not complete: watch, <series>, <parallel>, js
[09:29:40] Did you forget to signal async completion?
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

And yeah, I've wondered the same thing about promises, since it mentions issues with async completion.

Here's my current init code:

function js() {
	return gulp.src(globs.build.js)
		.pipe(sourcemaps.init())
		.pipe(include(config.js)).on('error', console.log)
		.pipe(rename({suffix: '.min'}))
		.pipe(sourcemaps.write('.'))
		.pipe(gulp.dest(dist.js))
		.pipe(tap(file => alert.success(file)))
		.pipe(browsersync.stream());
};

from gulp-include.

skeddles avatar skeddles commented on July 18, 2024

unfortunately I resorted to just not using sourcemaps for js

from gulp-include.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.