├── .gitignore ├── package.json ├── src ├── index.js └── signatures.js ├── yarn.lock └── README.md /.gitignore: -------------------------------------------------------------------------------- 1 | node_modules/ 2 | /dist/ 3 | /coverage/ 4 | bundle-stats.html 5 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "runtime-compress-loader", 3 | "version": "1.0.0", 4 | "description": "babel and typescript runtime optimization loader", 5 | "main": "src/index.js", 6 | "scripts": {}, 7 | "author": "theKashey ", 8 | "license": "MIT", 9 | "bugs": { 10 | "url": "https://github.com/theKashey/runtime-compress-loader/issues" 11 | }, 12 | "homepage": "https://github.com/theKashey/runtime-compress-loader#readme", 13 | "dependencies": { 14 | "@babel/runtime": "^7.1.2", 15 | "tslib": "^1.9.3" 16 | }, 17 | "peerDependencies": { 18 | "source-map": "^0.7.3" 19 | }, 20 | "devDependencies": { 21 | "source-map": "^0.7.3" 22 | } 23 | } 24 | -------------------------------------------------------------------------------- /src/index.js: -------------------------------------------------------------------------------- 1 | 'use strict'; 2 | const signatures = require('./signatures'); 3 | const {SourceNode, SourceMapConsumer} = require('source-map'); 4 | 5 | function transform(source, map) { 6 | if (this.cacheable) { 7 | this.cacheable(); 8 | } 9 | 10 | const hasExports = source.indexOf('exports '); 11 | 12 | const newSource = signatures.reduce( 13 | (result, pair) => result.replace(pair[0], pair[hasExports ? 2 : 1] || 'ERROR_NO_REPLACE'), 14 | source 15 | ); 16 | 17 | if (!this.sourceMap || !map) { 18 | return this.callback(null, newSource); 19 | } 20 | 21 | const node = new SourceNode(null, null, null, [ 22 | SourceNode.fromStringWithSourceMap(newSource, new SourceMapConsumer(map)), 23 | ]).join(''); 24 | 25 | const result = node.toStringWithSourceMap(); 26 | return this.callback(null, result.code, result.map.toString()); 27 | } 28 | 29 | module.exports = transform; 30 | -------------------------------------------------------------------------------- /yarn.lock: -------------------------------------------------------------------------------- 1 | # THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY. 2 | # yarn lockfile v1 3 | 4 | 5 | "@babel/runtime@^7.1.2": 6 | version "7.1.2" 7 | resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.1.2.tgz#81c89935f4647706fc54541145e6b4ecfef4b8e3" 8 | integrity sha512-Y3SCjmhSupzFB6wcv1KmmFucH6gDVnI30WjOcicV10ju0cZjak3Jcs67YLIXBrmZYw1xCrVeJPbycFwrqNyxpg== 9 | dependencies: 10 | regenerator-runtime "^0.12.0" 11 | 12 | regenerator-runtime@^0.12.0: 13 | version "0.12.1" 14 | resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.12.1.tgz#fa1a71544764c036f8c49b13a08b2594c9f8a0de" 15 | integrity sha512-odxIc1/vDlo4iZcfXqRYFj0vpXFNoGdKMAUieAlFYO6m/nl5e9KR/beGf41z4a1FI+aQgtjhuaSlDxQ0hmkrHg== 16 | 17 | source-map@^0.7.3: 18 | version "0.7.3" 19 | resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.7.3.tgz#5302f8169031735226544092e64981f751750383" 20 | integrity sha512-CkCj6giN3S+n9qrYiBTX5gystlENnRW5jZeNLHpe6aue+SrHcG5VYwujhW9s4dY31mEGsxBDrHR6oI69fTXsaQ== 21 | 22 | tslib@^1.9.3: 23 | version "1.9.3" 24 | resolved "https://registry.yarnpkg.com/tslib/-/tslib-1.9.3.tgz#d7e4dd79245d85428c4d7e4822a79917954ca286" 25 | integrity sha512-4krF8scpejhaOgqzBEcGM7yDIEfi0/8+8zDRZhNZZ2kjmHJ4hv3zCbQWxoJGz1iw5U0Jl0nma13xzHXcncMavQ== 26 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # runtime-compress-loader 2 | ---- 3 | Removes the "inline" helpers, babel and typescript inlines to the every file, greatly reducing size of your application __before the gzip__, making it loads and runs faster. 4 | 5 | ## What it does 6 | 7 | Finds babel and typescript helpers and replaces them by code from `@babel/runtime` and `tslib` 8 | 9 | It's usually a __kilobyte in every file__ you have a class inside. How many files you have? Well, you got the point. 10 | 11 | So what it does? It replaces inlined `babel-helpers` by `imported` ones, keeping only one version of them. 12 | Works as well for `rslib` helpers. 13 | ```diff 14 | -var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; 15 | -function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; } 16 | +import _extends from '@babel/runtime/helpers/esm/extends'; 17 | +import _createClass from '@babel/runtime/helpers/esm/createClass'; 18 | ``` 19 | 20 | ## Usage 21 | Just add this webpack loader before any other for node_modules, and after any other for other locations. 22 | 23 | ### For project files 24 | ```js 25 | { 26 | test: /\.js$/, 27 | exclude: /node_modules/, 28 | loaders: ['runtime-compress-loader', 'babel-loader'], 29 | } 30 | ``` 31 | 32 | ### For node modules 33 | ```js 34 | { 35 | test: /\.js$/, 36 | include: /node_modules/, 37 | loaders: ['runtime-compress-loader'], 38 | } 39 | ``` 40 | 41 | ### For any location 42 | ```js 43 | { 44 | test: /\.js$/, 45 | loaders: ['runtime-compress-loader', 'babel-loader', 'runtime-compress-loader'], 46 | } 47 | ``` 48 | 49 | ## Other ways 50 | 51 | - [babel-plugin-transform-runtime](https://babeljs.io/docs/en/babel-plugin-transform-runtime) - and __the why__. User babel to do the job. 52 | For project, not yet transpiled files only. 53 | 54 | - [tslib](https://github.com/Microsoft/tslib) - `importHelpers` for typescript 55 | 56 | - [jsx-compress-loader](https://github.com/theKashey/jsx-compress-loader) - almost the same "compressing" operation, but for React.createElement only. 57 | 58 | # Licence 59 | MIT 60 | -------------------------------------------------------------------------------- /src/signatures.js: -------------------------------------------------------------------------------- 1 | module.exports = [ 2 | [ 3 | `var _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; };`, 4 | `import _extends from '@babel/runtime/helpers/esm/extends';`, 5 | `var _extends = require('@babel/runtime/helpers/esm/extends').default;`, 6 | ], 7 | [ 8 | `function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }`, 9 | `import _extends from '@babel/runtime/helpers/esm/extends';`, 10 | `var _extends = require('@babel/runtime/helpers/esm/extends').default;`, 11 | ], 12 | [ 13 | `var _extends = Object.assign || function (target) { 14 | for (var i = 1; i < arguments.length; i++) { 15 | var source = arguments[i]; 16 | 17 | for (var key in source) { 18 | if (Object.prototype.hasOwnProperty.call(source, key)) { 19 | target[key] = source[key]; 20 | } 21 | } 22 | } 23 | 24 | return target; 25 | };`, 26 | `import _extends from '@babel/runtime/helpers/esm/extends';`, 27 | `var _extends = require('@babel/runtime/helpers/esm/extends').default;`, 28 | ], 29 | [ 30 | `function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; var ownKeys = Object.keys(source); if (typeof Object.getOwnPropertySymbols === 'function') { ownKeys = ownKeys.concat(Object.getOwnPropertySymbols(source).filter(function (sym) { return Object.getOwnPropertyDescriptor(source, sym).enumerable; })); } ownKeys.forEach(function (key) { _defineProperty(target, key, source[key]); }); } return target; }`, 31 | `import _objectSpread from '@babel/runtime/helpers/esm/objectSpread';`, 32 | `var _objectSpread = require ('@babel/runtime/helpers/esm/objectSpread').default;` 33 | ], 34 | [ 35 | `function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }`, 36 | `import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';`, 37 | `var _defineProperty = require('@babel/runtime/helpers/esm/defineProperty').default;`, 38 | ], 39 | [ 40 | `var _createClass = function () { function defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, descriptor.key, descriptor); } } return function (Constructor, protoProps, staticProps) { if (protoProps) defineProperties(Constructor.prototype, protoProps); if (staticProps) defineProperties(Constructor, staticProps); return Constructor; }; }();`, 41 | `import _createClass from '@babel/runtime/helpers/esm/createClass';`, 42 | `var _createClass = require ('@babel/runtime/helpers/esm/createClass').default;`, 43 | ], 44 | [ 45 | `function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); return Constructor; }`, 46 | `import _createClass from '@babel/runtime/helpers/esm/createClass';`, 47 | `var _createClass = require ('@babel/runtime/helpers/esm/createClass').default;`, 48 | ], 49 | [ 50 | `/* skip */function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }`, 51 | `import _interopRequireDefault from '@babel/runtime/helpers/esm/interopRequireDefault';`, 52 | `var _interopRequireDefault = require('@babel/runtime/helpers/esm/interopRequireDefault').default;`, 53 | ], 54 | [ 55 | `function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }`, 56 | `import _classCallCheck from '@babel/runtime/helpers/esm/classCallCheck';`, 57 | `var _classCallCheck = require('@babel/runtime/helpers/esm/classCallCheck').default;`, 58 | ], 59 | [ 60 | `function _possibleConstructorReturn(self, call) { if (!self) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return call && (typeof call === "object" || typeof call === "function") ? call : self; }`, 61 | `import _possibleConstructorReturn from '@babel/runtime/helpers/esm/possibleConstructorReturn';`, 62 | `var _possibleConstructorReturn = require('@babel/runtime/helpers/esm/possibleConstructorReturn').default;`, 63 | ], 64 | [ 65 | `function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } return _assertThisInitialized(self); }`, 66 | `import _possibleConstructorReturn from '@babel/runtime/helpers/esm/possibleConstructorReturn';`, 67 | `var _possibleConstructorReturn = require('@babel/runtime/helpers/esm/possibleConstructorReturn').default;`, 68 | ], 69 | [ 70 | `function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }`, 71 | `import _getPrototypeOf from '@babel/runtime/helpers/esm/getPrototypeOf';`, 72 | `var _getPrototypeOf = require('@babel/runtime/helpers/esm/getPrototypeOf').default;`, 73 | ], 74 | [ 75 | `function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }`, 76 | `import _setPrototypeOf from '@babel/runtime/helpers/esm/setPrototypeOf';`, 77 | `var _setPrototypeOf = require('@babel/runtime/helpers/esm/setPrototypeOf').default;`, 78 | ], 79 | [ 80 | `function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, enumerable: false, writable: true, configurable: true } }); if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; }`, 81 | `import _inherits from '@babel/runtime/helpers/esm/inherits';`, 82 | `var _inherits = require('@babel/runtime/helpers/esm/inherits').default;`, 83 | ], 84 | [ 85 | `function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); if (superClass) _setPrototypeOf(subClass, superClass); }`, 86 | `import _inherits from '@babel/runtime/helpers/esm/inherits';`, 87 | `var _inherits = require('@babel/runtime/helpers/esm/inherits').default;`, 88 | ], 89 | [ 90 | `function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }`, 91 | `import _assertThisInitialized from '@babel/runtime/helpers/esm/assertThisInitialized';`, 92 | `var _assertThisInitialized = require('@babel/runtime/helpers/esm/assertThisInitialized').default;`, 93 | ], 94 | [ 95 | `function _objectWithoutProperties(obj, keys) { var target = {}; for (var i in obj) { if (keys.indexOf(i) >= 0) continue; if (!Object.prototype.hasOwnProperty.call(obj, i)) continue; target[i] = obj[i]; } return target; }`, 96 | `import _objectWithoutProperties from '@babel/runtime/helpers/esm/objectWithoutProperties';`, 97 | `var _objectWithoutProperties = require('@babel/runtime/helpers/esm/objectWithoutProperties').default;`, 98 | ], 99 | [ 100 | `var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { return typeof obj; } : function (obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; };`, 101 | `import _typeof from '@babel/runtime/helpers/esm/typeof';`, 102 | `var _typeof = require('@babel/runtime/helpers/esm/typeof').default;`, 103 | ], 104 | [ 105 | `function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); }`, 106 | `import _typeof from '@babel/runtime/helpers/esm/typeof';`, 107 | `var _typeof = require('@babel/runtime/helpers/esm/typeof').default;`, 108 | ], 109 | [ 110 | `var _typeof = typeof Symbol === "function" && typeof Symbol.iterator === "symbol" ? function (obj) { 111 | return typeof obj; 112 | } : function (obj) { 113 | return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; 114 | };`, 115 | `import _typeof from '@babel/runtime/helpers/esm/typeof';`, 116 | `var _typeof = require('@babel/runtime/helpers/esm/typeof').default;`, 117 | ], 118 | [ 119 | `function _toConsumableArray(arr) { if (Array.isArray(arr)) { for (var i = 0, arr2 = Array(arr.length); i < arr.length; i++) { arr2[i] = arr[i]; } return arr2; } else { return Array.from(arr); } }`, 120 | `import _toConsumableArray from '@babel/runtime/helpers/esm/toConsumableArray';`, 121 | `var _toConsumableArray = require('@babel/runtime/helpers/esm/toConsumableArray').default;`, 122 | ], 123 | [ 124 | `var inherits = function (subClass, superClass) { 125 | if (typeof superClass !== "function" && superClass !== null) { 126 | throw new TypeError("Super expression must either be null or a function, not " + typeof superClass); 127 | } 128 | 129 | subClass.prototype = Object.create(superClass && superClass.prototype, { 130 | constructor: { 131 | value: subClass, 132 | enumerable: false, 133 | writable: true, 134 | configurable: true 135 | } 136 | }); 137 | if (superClass) Object.setPrototypeOf ? Object.setPrototypeOf(subClass, superClass) : subClass.__proto__ = superClass; 138 | };`, 139 | `import inherits from '@babel/runtime/helpers/esm/inherits';`, 140 | `var inherits = require('@babel/runtime/helpers/esm/inherits').default;`, 141 | ], 142 | [ 143 | `var possibleConstructorReturn = function (self, call) { 144 | if (!self) { 145 | throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); 146 | } 147 | 148 | return call && (typeof call === "object" || typeof call === "function") ? call : self; 149 | };`, 150 | `import possibleConstructorReturn from '@babel/runtime/helpers/esm/possibleConstructorReturn';`, 151 | `var possibleConstructorReturn = require('@babel/runtime/helpers/esm/possibleConstructorReturn').default;`, 152 | ], 153 | [ 154 | `function _asyncToGenerator(fn) { return function () { var gen = fn.apply(this, arguments); return new Promise(function (resolve, reject) { function step(key, arg) { try { var info = gen[key](arg); var value = info.value; } catch (error) { reject(error); return; } if (info.done) { resolve(value); } else { return Promise.resolve(value).then(function (value) { step("next", value); }, function (err) { step("throw", err); }); } } return step("next"); }); }; }`, 155 | `import _asyncToGenerator '@babel/runtime/helpers/esm/asyncToGenerator';`, 156 | `var _asyncToGenerator = require('@babel/runtime/helpers/esm/asyncToGenerator').default;`, 157 | ], 158 | 159 | 160 | /* TYPE SCRIPT */ 161 | 162 | 163 | [ 164 | `var __extends = (this && this.__extends) || (function () { 165 | var extendStatics = Object.setPrototypeOf || 166 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 167 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; 168 | return function (d, b) { 169 | extendStatics(d, b); 170 | function __() { this.constructor = d; } 171 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 172 | }; 173 | })();`, 174 | `import {__extends} from 'tslib';`, 175 | `var __extends = require('tslib').__extends;`, 176 | ], 177 | [ 178 | `var __extends = (this && this.__extends) || (function () { 179 | var extendStatics = function (d, b) { 180 | extendStatics = Object.setPrototypeOf || 181 | ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || 182 | function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; 183 | return extendStatics(d, b); 184 | } 185 | return function (d, b) { 186 | extendStatics(d, b); 187 | function __() { this.constructor = d; } 188 | d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); 189 | }; 190 | })();`, 191 | `import {__extends} from 'tslib';`, 192 | `var __extends = require('tslib').__extends;`, 193 | ], 194 | [ 195 | `var __assign = (this && this.__assign) || Object.assign || function(t) { 196 | for (var s, i = 1, n = arguments.length; i < n; i++) { 197 | s = arguments[i]; 198 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) 199 | t[p] = s[p]; 200 | } 201 | return t; 202 | };`, 203 | `import {__assign} from 'tslib';`, 204 | `var __assign = require('tslib').__assign;`, 205 | ], 206 | [ 207 | `var __assign = (this && this.__assign) || function () { 208 | __assign = Object.assign || function(t) { 209 | for (var s, i = 1, n = arguments.length; i < n; i++) { 210 | s = arguments[i]; 211 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) 212 | t[p] = s[p]; 213 | } 214 | return t; 215 | }; 216 | return __assign.apply(this, arguments); 217 | };`, 218 | `import {__assign} from 'tslib';`, 219 | `var __assign = require('tslib').__assign;`, 220 | ], 221 | [ 222 | `var __rest = (this && this.__rest) || function (s, e) { 223 | var t = {}; 224 | for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0) 225 | t[p] = s[p]; 226 | if (s != null && typeof Object.getOwnPropertySymbols === "function") 227 | for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0) 228 | t[p[i]] = s[p[i]]; 229 | return t; 230 | }; 231 | `, 232 | `import {__rest} from 'tslib';`, 233 | `var __rest = require('tslib').__rest;`, 234 | ], 235 | [ 236 | `var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { 237 | return new (P || (P = Promise))(function (resolve, reject) { 238 | function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } 239 | function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } 240 | function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); } 241 | step((generator = generator.apply(thisArg, _arguments || [])).next()); 242 | }); 243 | };`, 244 | `import {__awaiter} from 'tslib`, 245 | `var __awaiter = require('tslib').__awaiter;`, 246 | ], 247 | [ 248 | `var __generator = (this && this.__generator) || function (thisArg, body) { 249 | var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g; 250 | return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g; 251 | function verb(n) { return function (v) { return step([n, v]); }; } 252 | function step(op) { 253 | if (f) throw new TypeError("Generator is already executing."); 254 | while (_) try { 255 | if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t; 256 | if (y = 0, t) op = [op[0] & 2, t.value]; 257 | switch (op[0]) { 258 | case 0: case 1: t = op; break; 259 | case 4: _.label++; return { value: op[1], done: false }; 260 | case 5: _.label++; y = op[1]; op = [0]; continue; 261 | case 7: op = _.ops.pop(); _.trys.pop(); continue; 262 | default: 263 | if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; } 264 | if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; } 265 | if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; } 266 | if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; } 267 | if (t[2]) _.ops.pop(); 268 | _.trys.pop(); continue; 269 | } 270 | op = body.call(thisArg, _); 271 | } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; } 272 | if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true }; 273 | } 274 | };`, 275 | `import {__generator} from 'tslib';`, 276 | `var __generator = require('tslib').__generator;`, 277 | ], 278 | ]; 279 | --------------------------------------------------------------------------------