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

Do not add sourcemap markings for indentation #14506

Merged
merged 2 commits into from Apr 29, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -1 +1 @@
let str = "Updated!";
let str = "Updated!";
@@ -1 +1 @@
console.log("Updated!");
console.log("Updated!");

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -3,6 +3,6 @@
arr.map(function (x) {
return x * x;
});
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJhcnIiLCJtYXAiLCJ4Il0sInNvdXJjZXMiOlsic3RkaW4iXSwic291cmNlc0NvbnRlbnQiOlsiYXJyLm1hcCh4ID0+IHggKiB4KTsiXSwibWFwcGluZ3MiOiI7O0FBQUFBLEdBQUcsQ0FBQ0MsR0FBSixDQUFRLFVBQUFDLENBQUM7QUFBQSxTQUFJQSxDQUFDLEdBQUdBLENBQVI7QUFBQSxDQUFUIn0=
//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJuYW1lcyI6WyJhcnIiLCJtYXAiLCJ4Il0sInNvdXJjZXMiOlsic3RkaW4iXSwic291cmNlc0NvbnRlbnQiOlsiYXJyLm1hcCh4ID0+IHggKiB4KTsiXSwibWFwcGluZ3MiOiI7O0FBQUFBLEdBQUcsQ0FBQ0MsR0FBSixDQUFRLFVBQUFDLENBQUM7RUFBQSxPQUFJQSxDQUFDLEdBQUdBLENBQVI7QUFBQSxDQUFUIn0=

