Skip to content
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

Missing "file" property result source map (gulp-babel-minify) #862

Closed
egasato opened this issue May 22, 2018 · 1 comment
Closed

Missing "file" property result source map (gulp-babel-minify) #862

egasato opened this issue May 22, 2018 · 1 comment

Comments

@egasato
Copy link
Contributor

egasato commented May 22, 2018

The pipe crashes when the "file" property is missing in the "result" variable.

To Reproduce
My gulpfile.js serves as an example.

gulp.task("babel:server", function(_done) {
	return gulp.src("lib/*.mjs")
		.pipe(plugins.plumber(function(err) {
			log.error(err);
			this.emit("end");
		}))
		.pipe(plugins.sourcemaps.init())
		.pipe(plugins.babelMinify())
		.pipe(plugins.sourcemaps.write("."))
		.pipe(gulp.dest("build"));
});

Actual Output

I simply run gulp babel:server and this is what happens:

[14:34:36] Using gulpfile /run/media/esau/Shared/Universidad/PTI/Weether/iot-station/gulpfile.js
[14:34:36] Starting 'babel:server'...
/run/media/esau/Shared/Universidad/PTI/Weether/iot-station/node_modules/vinyl-sourcemaps-apply/index.js:37
    throw e;
    ^

Error: Source map to be applied is missing the "file" property
    at assertProperty (/run/media/esau/Shared/Universidad/PTI/Weether/iot-station/node_modules/vinyl-sourcemaps-apply/index.js:36:13)
    at applySourceMap (/run/media/esau/Shared/Universidad/PTI/Weether/iot-station/node_modules/vinyl-sourcemaps-apply/index.js:15:3)
    at DestroyableTransform._transform (/run/media/esau/Shared/Universidad/PTI/Weether/iot-station/node_modules/gulp-babel-minify/lib/index.js:75:9)
    at DestroyableTransform.Transform._read (/run/media/esau/Shared/Universidad/PTI/Weether/iot-station/node_modules/readable-stream/lib/_stream_transform.js:184:10)
    at DestroyableTransform.Transform._write (/run/media/esau/Shared/Universidad/PTI/Weether/iot-station/node_modules/readable-stream/lib/_stream_transform.js:172:83)
    at doWrite (/run/media/esau/Shared/Universidad/PTI/Weether/iot-station/node_modules/readable-stream/lib/_stream_writable.js:428:64)
    at writeOrBuffer (/run/media/esau/Shared/Universidad/PTI/Weether/iot-station/node_modules/readable-stream/lib/_stream_writable.js:417:5)
    at DestroyableTransform.Writable.write (/run/media/esau/Shared/Universidad/PTI/Weether/iot-station/node_modules/readable-stream/lib/_stream_writable.js:334:11)
    at DestroyableTransform.ondata (/run/media/esau/Shared/Universidad/PTI/Weether/iot-station/node_modules/readable-stream/lib/_stream_readable.js:619:20)
    at DestroyableTransform.emit (events.js:182:13)

Expected Output

Adding a simple condition fixing this bug leads to a successful task.

[14:35:55] Using gulpfile /run/media/esau/Shared/Universidad/PTI/Weether/iot-station/gulpfile.js
[14:35:55] Starting 'babel:server'...
[14:35:56] Finished 'babel:server' after 955 ms
[14:35:56] Starting 'babel'...
[14:35:56] Finished 'babel' after 16 μs

Stack Trace

It's in the Actual Output section.

Configuration

How are you using babel-minify?

gulp-babel-minify

babel-minify version: 0.4.3

babel version : 6.26.0

babel-minify-config: the default configuration.

babelrc:

{
  presets: ["env"]
}

Possible solution

Update the applySourceMap call with this code [lines 65-57]:

if (file.sourceMap) {
    if (!result.map.hasOwnProperty("file")) {
        result.map.file = file.sourceMap.file;
    }
    applySourceMap(file, result.map);
}

Additional context

Nothing to add here.

boopathi pushed a commit that referenced this issue May 22, 2018
* Fix issue #862

The following changes were applied:

  - Added a condition where the property "file" is checked. If it
    doesn't exist it is copied from the original source file.

* Fix indentation typo

* Fix index.js with 'yarn lint --fix'
@boopathi
Copy link
Member

Closed in #863 ...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants