From a5cc0494553633b6389b5f2e563fd52d08500df3 Mon Sep 17 00:00:00 2001 From: unicodesnowman Date: Tue, 14 Nov 2017 15:14:08 -0500 Subject: [PATCH] Fix StitchError stack traces in node * Add `babel-plugin-transform-builtin-extend` * Subclassing builtin types needs special treatment by babel * Without this plugin, in a node environment, a subclass of Error does not actually behave like a true subclass, which manifests itself via a missing stacktrace when a StitchError is thrown More details [here](https://github.com/babel/babel/issues/3083) --- .babelrc | 5 +++-- package.json | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/.babelrc b/.babelrc index 51b976081..40389b5de 100644 --- a/.babelrc +++ b/.babelrc @@ -6,11 +6,12 @@ "node": "6" }, "useBuiltins": "usage", - }] + }], ], "plugins": [ "transform-async-to-generator", "babel-plugin-add-module-exports", - "version-transform" + "version-transform", + ["babel-plugin-transform-builtin-extend", { globals: ["Error"] }] ] } diff --git a/package.json b/package.json index a44367948..78b87c8ad 100644 --- a/package.json +++ b/package.json @@ -40,6 +40,7 @@ "babel-loader": "^7.0.0", "babel-plugin-add-module-exports": "^0.2.1", "babel-plugin-transform-async-to-generator": "^6.24.1", + "babel-plugin-transform-builtin-extend": "^1.1.2", "babel-preset-env": "^1.6.1", "conventional-changelog-cli": "^1.3.1", "eslint": "^3.19.0",