From e7d150b332ec36a5122d3d200aa8fc591ae52a67 Mon Sep 17 00:00:00 2001 From: Nicolas Morel Date: Mon, 29 Aug 2016 18:33:55 +0200 Subject: [PATCH 1/2] Ignore sourcemaps names --- lib/fromStringWithSourceMap.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/fromStringWithSourceMap.js b/lib/fromStringWithSourceMap.js index cbddf99..0619db7 100644 --- a/lib/fromStringWithSourceMap.js +++ b/lib/fromStringWithSourceMap.js @@ -62,8 +62,9 @@ module.exports = function fromStringWithSourceMap(code, map) { var linePosition = currentLine; } - if(mapping.rest && mapping.rest[0] === ",") { - mapping.rest = mapping.rest.substr(1); + if(mapping.rest) { + var next = mapping.rest.indexOf(","); + mapping.rest = next === -1 ? "" : mapping.rest.substr(next); } if(!ignore) { From 855b4f635d51b6a4b803e290a3e1a283642f3b96 Mon Sep 17 00:00:00 2001 From: Joe Haddad Date: Thu, 1 Dec 2016 18:00:35 -0500 Subject: [PATCH 2/2] Add test case for stripping babel names ref: https://github.com/babel/babel/pull/3658 --- test/fixtures/from-to-tests/babel2-source.js | 6 ++ .../from-to-tests/babel2.expected.map | 13 +++ .../from-to-tests/babel2.generated.js | 84 +++++++++++++++++++ test/fixtures/from-to-tests/babel2.input.map | 1 + 4 files changed, 104 insertions(+) create mode 100644 test/fixtures/from-to-tests/babel2-source.js create mode 100644 test/fixtures/from-to-tests/babel2.expected.map create mode 100644 test/fixtures/from-to-tests/babel2.generated.js create mode 100644 test/fixtures/from-to-tests/babel2.input.map diff --git a/test/fixtures/from-to-tests/babel2-source.js b/test/fixtures/from-to-tests/babel2-source.js new file mode 100644 index 0000000..9b0296f --- /dev/null +++ b/test/fixtures/from-to-tests/babel2-source.js @@ -0,0 +1,6 @@ +class Test { + foo() { + console.log('bar') + throw new Error('bar') + } +} diff --git a/test/fixtures/from-to-tests/babel2.expected.map b/test/fixtures/from-to-tests/babel2.expected.map new file mode 100644 index 0000000..c8e8be5 --- /dev/null +++ b/test/fixtures/from-to-tests/babel2.expected.map @@ -0,0 +1,13 @@ +{ + "version": 3, + "file": "babel2.generated.js", + "sources": [ + "webpack:///webpack/bootstrap b1bcc793378011ad1abd", + "webpack:///./packages/react-scripts/template/src/index.js" + ], + "sourcesContent": [ + " \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap b1bcc793378011ad1abd\n **/", + "class Test {\n foo() {\n console.log('bar')\n throw new Error('bar')\n }\n}\n\n\n\n/** WEBPACK FOOTER **\n ** ./packages/react-scripts/template/src/index.js\n **/" + ], + "mappings": ";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA;AACA;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;ACtCA;;;;;;;AACA;AACA;AACA;AACA;;;;;;;;;" +} diff --git a/test/fixtures/from-to-tests/babel2.generated.js b/test/fixtures/from-to-tests/babel2.generated.js new file mode 100644 index 0000000..102b26c --- /dev/null +++ b/test/fixtures/from-to-tests/babel2.generated.js @@ -0,0 +1,84 @@ +/******/ (function(modules) { // webpackBootstrap +/******/ // The module cache +/******/ var installedModules = {}; +/******/ +/******/ // The require function +/******/ function __webpack_require__(moduleId) { +/******/ +/******/ // Check if module is in cache +/******/ if(installedModules[moduleId]) +/******/ return installedModules[moduleId].exports; +/******/ +/******/ // Create a new module (and put it into the cache) +/******/ var module = installedModules[moduleId] = { +/******/ exports: {}, +/******/ id: moduleId, +/******/ loaded: false +/******/ }; +/******/ +/******/ // Execute the module function +/******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__); +/******/ +/******/ // Flag the module as loaded +/******/ module.loaded = true; +/******/ +/******/ // Return the exports of the module +/******/ return module.exports; +/******/ } +/******/ +/******/ +/******/ // expose the modules object (__webpack_modules__) +/******/ __webpack_require__.m = modules; +/******/ +/******/ // expose the module cache +/******/ __webpack_require__.c = installedModules; +/******/ +/******/ // __webpack_public_path__ +/******/ __webpack_require__.p = "/"; +/******/ +/******/ // Load entry module and return exports +/******/ return __webpack_require__(0); +/******/ }) +/************************************************************************/ +/******/ ([ +/* 0 */ +/*!******************!*\ + !*** multi main ***! + \******************/ +/***/ function(module, exports, __webpack_require__) { + + module.exports = __webpack_require__(/*! /Users/joe/Documents/Development/create-react-app/packages/react-scripts/template/src/index.js */1); + + +/***/ }, +/* 1 */ +/*!******************************************************!*\ + !*** ./packages/react-scripts/template/src/index.js ***! + \******************************************************/ +/***/ function(module, exports) { + + 'use strict'; + + var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }(); + + function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } + + var Test = function () { + function Test() { + _classCallCheck(this, Test); + } + + _createClass(Test, [{ + key: 'foo', + value: function foo() { + console.log('bar'); + throw new Error('bar'); + } + }]); + + return Test; + }(); + +/***/ } +/******/ ]); +//# sourceMappingURL=bundle.js.map diff --git a/test/fixtures/from-to-tests/babel2.input.map b/test/fixtures/from-to-tests/babel2.input.map new file mode 100644 index 0000000..c0ccfa8 --- /dev/null +++ b/test/fixtures/from-to-tests/babel2.input.map @@ -0,0 +1 @@ +{"version":3,"sources":["webpack:///webpack/bootstrap b1bcc793378011ad1abd","webpack:///./packages/react-scripts/template/src/index.js"],"names":["Test","console","log","Error"],"mappings":";AAAA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;AAEA;AACA;AACA,uBAAe;AACf;AACA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;AACA;;;AAGA;AACA;;AAEA;AACA;;AAEA;AACA;;AAEA;AACA;;;;;;;;;;;;;;;;;;;;;;;;;;KCtCMA,I;;;;;;;2BACE;AACJC,eAAQC,GAAR,CAAY,KAAZ;AACA,aAAM,IAAIC,KAAJ,CAAU,KAAV,CAAN;AACD","file":"babel2.generated.js","sourcesContent":[" \t// The module cache\n \tvar installedModules = {};\n\n \t// The require function\n \tfunction __webpack_require__(moduleId) {\n\n \t\t// Check if module is in cache\n \t\tif(installedModules[moduleId])\n \t\t\treturn installedModules[moduleId].exports;\n\n \t\t// Create a new module (and put it into the cache)\n \t\tvar module = installedModules[moduleId] = {\n \t\t\texports: {},\n \t\t\tid: moduleId,\n \t\t\tloaded: false\n \t\t};\n\n \t\t// Execute the module function\n \t\tmodules[moduleId].call(module.exports, module, module.exports, __webpack_require__);\n\n \t\t// Flag the module as loaded\n \t\tmodule.loaded = true;\n\n \t\t// Return the exports of the module\n \t\treturn module.exports;\n \t}\n\n\n \t// expose the modules object (__webpack_modules__)\n \t__webpack_require__.m = modules;\n\n \t// expose the module cache\n \t__webpack_require__.c = installedModules;\n\n \t// __webpack_public_path__\n \t__webpack_require__.p = \"/\";\n\n \t// Load entry module and return exports\n \treturn __webpack_require__(0);\n\n\n\n/** WEBPACK FOOTER **\n ** webpack/bootstrap b1bcc793378011ad1abd\n **/","class Test {\n foo() {\n console.log('bar')\n throw new Error('bar')\n }\n}\n\n\n\n/** WEBPACK FOOTER **\n ** ./packages/react-scripts/template/src/index.js\n **/"],"sourceRoot":""}