Comments (14)
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:
- change all of your files to use LF instead of CRLF, and it'll work as expected
- Use something to preprocess your sources, like gulp-line-ending-corrector (https://www.npmjs.com/package/gulp-line-ending-corrector)
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.
any update with this feature? thanks !!!
from gulp-include.
+1
from gulp-include.
+1
from gulp-include.
+1
from gulp-include.
+1
from gulp-include.
+1
from gulp-include.
+1
from gulp-include.
+100
from gulp-include.
+1
from gulp-include.
+1
from gulp-include.
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.
@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.
unfortunately I resorted to just not using sourcemaps for js
from gulp-include.
Related Issues (20)
- Ability to control syntax HOT 2
- Error preventing run HOT 2
- Pre and post processing
- Variables not scoped properly HOT 3
- gulp-include and eslint and proper line numbers? HOT 1
- processInclude processes output file indefinitely (or until the stack explodes) HOT 1
- Require Behaviour HOT 2
- Compile before include
- Gulp include breaks the code on windows system HOT 1
- Add "include-if-exists" functionality
- how do I to insert file conten inside quotation marks? HOT 2
- Replace deprecated dependency gulp-util HOT 1
- Independent require in several files HOT 5
- Possibly remove/lock event-stream HOT 1
- gulp-util removal request HOT 2
- Anyone know of a good alternative? HOT 13
- When multiple files are matched, it includes both of them. HOT 7
- TypeError: resultMap.eachMapping is not a function HOT 5
- Question about src/js/main.js
- Any way to use sourcemaps and minification of files?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from gulp-include.