//# sourceMappingURL=data:application/json;charset=utf-8;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic3Rkb3V0IiwibmFtZXMiOltdLCJzb3VyY2VzIjpbXSwic291cmNlc0NvbnRlbnQiOltdLCJtYXBwaW5ncyI6IiJ9
43 changes: 27 additions & 16 deletions packages/babel-cli/test/index.js
Expand Up @@ -79,29 +79,40 @@ const assertTest = function (stdout, stderr, opts, cwd) {
const expectStderr = opts.stderr.trim();
stderr = stderr.trim();

if (opts.stderr) {
if (opts.stderrContains) {
expect(stderr).toContain(expectStderr);
} else {
expect(stderr).toBe(expectStderr);
try {
if (opts.stderr) {
if (opts.stderrContains) {
expect(stderr).toContain(expectStderr);
} else {
expect(stderr).toBe(expectStderr);
}
} else if (stderr) {
throw new Error("stderr:\n" + stderr);
}
} else if (stderr) {
throw new Error("stderr:\n" + stderr);
} catch (e) {
if (!process.env.OVERWRITE) throw e;
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm tired of manually updating fixtures, so I'm adding these in the places that can use it.

console.log(`Updated test file: ${opts.stderrPath}`);
outputFileSync(opts.stderrPath, stderr + "\n");
}

const expectStdout = opts.stdout.trim();
stdout = stdout.trim();
stdout = stdout.replace(/\\/g, "/");

if (opts.stdout) {
if (opts.stdoutContains) {
expect(stdout).toContain(expectStdout);
} else {
fs.writeFileSync(opts.stdoutPath, stdout + "\n");
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This was very annoying.

expect(stdout).toBe(expectStdout);
try {
if (opts.stdout) {
if (opts.stdoutContains) {
expect(stdout).toContain(expectStdout);
} else {
expect(stdout).toBe(expectStdout);
}
} else if (stdout) {
throw new Error("stdout:\n" + stdout);
}
} else if (stdout) {
throw new Error("stdout:\n" + stdout);
} catch (e) {
if (!process.env.OVERWRITE) throw e;
console.log(`Updated test file: ${opts.stdoutPath}`);
outputFileSync(opts.stdoutPath, stdout + "\n");
}

if (opts.outFiles) {
Expand All @@ -127,7 +138,7 @@ const assertTest = function (stdout, stderr, opts, cwd) {
}
const expectedLoc = path.join(opts.testLoc, "out-files", filename);
console.log(`Updated test file: ${expectedLoc}`);
fs.writeFileSync(expectedLoc, actualFiles[filename]);
outputFileSync(expectedLoc, actualFiles[filename]);
}
});

Expand Down
@@ -1,11 +1,15 @@
{
"version": 3,
"sources": ["source-maps/full/input.js"],
"names": [
"arr",
"map",
"x"
],
"mappings": "AAAAA,GAAG,CAACC,GAAJ,CAAQ,UAAAC,CAAC;AAAA,SAAIA,CAAC,GAAGA,CAAR;AAAA,CAAT",
"sourcesContent": ["arr.map(x => x * x);"]
}
"sources": [
"source-maps/full/input.js"
],
"sourcesContent": [
"arr.map(x => x * x);"
],
"mappings": "AAAAA,GAAG,CAACC,GAAJ,CAAQ,UAAAC,CAAC;EAAA,OAAIA,CAAC,GAAGA,CAAR;AAAA,CAAT"
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The diff here:

- AAAAA,GAAG,CAACC,GAAJ,CAAQ,UAAAC,CAAC;AAAA,SAAIA,CAAC,GAAGA,CAAR;AAAA,CAAT
+ AAAAA,GAAG,CAACC,GAAJ,CAAQ,UAAAC,CAAC;EAAA,OAAIA,CAAC,GAAGA,CAAR;AAAA,CAAT

The changed AAAA,SAAIA -> EAAA,OAAIA is the two spaces used for indentation. A means 0, and E means 2, so we moved the generated column 2 times when inserting the new marking. The S -> O is because markings are deltas, so we subtracted 2 columns from S giving us O.

}

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

@@ -1,10 +1,16 @@
{
"version": 3,
"sources": ["HelloWorld.vue"],
"names": ["name", "data", "msg"],
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAsFA;AACAA,oBADA;;AAEAC;AACA;AACAC;AADA;AAGA;;AANA,C",
"mappings": ";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;eAsFA;EACAA,kBADA;;EAEAC;IACA;MACAC;IADA;EAGA;;AANA,C",
"names": [
"name",
"data",
"msg"
],
"sourceRoot": "src/components",
"sources": [
"HelloWorld.vue"
],
"sourcesContent": [
"<template>\n <div class=\"hello\">\n <h1>{{ msg }}</h1>\n <h2>Essential Links</h2>\n <ul>\n <li>\n <a\n href=\"https://vuejs.org\"\n target=\"_blank\"\n >\n Core Docs\n </a>\n </li>\n <li>\n <a\n href=\"https://forum.vuejs.org\"\n target=\"_blank\"\n >\n Forum\n </a>\n </li>\n <li>\n <a\n href=\"https://chat.vuejs.org\"\n target=\"_blank\"\n >\n Community Chat\n </a>\n </li>\n <li>\n <a\n href=\"https://twitter.com/vuejs\"\n target=\"_blank\"\n >\n Twitter\n </a>\n </li>\n <br>\n <li>\n <a\n href=\"http://vuejs-templates.github.io/webpack/\"\n target=\"_blank\"\n >\n Docs for This Template\n </a>\n </li>\n </ul>\n <h2>Ecosystem</h2>\n <ul>\n <li>\n <a\n href=\"http://router.vuejs.org/\"\n target=\"_blank\"\n >\n vue-router\n </a>\n </li>\n <li>\n <a\n href=\"http://vuex.vuejs.org/\"\n target=\"_blank\"\n >\n vuex\n </a>\n </li>\n <li>\n <a\n href=\"http://vue-loader.vuejs.org/\"\n target=\"_blank\"\n >\n vue-loader\n </a>\n </li>\n <li>\n <a\n href=\"https://github.com/vuejs/awesome-vue\"\n target=\"_blank\"\n >\n awesome-vue\n </a>\n </li>\n </ul>\n </div>\n</template>\n\n<script>\nexport default {\n name: 'HelloWorld',\n data () {\n return {\n msg: 'Welcome to Your Vue.js App'\n }\n }\n}\n</script>\n\n<!-- Add \"scoped\" attribute to limit CSS to this component only -->\n<style scoped>\nh1, h2 {\n font-weight: normal;\n}\nul {\n list-style-type: none;\n padding: 0;\n}\nli {\n display: inline-block;\n margin: 0 10px;\n}\na {\n color: #42b983;\n}\n</style>\n"
]
}
}
Expand Up @@ -12,7 +12,7 @@
{
"generated": {
"line": 93,
"column": 0
"column": 2
},
"original": {
"line": 88,
Expand All @@ -32,7 +32,7 @@
{
"generated": {
"line": 96,
"column": 0
"column": 4
},
"original": {
"line": 90,
Expand All @@ -42,7 +42,7 @@
{
"generated": {
"line": 97,
"column": 0
"column": 6
},
"original": {
"line": 91,
Expand All @@ -52,7 +52,7 @@
{
"generated": {
"line": 98,
"column": 0
"column": 4
},
"original": {
"line": 90,
Expand All @@ -62,7 +62,7 @@
{
"generated": {
"line": 99,
"column": 0
"column": 2
},
"original": {
"line": 93,
Expand Down
@@ -1,5 +1,6 @@
{
"mappings": "AAAC;;ACCD,SAASA,GAAT,CAAaC,GAAb,EAAwB;AACpB,QAAM,IAAIC,KAAJ,CAAU,cAAV,CAAN;AACH",
"version": 3,
"mappings": "AAAC;;ACCD,SAASA,GAAT,CAAaC,GAAb,EAAwB;EACpB,MAAM,IAAIC,KAAJ,CAAU,cAAV,CAAN;AACH",
"names": [
"foo",
"bar",
Expand All @@ -12,6 +13,5 @@
"sourcesContent": [
"<bar />",
"foo(1);\nfunction foo(bar: number): never {\n throw new Error('Intentional.');\n}"
],
"version": 3
}
]
}