discourse/vendor/assets/javascripts/babel.js

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

3 lines
1.5 MiB
JavaScript
Raw Normal View History

DEV: updates js transpiler to use babel 7 (#10627) Updates our js transpiler code to use Babel 7.11.6 List of changes in this commit: - Updates plugins, babel plugins all have a new version which doesn't contain -es2015- anymore - Drops [transform-es2015-classes](https://babeljs.io/docs/en/babel-plugin-transform-classes) this plugin shouldn't be needed now that we don't support IE - Drops check-es2015-constants, checking constants is now part of babel and the check-constants plugin is deprecated. As a result the behavior slightly changed, and is now wrapping every const call in a readOnlyError function which would throw if assigned a new value. This explains the modified spec. - Adds [proposal-optional-chaining](https://babeljs.io/docs/en/babel-plugin-proposal-optional-chaining) ```javascript const obj = { foo: { bar: { baz: 42, }, }, }; const baz = obj?.foo?.bar?.baz; // 42 ``` - Adds [proposal-json-strings](https://babeljs.io/docs/en/babel-plugin-proposal-json-strings) ```javascript // IN const ex = "before after"; // ^ There's a U+2028 char between 'before' and 'after' // OUT const ex = "before\u2028after"; // ^ There's a U+2028 char between 'before' and 'after' ``` - Adds [proposal-nullish-coalescing-operator](https://babeljs.io/docs/en/babel-plugin-proposal-nullish-coalescing-operator) ```javascript var object = {}; var foo = object.foo ?? "default"; // default ``` - Adds [proposal-logical-assignment-operators](https://babeljs.io/docs/en/babel-plugin-proposal-logical-assignment-operators) ```javascript let a; let b = 2; a ||= b; // 2 ``` - Adds [proposal-numeric-separator](https://babeljs.io/docs/en/babel-plugin-proposal-numeric-separator) ```javascript let budget = 1_000_000_000_000; console.log(budget === 10 ** 12); // true ``` - Adds proposal-object-rest-spread https://babeljs.io/docs/en/babel-plugin-proposal-object-rest-spread ```javascript let { x, y, ...z } = { x: 1, y: 2, a: 3, b: 4 }; console.log(x); // 1 console.log(y); // 2 console.log(z); // { a: 3, b: 4 } ``` - Adds proposal-optional-catch-binding https://babeljs.io/docs/en/babel-plugin-proposal-optional-catch-binding ```javascript try { } catch { } finally { // ensures finally is available in every browsers } ``` - Adds improved regex support for firefox through (transform-dotall-regex](https://babeljs.io/docs/en/next/babel-plugin-transform-dotall-regex.html) and (proposal-unicode-property-regex](https://babeljs.io/docs/en/babel-plugin-proposal-unicode-property-regex) - Drops async/generator stuff, the browser we target should allow to use this (excepts iterable async)
2020-09-15 15:26:33 +08:00
// https://unpkg.com/@babel/standalone@7.11.6/babel.min.js
!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).Babel={})}(this,(function(e){"use strict";var t,r=Object.freeze({__proto__:null,get types(){return Ah},get DEFAULT_EXTENSIONS(){return bI},get OptionManager(){return xI},get Plugin(){return EI},get File(){return VA},get buildExternalHelpers(){return XA},get resolvePlugin(){return uP},get resolvePreset(){return pP},get version(){return hP},get getEnv(){return mP},get tokTypes(){return cx},get traverse(){return $w},get template(){return nw},get createConfigItem(){return gk},get loadPartialConfig(){return vD},get loadPartialConfigSync(){return bD},get loadPartialConfigAsync(){return xD},get loadOptions(){return ED},get loadOptionsSync(){return wD},get loadOptionsAsync(){return SD},get transform(){return sI},get transformSync(){return iI},get transformAsync(){return oI},get transformFile(){return lI},get transformFileSync(){return cI},get transformFileAsync(){return uI},get transformFromAst(){return dI},get transformFromAstSync(){return fI},get transformFromAstAsync(){return hI},get parse(){return yI},get parseSync(){return gI},get parseAsync(){return vI}});function n(e){return(n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e})(e)}function a(e){this.wrapped=e}function s(e){var t,r;function n(t,r){try{var i=e[t](r),o=i.value,l=o instanceof a;Promise.resolve(l?o.wrapped:o).then((function(e){l?n("return"===t?"return":"next",e):s(i.done?"return":"normal",e)}),(function(e){n("throw",e)}))}catch(e){s("throw",e)}}function s(e,a){switch(e){case"return":t.resolve({value:a,done:!0});break;case"throw":t.reject(a);break;default:t.resolve({value:a,done:!1})}(t=t.next)?n(t.key,t.arg):r=null}this._invoke=function(e,a){return new Promise((function(s,i){var o={key:e,arg:a,resolve:s,reject:i,next:null};r?r=r.next=o:(t=r=o,n(e,a))}))},"function"!=typeof e.return&&(this.return=void 0)}function i(e,t,r,n,a,s,i){try{var o=e[s](i),l=o.value}catch(e){return void r(e)}o.done?t(l):Promise.resolve(l).then(n,a)}function o(e,t){for(var r=0;r<t.length;r++){var n=t[r];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function l(e,t,r){return t&&o(e.prototype,t),r&&o(e,r),e}function c(e,t,r){return t in e?Object.defineProperty(e,t,{value:r,enumerable:!0,configurable:!0,writable:!0}):e[t]=r,e}function u(){return(u=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var r=arguments[t];for(var n in r)Object.prototype.hasOwnProperty.call(r,n)&&(e[n]=r[n])}return e}).apply(this,arguments)}function p(e,t){var r=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t&&(n=n.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),r.push.apply(r,n)}return r}function d(e,t){if("function"!=typeof t&&null!==t)throw new TypeError("Super expression must either be null or a function");e.prototype=Object.create(t&&t.prototype,{constructor:{value:e,writable:!0,configurable:!0}}),t&&m(e,t)}function f(e,t){e.prototype=Object.create(t.prototype),e.prototype.constructor=e,e.__proto__=t}function h(e){return(h=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function m(e,t){return(m=Object.setPrototypeOf||function(e,t){return e.__proto__=t,e})(e,t)}function y(){if("undefined"==typeof Reflect||!Reflect.construct)return!1;if(Reflect.construct.sham)return!1;if("function"==typeof Proxy)return!0;try{return Date.prototype.toString.call(Reflect.construct(Date,[],(function(){}))),!0}catch(e){return!1}}function g(e,t,r){return(g=y()?Reflect.construct:function(e,t,r){var n=[null];n.push.apply(n,t);var a=new(Function.bind.apply(e,n));return r&&m(a,r.prototype),a}).apply(null,arguments)}function v(e){return-1!==Function.toString.call(e).indexOf("[native code]")}functi