Add basic support for the optional chaining operator ?.

For now we need to use a Babel-plugin, since part of our build system doesn't support this fully (e.g. Babel-loader, Webpack 4.x, and SystemJS).

While the `?.` operator will thus always be transpiled by Babel, even in modern builds, simply supporting it for development purposes seems like a step in the right direction.

https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining
This commit is contained in:
Jonas Jenwald 2020-09-29 15:45:05 +02:00
parent 5107259176
commit db4cefbac3
3 changed files with 8 additions and 1 deletions

View File

@ -224,6 +224,12 @@ function createWebpackConfig(defines, output) {
loose: true,
},
],
[
"@babel/plugin-proposal-optional-chaining",
{
loose: true,
},
],
"@babel/plugin-transform-modules-commonjs",
[
"@babel/plugin-transform-runtime",

View File

@ -4,6 +4,7 @@
"devDependencies": {
"@babel/core": "^7.11.6",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.10.4",
"@babel/plugin-proposal-optional-chaining": "^7.11.0",
"@babel/plugin-transform-modules-commonjs": "^7.10.4",
"@babel/plugin-transform-runtime": "^7.11.5",
"@babel/preset-env": "^7.11.5",

View File

@ -846,7 +846,7 @@ const PDFViewerApplication = {
return undefined; // Ignore errors for previously opened PDF files.
}
const message = exception && exception.message;
const message = exception?.message;
let loadingErrorMessage;
if (exception instanceof InvalidPDFException) {
// change error message also for other builds