* Map a webpack `output.environment` configuration to the highest * ECMAScript version that the target is known to support. Returns `5` * when no ES2015+ features are flagged. * @param {NonNullable ["environment"]>} environment environment *
(environment)
| 24 | * @returns {number} ecma version (5, 2015, 2017 or 2020) |
| 25 | */ |
| 26 | function getEcmaVersion(environment) { |
| 27 | // ES2020 (11th edition) |
| 28 | if ( |
| 29 | environment.bigIntLiteral || |
| 30 | environment.dynamicImport || |
| 31 | environment.dynamicImportInWorker || |
| 32 | environment.globalThis || |
| 33 | environment.optionalChaining |
| 34 | ) { |
| 35 | return 2020; |
| 36 | } |
| 37 | |
| 38 | // ES2017 (8th edition) |
| 39 | if (environment.asyncFunction) { |
| 40 | return 2017; |
| 41 | } |
| 42 | |
| 43 | // ES2015 (6th edition) |
| 44 | if ( |
| 45 | environment.arrowFunction || |
| 46 | environment.const || |
| 47 | environment.destructuring || |
| 48 | environment.forOf || |
| 49 | environment.methodShorthand || |
| 50 | environment.module || |
| 51 | environment.templateLiteral |
| 52 | ) { |
| 53 | return 2015; |
| 54 | } |
| 55 | |
| 56 | return 5; |
| 57 | } |
| 58 | |
| 59 | const notSettled = Symbol("not-settled"); |
| 60 |
no outgoing calls
no test coverage detected
searching dependent graphs…