mirror of
https://github.com/Microsoft/vscode
synced 2024-10-12 06:17:18 +00:00
eng - throw if minified output contains non-ascii characters (#178590)
This commit is contained in:
parent
9e1375620e
commit
95917c1376
File diff suppressed because one or more lines are too long
|
@ -406,10 +406,16 @@ export function minifyTask(src: string, sourceMapBaseUrl?: string): (cb: any) =>
|
||||||
const jsFile = res.outputFiles.find(f => /\.js$/.test(f.path))!;
|
const jsFile = res.outputFiles.find(f => /\.js$/.test(f.path))!;
|
||||||
const sourceMapFile = res.outputFiles.find(f => /\.js\.map$/.test(f.path))!;
|
const sourceMapFile = res.outputFiles.find(f => /\.js\.map$/.test(f.path))!;
|
||||||
|
|
||||||
f.contents = Buffer.from(jsFile.contents);
|
const contents = Buffer.from(jsFile.contents);
|
||||||
f.sourceMap = JSON.parse(sourceMapFile.text);
|
const unicodeMatch = contents.toString().match(/[^\x00-\xFF]+/g);
|
||||||
|
if (unicodeMatch) {
|
||||||
|
cb(new Error(`Found non-ascii character ${unicodeMatch[0]} in the minified output of ${f.path}. Non-ASCII characters in the output can cause performance problems when loading. Please review if you have introduced a regular expression that esbuild is not automatically converting and convert it to using unicode escape sequences.`));
|
||||||
|
} else {
|
||||||
|
f.contents = contents;
|
||||||
|
f.sourceMap = JSON.parse(sourceMapFile.text);
|
||||||
|
|
||||||
cb(undefined, f);
|
cb(undefined, f);
|
||||||
|
}
|
||||||
}, cb);
|
}, cb);
|
||||||
}),
|
}),
|
||||||
jsFilter.restore,
|
jsFilter.restore,
|
||||||
|
|
Loading…
Reference in a new issue