From 4da4728bf5e1f46c02447a9f400be09e6c5cdbfe Mon Sep 17 00:00:00 2001 From: Logan Smyth Date: Mon, 16 Apr 2018 13:45:43 -0700 Subject: [PATCH] Add an example of an extremely bad sourcemap merge. --- .../input-source-map.json | 12 ++ .../input-source-map-complex/input.mjs | 113 +++++++++++++++++ .../input-source-map-complex/options.json | 5 + .../input-source-map-complex/output.js | 120 ++++++++++++++++++ .../input-source-map-complex/source-map.json | 12 ++ .../source-mappings.json | 82 ++++++++++++ packages/babel-helper-fixtures/src/index.js | 5 + .../src/index.js | 1 + 8 files changed, 350 insertions(+) create mode 100644 packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-complex/input-source-map.json create mode 100644 packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-complex/input.mjs create mode 100644 packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-complex/options.json create mode 100644 packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-complex/output.js create mode 100644 packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-complex/source-map.json create mode 100644 packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-complex/source-mappings.json diff --git a/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-complex/input-source-map.json b/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-complex/input-source-map.json new file mode 100644 index 0000000000..2297724483 --- /dev/null +++ b/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-complex/input-source-map.json @@ -0,0 +1,12 @@ +{ + "version": 3, + "sources": [ + "HelloWorld.vue" + ], + "names": [], + "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsFA;AACA;AACA;AACA;AACA;AACA;AACA;AACA", + "sourceRoot": "src/components", + "sourcesContent": [ + "\n\n\n\n\n\n" + ] +} diff --git a/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-complex/input.mjs b/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-complex/input.mjs new file mode 100644 index 0000000000..7188e524b2 --- /dev/null +++ b/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-complex/input.mjs @@ -0,0 +1,113 @@ +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// + +// +export default { + name: 'HelloWorld', + data () { + return { + msg: 'Welcome to Your Vue.js App' + } + } +} +// + +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// diff --git a/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-complex/options.json b/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-complex/options.json new file mode 100644 index 0000000000..8b5e8767af --- /dev/null +++ b/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-complex/options.json @@ -0,0 +1,5 @@ +{ + "plugins": [ + "transform-modules-commonjs" + ] +} diff --git a/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-complex/output.js b/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-complex/output.js new file mode 100644 index 0000000000..5abbe8e6bc --- /dev/null +++ b/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-complex/output.js @@ -0,0 +1,120 @@ +"use strict"; + +Object.defineProperty(exports, "__esModule", { + value: true +}); +exports.default = void 0; +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +var _default = { + name: 'HelloWorld', + + data() { + return { + msg: 'Welcome to Your Vue.js App' + }; + } + +}; // +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// +// + +exports.default = _default; diff --git a/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-complex/source-map.json b/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-complex/source-map.json new file mode 100644 index 0000000000..d859858ec2 --- /dev/null +++ b/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-complex/source-map.json @@ -0,0 +1,12 @@ +{ + "version": 3, + "sources": [ + "HelloWorld.vue" + ], + "names": [], + "mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAsFA;;QAEA;;SACA;;WAEA,AACA;AAFA;AAGA;;AANA", + "sourceRoot": "src/components", + "sourcesContent": [ + "\n\n\n\n\n\n" + ] +} diff --git a/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-complex/source-mappings.json b/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-complex/source-mappings.json new file mode 100644 index 0000000000..21079a86cc --- /dev/null +++ b/packages/babel-core/test/fixtures/transformation/source-maps/input-source-map-complex/source-mappings.json @@ -0,0 +1,82 @@ +[ + { + "generated": { + "line": 91, + "column": 0 + }, + "original": { + "line": 87, + "column": 0 + } + }, + { + "generated": { + "line": 92, + "column": 0 + }, + "original": { + "line": null, + "column": null + } + }, + { + "generated": { + "line": 93, + "column": 0 + }, + "original": { + "line": null, + "column": null + } + }, + { + "generated": { + "line": 93, + "column": 9 + }, + "original": { + "line": 89, + "column": 0 + } + }, + { + "generated": { + "line": 94, + "column": 9 + }, + "original": { + "line": null, + "column": null + } + }, + { + "generated": { + "line": 95, + "column": 9 + }, + "original": { + "line": 90, + "column": 0 + } + }, + { + "generated": { + "line": 96, + "column": 0 + }, + "original": { + "line": null, + "column": null + } + }, + { + "generated": { + "line": 97, + "column": 12 + }, + "original": { + "line": 92, + "column": 0 + } + } +] diff --git a/packages/babel-helper-fixtures/src/index.js b/packages/babel-helper-fixtures/src/index.js index dcf01d8b61..d27772495e 100644 --- a/packages/babel-helper-fixtures/src/index.js +++ b/packages/babel-helper-fixtures/src/index.js @@ -196,6 +196,11 @@ export default function get(entryLoc): Array { if (fs.existsSync(sourceMapLoc)) { test.sourceMap = JSON.parse(readFile(sourceMapLoc)); } + + const inputMapLoc = taskDir + "/input-source-map.json"; + if (fs.existsSync(inputMapLoc)) { + test.inputSourceMap = JSON.parse(readFile(inputMapLoc)); + } } } diff --git a/packages/babel-helper-transform-fixture-test-runner/src/index.js b/packages/babel-helper-transform-fixture-test-runner/src/index.js index fde5f91326..077645297e 100644 --- a/packages/babel-helper-transform-fixture-test-runner/src/index.js +++ b/packages/babel-helper-transform-fixture-test-runner/src/index.js @@ -325,6 +325,7 @@ function run(task) { sourceFileName: self.filename, sourceType: "script", babelrc: false, + inputSourceMap: task.inputSourceMap || undefined, }, opts, );