applying transfer to react app

This commit is contained in:
Tyler Koenig
2021-09-20 16:54:47 -04:00
parent 8819f31dd0
commit c612b7d702
37373 changed files with 3775588 additions and 2871 deletions
+21
View File
@@ -0,0 +1,21 @@
MIT License
Copyright (c) 2013-present, Facebook, Inc.
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
+63
View File
@@ -0,0 +1,63 @@
# babel-preset-react-app
This package includes the Babel preset used by [Create React App](https://github.com/facebook/create-react-app).<br>
Please refer to its documentation:
- [Getting Started](https://facebook.github.io/create-react-app/docs/getting-started) How to create a new app.
- [User Guide](https://facebook.github.io/create-react-app/) How to develop apps bootstrapped with Create React App.
## Usage in Create React App Projects
The easiest way to use this configuration is with [Create React App](https://github.com/facebook/create-react-app), which includes it by default. **You dont need to install it separately in Create React App projects.**
## Usage Outside of Create React App
If you want to use this Babel preset in a project not built with Create React App, you can install it with the following steps.
First, [install Babel](https://babeljs.io/docs/setup/).
Then install babel-preset-react-app.
```sh
npm install babel-preset-react-app --save-dev
```
Then create a file named `.babelrc` with following contents in the root folder of your project:
```json
{
"presets": ["react-app"]
}
```
This preset uses the `useBuiltIns` option with [transform-object-rest-spread](http://babeljs.io/docs/plugins/transform-object-rest-spread/) and [transform-react-jsx](http://babeljs.io/docs/plugins/transform-react-jsx/), which assumes that `Object.assign` is available or polyfilled.
## Usage with Flow
Make sure you have a `.flowconfig` file at the root directory. You can also use the `flow` option on `.babelrc`:
```json
{
"presets": [["react-app", { "flow": true, "typescript": false }]]
}
```
## Usage with TypeScript
Make sure you have a `tsconfig.json` file at the root directory. You can also use the `typescript` option on `.babelrc`:
```json
{
"presets": [["react-app", { "flow": false, "typescript": true }]]
}
```
## Absolute Runtime Paths
Absolute paths are enabled by default for imports. To use relative paths instead, set the `absoluteRuntime` option in `.babelrc` to `false`:
```
{
"presets": [["react-app", { "absoluteRuntime": false }]]
}
```
+209
View File
@@ -0,0 +1,209 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
const path = require('path');
const validateBoolOption = (name, value, defaultValue) => {
if (typeof value === 'undefined') {
value = defaultValue;
}
if (typeof value !== 'boolean') {
throw new Error(`Preset react-app: '${name}' option must be a boolean.`);
}
return value;
};
module.exports = function (api, opts, env) {
if (!opts) {
opts = {};
}
var isEnvDevelopment = env === 'development';
var isEnvProduction = env === 'production';
var isEnvTest = env === 'test';
var useESModules = validateBoolOption(
'useESModules',
opts.useESModules,
isEnvDevelopment || isEnvProduction
);
var isFlowEnabled = validateBoolOption('flow', opts.flow, true);
var isTypeScriptEnabled = validateBoolOption(
'typescript',
opts.typescript,
true
);
var areHelpersEnabled = validateBoolOption('helpers', opts.helpers, true);
var useAbsoluteRuntime = validateBoolOption(
'absoluteRuntime',
opts.absoluteRuntime,
true
);
var absoluteRuntimePath = undefined;
if (useAbsoluteRuntime) {
absoluteRuntimePath = path.dirname(
require.resolve('@babel/runtime/package.json')
);
}
if (!isEnvDevelopment && !isEnvProduction && !isEnvTest) {
throw new Error(
'Using `babel-preset-react-app` requires that you specify `NODE_ENV` or ' +
'`BABEL_ENV` environment variables. Valid values are "development", ' +
'"test", and "production". Instead, received: ' +
JSON.stringify(env) +
'.'
);
}
return {
presets: [
isEnvTest && [
// ES features necessary for user's Node version
require('@babel/preset-env').default,
{
targets: {
node: 'current',
},
},
],
(isEnvProduction || isEnvDevelopment) && [
// Latest stable ECMAScript features
require('@babel/preset-env').default,
{
// Allow importing core-js in entrypoint and use browserlist to select polyfills
useBuiltIns: 'entry',
// Set the corejs version we are using to avoid warnings in console
corejs: 3,
// Exclude transforms that make all code slower
exclude: ['transform-typeof-symbol'],
},
],
[
require('@babel/preset-react').default,
{
// Adds component stack to warning messages
// Adds __self attribute to JSX which React will use for some warnings
development: isEnvDevelopment || isEnvTest,
// Will use the native built-in instead of trying to polyfill
// behavior for any plugins that require one.
...(opts.runtime !== 'automatic' ? { useBuiltIns: true } : {}),
runtime: opts.runtime || 'classic',
},
],
isTypeScriptEnabled && [require('@babel/preset-typescript').default],
].filter(Boolean),
plugins: [
// Strip flow types before any other transform, emulating the behavior
// order as-if the browser supported all of the succeeding features
// https://github.com/facebook/create-react-app/pull/5182
// We will conditionally enable this plugin below in overrides as it clashes with
// @babel/plugin-proposal-decorators when using TypeScript.
// https://github.com/facebook/create-react-app/issues/5741
isFlowEnabled && [
require('@babel/plugin-transform-flow-strip-types').default,
false,
],
// Experimental macros support. Will be documented after it's had some time
// in the wild.
require('babel-plugin-macros'),
// Disabled as it's handled automatically by preset-env, and `selectiveLoose` isn't
// yet merged into babel: https://github.com/babel/babel/pull/9486
// Related: https://github.com/facebook/create-react-app/pull/8215
// [
// require('@babel/plugin-transform-destructuring').default,
// {
// // Use loose mode for performance:
// // https://github.com/facebook/create-react-app/issues/5602
// loose: false,
// selectiveLoose: [
// 'useState',
// 'useEffect',
// 'useContext',
// 'useReducer',
// 'useCallback',
// 'useMemo',
// 'useRef',
// 'useImperativeHandle',
// 'useLayoutEffect',
// 'useDebugValue',
// ],
// },
// ],
// Turn on legacy decorators for TypeScript files
isTypeScriptEnabled && [
require('@babel/plugin-proposal-decorators').default,
false,
],
// class { handleClick = () => { } }
// Enable loose mode to use assignment instead of defineProperty
// See discussion in https://github.com/facebook/create-react-app/issues/4263
[
require('@babel/plugin-proposal-class-properties').default,
{
loose: true,
},
],
// Adds Numeric Separators
require('@babel/plugin-proposal-numeric-separator').default,
// Polyfills the runtime needed for async/await, generators, and friends
// https://babeljs.io/docs/en/babel-plugin-transform-runtime
[
require('@babel/plugin-transform-runtime').default,
{
corejs: false,
helpers: areHelpersEnabled,
// By default, babel assumes babel/runtime version 7.0.0-beta.0,
// explicitly resolving to match the provided helper functions.
// https://github.com/babel/babel/issues/10261
version: require('@babel/runtime/package.json').version,
regenerator: true,
// https://babeljs.io/docs/en/babel-plugin-transform-runtime#useesmodules
// We should turn this on once the lowest version of Node LTS
// supports ES Modules.
useESModules,
// Undocumented option that lets us encapsulate our runtime, ensuring
// the correct version is used
// https://github.com/babel/babel/blob/090c364a90fe73d36a30707fc612ce037bdbbb24/packages/babel-plugin-transform-runtime/src/index.js#L35-L42
absoluteRuntime: absoluteRuntimePath,
},
],
isEnvProduction && [
// Remove PropTypes from production build
require('babel-plugin-transform-react-remove-prop-types').default,
{
removeImport: true,
},
],
// Optional chaining and nullish coalescing are supported in @babel/preset-env,
// but not yet supported in webpack due to support missing from acorn.
// These can be removed once webpack has support.
// See https://github.com/facebook/create-react-app/issues/8445#issuecomment-588512250
require('@babel/plugin-proposal-optional-chaining').default,
require('@babel/plugin-proposal-nullish-coalescing-operator').default,
].filter(Boolean),
overrides: [
isFlowEnabled && {
exclude: /\.tsx?$/,
plugins: [require('@babel/plugin-transform-flow-strip-types').default],
},
isTypeScriptEnabled && {
test: /\.tsx?$/,
plugins: [
[
require('@babel/plugin-proposal-decorators').default,
{ legacy: true },
],
],
},
].filter(Boolean),
};
};
+143
View File
@@ -0,0 +1,143 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
const path = require('path');
const validateBoolOption = (name, value, defaultValue) => {
if (typeof value === 'undefined') {
value = defaultValue;
}
if (typeof value !== 'boolean') {
throw new Error(`Preset react-app: '${name}' option must be a boolean.`);
}
return value;
};
module.exports = function (api, opts) {
if (!opts) {
opts = {};
}
// This is similar to how `env` works in Babel:
// https://babeljs.io/docs/usage/babelrc/#env-option
// We are not using `env` because its ignored in versions > babel-core@6.10.4:
// https://github.com/babel/babel/issues/4539
// https://github.com/facebook/create-react-app/issues/720
// Its also nice that we can enforce `NODE_ENV` being specified.
var env = process.env.BABEL_ENV || process.env.NODE_ENV;
var isEnvDevelopment = env === 'development';
var isEnvProduction = env === 'production';
var isEnvTest = env === 'test';
var areHelpersEnabled = validateBoolOption('helpers', opts.helpers, false);
var useAbsoluteRuntime = validateBoolOption(
'absoluteRuntime',
opts.absoluteRuntime,
true
);
var absoluteRuntimePath = undefined;
if (useAbsoluteRuntime) {
absoluteRuntimePath = path.dirname(
require.resolve('@babel/runtime/package.json')
);
}
if (!isEnvDevelopment && !isEnvProduction && !isEnvTest) {
throw new Error(
'Using `babel-preset-react-app` requires that you specify `NODE_ENV` or ' +
'`BABEL_ENV` environment variables. Valid values are "development", ' +
'"test", and "production". Instead, received: ' +
JSON.stringify(env) +
'.'
);
}
return {
// Babel assumes ES Modules, which isn't safe until CommonJS
// dies. This changes the behavior to assume CommonJS unless
// an `import` or `export` is present in the file.
// https://github.com/webpack/webpack/issues/4039#issuecomment-419284940
sourceType: 'unambiguous',
presets: [
isEnvTest && [
// ES features necessary for user's Node version
require('@babel/preset-env').default,
{
targets: {
node: 'current',
},
// Exclude transforms that make all code slower
exclude: ['transform-typeof-symbol'],
},
],
(isEnvProduction || isEnvDevelopment) && [
// Latest stable ECMAScript features
require('@babel/preset-env').default,
{
// Allow importing core-js in entrypoint and use browserlist to select polyfills
useBuiltIns: 'entry',
// Set the corejs version we are using to avoid warnings in console
// This will need to change once we upgrade to corejs@3
corejs: 3,
// Exclude transforms that make all code slower
exclude: ['transform-typeof-symbol'],
},
],
].filter(Boolean),
plugins: [
// Disabled as it's handled automatically by preset-env, and `selectiveLoose` isn't
// yet merged into babel: https://github.com/babel/babel/pull/9486
// Related: https://github.com/facebook/create-react-app/pull/8215
// [
// require('@babel/plugin-transform-destructuring').default,
// {
// // Use loose mode for performance:
// // https://github.com/facebook/create-react-app/issues/5602
// loose: false,
// selectiveLoose: [
// 'useState',
// 'useEffect',
// 'useContext',
// 'useReducer',
// 'useCallback',
// 'useMemo',
// 'useRef',
// 'useImperativeHandle',
// 'useLayoutEffect',
// 'useDebugValue',
// ],
// },
// ],
// Polyfills the runtime needed for async/await, generators, and friends
// https://babeljs.io/docs/en/babel-plugin-transform-runtime
[
require('@babel/plugin-transform-runtime').default,
{
corejs: false,
helpers: areHelpersEnabled,
// By default, babel assumes babel/runtime version 7.0.0-beta.0,
// explicitly resolving to match the provided helper functions.
// https://github.com/babel/babel/issues/10261
version: require('@babel/runtime/package.json').version,
regenerator: true,
// https://babeljs.io/docs/en/babel-plugin-transform-runtime#useesmodules
// We should turn this on once the lowest version of Node LTS
// supports ES Modules.
useESModules: isEnvDevelopment || isEnvProduction,
// Undocumented option that lets us encapsulate our runtime, ensuring
// the correct version is used
// https://github.com/babel/babel/blob/090c364a90fe73d36a30707fc612ce037bdbbb24/packages/babel-plugin-transform-runtime/src/index.js#L35-L42
absoluteRuntime: absoluteRuntimePath,
},
],
].filter(Boolean),
};
};
+13
View File
@@ -0,0 +1,13 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
const create = require('./create');
module.exports = function (api, opts) {
return create(api, Object.assign({ helpers: false }, opts), 'development');
};
+20
View File
@@ -0,0 +1,20 @@
/**
* Copyright (c) 2015-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
'use strict';
const create = require('./create');
module.exports = function (api, opts) {
// This is similar to how `env` works in Babel:
// https://babeljs.io/docs/usage/babelrc/#env-option
// We are not using `env` because its ignored in versions > babel-core@6.10.4:
// https://github.com/babel/babel/issues/4539
// https://github.com/facebook/create-react-app/issues/720
// Its also nice that we can enforce `NODE_ENV` being specified.
const env = process.env.BABEL_ENV || process.env.NODE_ENV;
return create(api, opts, env);
};
+1
View File
@@ -0,0 +1 @@
../semver/bin/semver
@@ -0,0 +1,22 @@
MIT License
Copyright (c) 2014-present Sebastian McKenzie and other contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
# @babel/plugin-proposal-class-properties
> This plugin transforms static class properties as well as properties declared with the property initializer syntax
See our website [@babel/plugin-proposal-class-properties](https://babeljs.io/docs/en/next/babel-plugin-proposal-class-properties.html) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/plugin-proposal-class-properties
```
or using yarn:
```sh
yarn add @babel/plugin-proposal-class-properties --dev
```
@@ -0,0 +1,26 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _helperPluginUtils = require("@babel/helper-plugin-utils");
var _helperCreateClassFeaturesPlugin = require("@babel/helper-create-class-features-plugin");
var _default = (0, _helperPluginUtils.declare)((api, options) => {
api.assertVersion(7);
return (0, _helperCreateClassFeaturesPlugin.createClassFeaturePlugin)({
name: "proposal-class-properties",
feature: _helperCreateClassFeaturesPlugin.FEATURES.fields,
loose: options.loose,
manipulateOptions(opts, parserOpts) {
parserOpts.plugins.push("classProperties", "classPrivateProperties");
}
});
});
exports.default = _default;
@@ -0,0 +1,60 @@
{
"_from": "@babel/plugin-proposal-class-properties@7.12.1",
"_id": "@babel/plugin-proposal-class-properties@7.12.1",
"_inBundle": false,
"_integrity": "sha512-cKp3dlQsFsEs5CWKnN7BnSHOd0EOW8EKpEjkoz1pO2E5KzIDNV9Ros1b0CnmbVgAGXJubOYVBOGCT1OmJwOI7w==",
"_location": "/babel-preset-react-app/@babel/plugin-proposal-class-properties",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@babel/plugin-proposal-class-properties@7.12.1",
"name": "@babel/plugin-proposal-class-properties",
"escapedName": "@babel%2fplugin-proposal-class-properties",
"scope": "@babel",
"rawSpec": "7.12.1",
"saveSpec": null,
"fetchSpec": "7.12.1"
},
"_requiredBy": [
"/babel-preset-react-app",
"/babel-preset-react-app/@babel/preset-env"
],
"_resolved": "https://registry.npmjs.org/@babel/plugin-proposal-class-properties/-/plugin-proposal-class-properties-7.12.1.tgz",
"_shasum": "a082ff541f2a29a4821065b8add9346c0c16e5de",
"_spec": "@babel/plugin-proposal-class-properties@7.12.1",
"_where": "/Users/tylerkoenig/Code/personal/react-scss2/node_modules/babel-preset-react-app",
"bugs": {
"url": "https://github.com/babel/babel/issues"
},
"bundleDependencies": false,
"dependencies": {
"@babel/helper-create-class-features-plugin": "^7.12.1",
"@babel/helper-plugin-utils": "^7.10.4"
},
"deprecated": false,
"description": "This plugin transforms static class properties as well as properties declared with the property initializer syntax",
"devDependencies": {
"@babel/core": "^7.12.1",
"@babel/helper-plugin-test-runner": "7.10.4"
},
"homepage": "https://github.com/babel/babel#readme",
"keywords": [
"babel-plugin"
],
"license": "MIT",
"main": "lib/index.js",
"name": "@babel/plugin-proposal-class-properties",
"peerDependencies": {
"@babel/core": "^7.0.0-0"
},
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/babel/babel.git",
"directory": "packages/babel-plugin-proposal-class-properties"
},
"version": "7.12.1"
}
@@ -0,0 +1,22 @@
MIT License
Copyright (c) 2014-present Sebastian McKenzie and other contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
# @babel/plugin-proposal-nullish-coalescing-operator
> Remove nullish coalescing operator
See our website [@babel/plugin-proposal-nullish-coalescing-operator](https://babeljs.io/docs/en/next/babel-plugin-proposal-nullish-coalescing-operator.html) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/plugin-proposal-nullish-coalescing-operator
```
or using yarn:
```sh
yarn add @babel/plugin-proposal-nullish-coalescing-operator --dev
```
@@ -0,0 +1,58 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _helperPluginUtils = require("@babel/helper-plugin-utils");
var _pluginSyntaxNullishCoalescingOperator = _interopRequireDefault(require("@babel/plugin-syntax-nullish-coalescing-operator"));
var _core = require("@babel/core");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = (0, _helperPluginUtils.declare)((api, {
loose = false
}) => {
api.assertVersion(7);
return {
name: "proposal-nullish-coalescing-operator",
inherits: _pluginSyntaxNullishCoalescingOperator.default,
visitor: {
LogicalExpression(path) {
const {
node,
scope
} = path;
if (node.operator !== "??") {
return;
}
let ref;
let assignment;
if (scope.isStatic(node.left)) {
ref = node.left;
assignment = _core.types.cloneNode(node.left);
} else if (scope.path.isPattern()) {
path.replaceWith(_core.template.ast`(() => ${path.node})()`);
return;
} else {
ref = scope.generateUidIdentifierBasedOnNode(node.left);
scope.push({
id: _core.types.cloneNode(ref)
});
assignment = _core.types.assignmentExpression("=", ref, node.left);
}
path.replaceWith(_core.types.conditionalExpression(loose ? _core.types.binaryExpression("!=", assignment, _core.types.nullLiteral()) : _core.types.logicalExpression("&&", _core.types.binaryExpression("!==", assignment, _core.types.nullLiteral()), _core.types.binaryExpression("!==", _core.types.cloneNode(ref), scope.buildUndefinedNode())), _core.types.cloneNode(ref), node.right));
}
}
};
});
exports.default = _default;
@@ -0,0 +1,60 @@
{
"_from": "@babel/plugin-proposal-nullish-coalescing-operator@7.12.1",
"_id": "@babel/plugin-proposal-nullish-coalescing-operator@7.12.1",
"_inBundle": false,
"_integrity": "sha512-nZY0ESiaQDI1y96+jk6VxMOaL4LPo/QDHBqL+SF3/vl6dHkTwHlOI8L4ZwuRBHgakRBw5zsVylel7QPbbGuYgg==",
"_location": "/babel-preset-react-app/@babel/plugin-proposal-nullish-coalescing-operator",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@babel/plugin-proposal-nullish-coalescing-operator@7.12.1",
"name": "@babel/plugin-proposal-nullish-coalescing-operator",
"escapedName": "@babel%2fplugin-proposal-nullish-coalescing-operator",
"scope": "@babel",
"rawSpec": "7.12.1",
"saveSpec": null,
"fetchSpec": "7.12.1"
},
"_requiredBy": [
"/babel-preset-react-app",
"/babel-preset-react-app/@babel/preset-env"
],
"_resolved": "https://registry.npmjs.org/@babel/plugin-proposal-nullish-coalescing-operator/-/plugin-proposal-nullish-coalescing-operator-7.12.1.tgz",
"_shasum": "3ed4fff31c015e7f3f1467f190dbe545cd7b046c",
"_spec": "@babel/plugin-proposal-nullish-coalescing-operator@7.12.1",
"_where": "/Users/tylerkoenig/Code/personal/react-scss2/node_modules/babel-preset-react-app",
"bugs": {
"url": "https://github.com/babel/babel/issues"
},
"bundleDependencies": false,
"dependencies": {
"@babel/helper-plugin-utils": "^7.10.4",
"@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.0"
},
"deprecated": false,
"description": "Remove nullish coalescing operator",
"devDependencies": {
"@babel/core": "^7.12.1",
"@babel/helper-plugin-test-runner": "7.10.4"
},
"homepage": "https://github.com/babel/babel#readme",
"keywords": [
"babel-plugin"
],
"license": "MIT",
"main": "lib/index.js",
"name": "@babel/plugin-proposal-nullish-coalescing-operator",
"peerDependencies": {
"@babel/core": "^7.0.0-0"
},
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/babel/babel.git",
"directory": "packages/babel-plugin-proposal-nullish-coalescing-operator"
},
"version": "7.12.1"
}
@@ -0,0 +1,22 @@
MIT License
Copyright (c) 2014-present Sebastian McKenzie and other contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
# @babel/plugin-proposal-numeric-separator
> Remove numeric separators from Decimal, Binary, Hex and Octal literals
See our website [@babel/plugin-proposal-numeric-separator](https://babeljs.io/docs/en/next/babel-plugin-proposal-numeric-separator.html) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/plugin-proposal-numeric-separator
```
or using yarn:
```sh
yarn add @babel/plugin-proposal-numeric-separator --dev
```
@@ -0,0 +1,36 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _helperPluginUtils = require("@babel/helper-plugin-utils");
var _pluginSyntaxNumericSeparator = _interopRequireDefault(require("@babel/plugin-syntax-numeric-separator"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = (0, _helperPluginUtils.declare)(api => {
api.assertVersion(7);
return {
name: "proposal-numeric-separator",
inherits: _pluginSyntaxNumericSeparator.default,
visitor: {
NumericLiteral({
node
}) {
const {
extra
} = node;
if (extra && /_/.test(extra.raw)) {
extra.raw = extra.raw.replace(/_/g, "");
}
}
}
};
});
exports.default = _default;
@@ -0,0 +1,60 @@
{
"_from": "@babel/plugin-proposal-numeric-separator@7.12.1",
"_id": "@babel/plugin-proposal-numeric-separator@7.12.1",
"_inBundle": false,
"_integrity": "sha512-MR7Ok+Af3OhNTCxYVjJZHS0t97ydnJZt/DbR4WISO39iDnhiD8XHrY12xuSJ90FFEGjir0Fzyyn7g/zY6hxbxA==",
"_location": "/babel-preset-react-app/@babel/plugin-proposal-numeric-separator",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@babel/plugin-proposal-numeric-separator@7.12.1",
"name": "@babel/plugin-proposal-numeric-separator",
"escapedName": "@babel%2fplugin-proposal-numeric-separator",
"scope": "@babel",
"rawSpec": "7.12.1",
"saveSpec": null,
"fetchSpec": "7.12.1"
},
"_requiredBy": [
"/babel-preset-react-app",
"/babel-preset-react-app/@babel/preset-env"
],
"_resolved": "https://registry.npmjs.org/@babel/plugin-proposal-numeric-separator/-/plugin-proposal-numeric-separator-7.12.1.tgz",
"_shasum": "0e2c6774c4ce48be412119b4d693ac777f7685a6",
"_spec": "@babel/plugin-proposal-numeric-separator@7.12.1",
"_where": "/Users/tylerkoenig/Code/personal/react-scss2/node_modules/babel-preset-react-app",
"bugs": {
"url": "https://github.com/babel/babel/issues"
},
"bundleDependencies": false,
"dependencies": {
"@babel/helper-plugin-utils": "^7.10.4",
"@babel/plugin-syntax-numeric-separator": "^7.10.4"
},
"deprecated": false,
"description": "Remove numeric separators from Decimal, Binary, Hex and Octal literals",
"devDependencies": {
"@babel/core": "^7.12.1",
"@babel/helper-plugin-test-runner": "7.10.4"
},
"homepage": "https://github.com/babel/babel#readme",
"keywords": [
"babel-plugin"
],
"license": "MIT",
"main": "lib/index.js",
"name": "@babel/plugin-proposal-numeric-separator",
"peerDependencies": {
"@babel/core": "^7.0.0-0"
},
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/babel/babel.git",
"directory": "packages/babel-plugin-proposal-numeric-separator"
},
"version": "7.12.1"
}
@@ -0,0 +1,22 @@
MIT License
Copyright (c) 2014-present Sebastian McKenzie and other contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
# @babel/plugin-proposal-optional-chaining
> Transform optional chaining operators into a series of nil checks
See our website [@babel/plugin-proposal-optional-chaining](https://babeljs.io/docs/en/next/babel-plugin-proposal-optional-chaining.html) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/plugin-proposal-optional-chaining
```
or using yarn:
```sh
yarn add @babel/plugin-proposal-optional-chaining --dev
```
@@ -0,0 +1,186 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _helperPluginUtils = require("@babel/helper-plugin-utils");
var _helperSkipTransparentExpressionWrappers = require("@babel/helper-skip-transparent-expression-wrappers");
var _pluginSyntaxOptionalChaining = _interopRequireDefault(require("@babel/plugin-syntax-optional-chaining"));
var _core = require("@babel/core");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = (0, _helperPluginUtils.declare)((api, options) => {
api.assertVersion(7);
const {
loose = false
} = options;
function isSimpleMemberExpression(expression) {
expression = (0, _helperSkipTransparentExpressionWrappers.skipTransparentExprWrappers)(expression);
return _core.types.isIdentifier(expression) || _core.types.isSuper(expression) || _core.types.isMemberExpression(expression) && !expression.computed && isSimpleMemberExpression(expression.object);
}
function needsMemoize(path) {
let optionalPath = path;
const {
scope
} = path;
while (optionalPath.isOptionalMemberExpression() || optionalPath.isOptionalCallExpression()) {
const {
node
} = optionalPath;
const childKey = optionalPath.isOptionalMemberExpression() ? "object" : "callee";
const childPath = (0, _helperSkipTransparentExpressionWrappers.skipTransparentExprWrappers)(optionalPath.get(childKey));
if (node.optional) {
return !scope.isStatic(childPath.node);
}
optionalPath = childPath;
}
}
return {
name: "proposal-optional-chaining",
inherits: _pluginSyntaxOptionalChaining.default,
visitor: {
"OptionalCallExpression|OptionalMemberExpression"(path) {
const {
scope
} = path;
let maybeWrapped = path;
const parentPath = path.findParent(p => {
if (!(0, _helperSkipTransparentExpressionWrappers.isTransparentExprWrapper)(p)) return true;
maybeWrapped = p;
});
let isDeleteOperation = false;
const parentIsCall = parentPath.isCallExpression({
callee: maybeWrapped.node
}) && path.isOptionalMemberExpression();
const optionals = [];
let optionalPath = path;
if (scope.path.isPattern() && needsMemoize(optionalPath)) {
path.replaceWith(_core.template.ast`(() => ${path.node})()`);
return;
}
while (optionalPath.isOptionalMemberExpression() || optionalPath.isOptionalCallExpression()) {
const {
node
} = optionalPath;
if (node.optional) {
optionals.push(node);
}
if (optionalPath.isOptionalMemberExpression()) {
optionalPath.node.type = "MemberExpression";
optionalPath = (0, _helperSkipTransparentExpressionWrappers.skipTransparentExprWrappers)(optionalPath.get("object"));
} else if (optionalPath.isOptionalCallExpression()) {
optionalPath.node.type = "CallExpression";
optionalPath = (0, _helperSkipTransparentExpressionWrappers.skipTransparentExprWrappers)(optionalPath.get("callee"));
}
}
let replacementPath = path;
if (parentPath.isUnaryExpression({
operator: "delete"
})) {
replacementPath = parentPath;
isDeleteOperation = true;
}
for (let i = optionals.length - 1; i >= 0; i--) {
const node = optionals[i];
const isCall = _core.types.isCallExpression(node);
const replaceKey = isCall ? "callee" : "object";
const chainWithTypes = node[replaceKey];
let chain = chainWithTypes;
while ((0, _helperSkipTransparentExpressionWrappers.isTransparentExprWrapper)(chain)) {
chain = chain.expression;
}
let ref;
let check;
if (isCall && _core.types.isIdentifier(chain, {
name: "eval"
})) {
check = ref = chain;
node[replaceKey] = _core.types.sequenceExpression([_core.types.numericLiteral(0), ref]);
} else if (loose && isCall && isSimpleMemberExpression(chain)) {
check = ref = chainWithTypes;
} else {
ref = scope.maybeGenerateMemoised(chain);
if (ref) {
check = _core.types.assignmentExpression("=", _core.types.cloneNode(ref), chainWithTypes);
node[replaceKey] = ref;
} else {
check = ref = chainWithTypes;
}
}
if (isCall && _core.types.isMemberExpression(chain)) {
if (loose && isSimpleMemberExpression(chain)) {
node.callee = chainWithTypes;
} else {
const {
object
} = chain;
let context = scope.maybeGenerateMemoised(object);
if (context) {
chain.object = _core.types.assignmentExpression("=", context, object);
} else if (_core.types.isSuper(object)) {
context = _core.types.thisExpression();
} else {
context = object;
}
node.arguments.unshift(_core.types.cloneNode(context));
node.callee = _core.types.memberExpression(node.callee, _core.types.identifier("call"));
}
}
let replacement = replacementPath.node;
if (i === 0 && parentIsCall) {
var _baseRef;
const object = (0, _helperSkipTransparentExpressionWrappers.skipTransparentExprWrappers)(replacementPath.get("object")).node;
let baseRef;
if (!loose || !isSimpleMemberExpression(object)) {
baseRef = scope.maybeGenerateMemoised(object);
if (baseRef) {
replacement.object = _core.types.assignmentExpression("=", baseRef, object);
}
}
replacement = _core.types.callExpression(_core.types.memberExpression(replacement, _core.types.identifier("bind")), [_core.types.cloneNode((_baseRef = baseRef) != null ? _baseRef : object)]);
}
replacementPath.replaceWith(_core.types.conditionalExpression(loose ? _core.types.binaryExpression("==", _core.types.cloneNode(check), _core.types.nullLiteral()) : _core.types.logicalExpression("||", _core.types.binaryExpression("===", _core.types.cloneNode(check), _core.types.nullLiteral()), _core.types.binaryExpression("===", _core.types.cloneNode(ref), scope.buildUndefinedNode())), isDeleteOperation ? _core.types.booleanLiteral(true) : scope.buildUndefinedNode(), replacement));
replacementPath = (0, _helperSkipTransparentExpressionWrappers.skipTransparentExprWrappers)(replacementPath.get("alternate"));
}
}
}
};
});
exports.default = _default;
@@ -0,0 +1,62 @@
{
"_from": "@babel/plugin-proposal-optional-chaining@7.12.1",
"_id": "@babel/plugin-proposal-optional-chaining@7.12.1",
"_inBundle": false,
"_integrity": "sha512-c2uRpY6WzaVDzynVY9liyykS+kVU+WRZPMPYpkelXH8KBt1oXoI89kPbZKKG/jDT5UK92FTW2fZkZaJhdiBabw==",
"_location": "/babel-preset-react-app/@babel/plugin-proposal-optional-chaining",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@babel/plugin-proposal-optional-chaining@7.12.1",
"name": "@babel/plugin-proposal-optional-chaining",
"escapedName": "@babel%2fplugin-proposal-optional-chaining",
"scope": "@babel",
"rawSpec": "7.12.1",
"saveSpec": null,
"fetchSpec": "7.12.1"
},
"_requiredBy": [
"/babel-preset-react-app",
"/babel-preset-react-app/@babel/preset-env"
],
"_resolved": "https://registry.npmjs.org/@babel/plugin-proposal-optional-chaining/-/plugin-proposal-optional-chaining-7.12.1.tgz",
"_shasum": "cce122203fc8a32794296fc377c6dedaf4363797",
"_spec": "@babel/plugin-proposal-optional-chaining@7.12.1",
"_where": "/Users/tylerkoenig/Code/personal/react-scss2/node_modules/babel-preset-react-app",
"bugs": {
"url": "https://github.com/babel/babel/issues"
},
"bundleDependencies": false,
"dependencies": {
"@babel/helper-plugin-utils": "^7.10.4",
"@babel/helper-skip-transparent-expression-wrappers": "^7.12.1",
"@babel/plugin-syntax-optional-chaining": "^7.8.0"
},
"deprecated": false,
"description": "Transform optional chaining operators into a series of nil checks",
"devDependencies": {
"@babel/core": "^7.12.1",
"@babel/helper-plugin-test-runner": "7.10.4",
"@babel/plugin-transform-block-scoping": "^7.12.1"
},
"homepage": "https://github.com/babel/babel#readme",
"keywords": [
"babel-plugin"
],
"license": "MIT",
"main": "lib/index.js",
"name": "@babel/plugin-proposal-optional-chaining",
"peerDependencies": {
"@babel/core": "^7.0.0-0"
},
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/babel/babel.git",
"directory": "packages/babel-plugin-proposal-optional-chaining"
},
"version": "7.12.1"
}
@@ -0,0 +1,22 @@
MIT License
Copyright (c) 2014-present Sebastian McKenzie and other contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
# @babel/plugin-transform-react-display-name
> Add displayName to React.createClass calls
See our website [@babel/plugin-transform-react-display-name](https://babeljs.io/docs/en/next/babel-plugin-transform-react-display-name.html) for more information.
## Install
Using npm:
```sh
npm install --save-dev @babel/plugin-transform-react-display-name
```
or using yarn:
```sh
yarn add @babel/plugin-transform-react-display-name --dev
```
@@ -0,0 +1,112 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _helperPluginUtils = require("@babel/helper-plugin-utils");
var _path = _interopRequireDefault(require("path"));
var _core = require("@babel/core");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = (0, _helperPluginUtils.declare)(api => {
api.assertVersion(7);
function addDisplayName(id, call) {
const props = call.arguments[0].properties;
let safe = true;
for (let i = 0; i < props.length; i++) {
const prop = props[i];
const key = _core.types.toComputedKey(prop);
if (_core.types.isLiteral(key, {
value: "displayName"
})) {
safe = false;
break;
}
}
if (safe) {
props.unshift(_core.types.objectProperty(_core.types.identifier("displayName"), _core.types.stringLiteral(id)));
}
}
const isCreateClassCallExpression = _core.types.buildMatchMemberExpression("React.createClass");
const isCreateClassAddon = callee => callee.name === "createReactClass";
function isCreateClass(node) {
if (!node || !_core.types.isCallExpression(node)) return false;
if (!isCreateClassCallExpression(node.callee) && !isCreateClassAddon(node.callee)) {
return false;
}
const args = node.arguments;
if (args.length !== 1) return false;
const first = args[0];
if (!_core.types.isObjectExpression(first)) return false;
return true;
}
return {
name: "transform-react-display-name",
visitor: {
ExportDefaultDeclaration({
node
}, state) {
if (isCreateClass(node.declaration)) {
const filename = state.filename || "unknown";
let displayName = _path.default.basename(filename, _path.default.extname(filename));
if (displayName === "index") {
displayName = _path.default.basename(_path.default.dirname(filename));
}
addDisplayName(displayName, node.declaration);
}
},
CallExpression(path) {
const {
node
} = path;
if (!isCreateClass(node)) return;
let id;
path.find(function (path) {
if (path.isAssignmentExpression()) {
id = path.node.left;
} else if (path.isObjectProperty()) {
id = path.node.key;
} else if (path.isVariableDeclarator()) {
id = path.node.id;
} else if (path.isStatement()) {
return true;
}
if (id) return true;
});
if (!id) return;
if (_core.types.isMemberExpression(id)) {
id = id.property;
}
if (_core.types.isIdentifier(id)) {
addDisplayName(id.name, node);
}
}
}
};
});
exports.default = _default;
@@ -0,0 +1,59 @@
{
"_from": "@babel/plugin-transform-react-display-name@7.12.1",
"_id": "@babel/plugin-transform-react-display-name@7.12.1",
"_inBundle": false,
"_integrity": "sha512-cAzB+UzBIrekfYxyLlFqf/OagTvHLcVBb5vpouzkYkBclRPraiygVnafvAoipErZLI8ANv8Ecn6E/m5qPXD26w==",
"_location": "/babel-preset-react-app/@babel/plugin-transform-react-display-name",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@babel/plugin-transform-react-display-name@7.12.1",
"name": "@babel/plugin-transform-react-display-name",
"escapedName": "@babel%2fplugin-transform-react-display-name",
"scope": "@babel",
"rawSpec": "7.12.1",
"saveSpec": null,
"fetchSpec": "7.12.1"
},
"_requiredBy": [
"/babel-preset-react-app",
"/babel-preset-react-app/@babel/preset-react"
],
"_resolved": "https://registry.npmjs.org/@babel/plugin-transform-react-display-name/-/plugin-transform-react-display-name-7.12.1.tgz",
"_shasum": "1cbcd0c3b1d6648c55374a22fc9b6b7e5341c00d",
"_spec": "@babel/plugin-transform-react-display-name@7.12.1",
"_where": "/Users/tylerkoenig/Code/personal/react-scss2/node_modules/babel-preset-react-app",
"bugs": {
"url": "https://github.com/babel/babel/issues"
},
"bundleDependencies": false,
"dependencies": {
"@babel/helper-plugin-utils": "^7.10.4"
},
"deprecated": false,
"description": "Add displayName to React.createClass calls",
"devDependencies": {
"@babel/core": "^7.12.1",
"@babel/helper-plugin-test-runner": "7.10.4"
},
"homepage": "https://github.com/babel/babel#readme",
"keywords": [
"babel-plugin"
],
"license": "MIT",
"main": "lib/index.js",
"name": "@babel/plugin-transform-react-display-name",
"peerDependencies": {
"@babel/core": "^7.0.0-0"
},
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/babel/babel.git",
"directory": "packages/babel-plugin-transform-react-display-name"
},
"version": "7.12.1"
}
@@ -0,0 +1,22 @@
MIT License
Copyright (c) 2014-present Sebastian McKenzie and other contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
# @babel/preset-env
> A Babel preset for each environment.
See our website [@babel/preset-env](https://babeljs.io/docs/en/next/babel-preset-env.html) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20preset-env%22+is%3Aopen) associated with this package.
## Install
Using npm:
```sh
npm install --save-dev @babel/preset-env
```
or using yarn:
```sh
yarn add @babel/preset-env --dev
```
@@ -0,0 +1,3 @@
// TODO: Remove in Babel 8
module.exports = require("@babel/compat-data/native-modules");
@@ -0,0 +1,3 @@
// TODO: Remove in Babel 8
module.exports = require("@babel/compat-data/native-modules");
@@ -0,0 +1,4 @@
// TODO: Remove in Babel 8
// https://github.com/vuejs/vue-cli/issues/3671
module.exports = require("./corejs2-built-ins.json");
@@ -0,0 +1,4 @@
// TODO: Remove in Babel 8
// https://github.com/vuejs/vue-cli/issues/3671
module.exports = require("./corejs2-built-ins.json");
@@ -0,0 +1,3 @@
// TODO: Remove in Babel 8
module.exports = require("@babel/compat-data/corejs2-built-ins");
@@ -0,0 +1,3 @@
// TODO: Remove in Babel 8
module.exports = require("@babel/compat-data/corejs2-built-ins");
@@ -0,0 +1,3 @@
// TODO: Remove in Babel 8
module.exports = require("@babel/compat-data/plugins");
@@ -0,0 +1,3 @@
// TODO: Remove in Babel 8
module.exports = require("@babel/compat-data/plugins");
@@ -0,0 +1,31 @@
/* eslint sort-keys: "error" */
// These mappings represent the syntax proposals that have been
// shipped by browsers, and are enabled by the `shippedProposals` option.
const proposalPlugins = new Set([
"proposal-class-properties",
"proposal-private-methods"
]);
// use intermediary object to enforce alphabetical key order
const pluginSyntaxObject = {
"proposal-async-generator-functions": "syntax-async-generators",
"proposal-class-properties": "syntax-class-properties",
"proposal-json-strings": "syntax-json-strings",
"proposal-nullish-coalescing-operator": "syntax-nullish-coalescing-operator",
"proposal-numeric-separator": "syntax-numeric-separator",
"proposal-object-rest-spread": "syntax-object-rest-spread",
"proposal-optional-catch-binding": "syntax-optional-catch-binding",
"proposal-optional-chaining": "syntax-optional-chaining",
// note: we don't have syntax-private-methods
"proposal-private-methods": "syntax-class-properties",
"proposal-unicode-property-regex": null,
};
const pluginSyntaxEntries = Object.keys(pluginSyntaxObject).map(function (key) {
return [key, pluginSyntaxObject[key]];
});
const pluginSyntaxMap = new Map(pluginSyntaxEntries);
module.exports = { pluginSyntaxMap, proposalPlugins };
@@ -0,0 +1,3 @@
// TODO: Remove in Babel 8
module.exports = require("@babel/helper-compilation-targets").unreleasedLabels;
@@ -0,0 +1,201 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _pluginSyntaxAsyncGenerators = _interopRequireDefault(require("@babel/plugin-syntax-async-generators"));
var _pluginSyntaxClassProperties = _interopRequireDefault(require("@babel/plugin-syntax-class-properties"));
var _pluginSyntaxDynamicImport = _interopRequireDefault(require("@babel/plugin-syntax-dynamic-import"));
var _pluginSyntaxExportNamespaceFrom = _interopRequireDefault(require("@babel/plugin-syntax-export-namespace-from"));
var _pluginSyntaxJsonStrings = _interopRequireDefault(require("@babel/plugin-syntax-json-strings"));
var _pluginSyntaxLogicalAssignmentOperators = _interopRequireDefault(require("@babel/plugin-syntax-logical-assignment-operators"));
var _pluginSyntaxNullishCoalescingOperator = _interopRequireDefault(require("@babel/plugin-syntax-nullish-coalescing-operator"));
var _pluginSyntaxNumericSeparator = _interopRequireDefault(require("@babel/plugin-syntax-numeric-separator"));
var _pluginSyntaxObjectRestSpread = _interopRequireDefault(require("@babel/plugin-syntax-object-rest-spread"));
var _pluginSyntaxOptionalCatchBinding = _interopRequireDefault(require("@babel/plugin-syntax-optional-catch-binding"));
var _pluginSyntaxOptionalChaining = _interopRequireDefault(require("@babel/plugin-syntax-optional-chaining"));
var _pluginSyntaxTopLevelAwait = _interopRequireDefault(require("@babel/plugin-syntax-top-level-await"));
var _pluginProposalAsyncGeneratorFunctions = _interopRequireDefault(require("@babel/plugin-proposal-async-generator-functions"));
var _pluginProposalClassProperties = _interopRequireDefault(require("@babel/plugin-proposal-class-properties"));
var _pluginProposalDynamicImport = _interopRequireDefault(require("@babel/plugin-proposal-dynamic-import"));
var _pluginProposalExportNamespaceFrom = _interopRequireDefault(require("@babel/plugin-proposal-export-namespace-from"));
var _pluginProposalJsonStrings = _interopRequireDefault(require("@babel/plugin-proposal-json-strings"));
var _pluginProposalLogicalAssignmentOperators = _interopRequireDefault(require("@babel/plugin-proposal-logical-assignment-operators"));
var _pluginProposalNullishCoalescingOperator = _interopRequireDefault(require("@babel/plugin-proposal-nullish-coalescing-operator"));
var _pluginProposalNumericSeparator = _interopRequireDefault(require("@babel/plugin-proposal-numeric-separator"));
var _pluginProposalObjectRestSpread = _interopRequireDefault(require("@babel/plugin-proposal-object-rest-spread"));
var _pluginProposalOptionalCatchBinding = _interopRequireDefault(require("@babel/plugin-proposal-optional-catch-binding"));
var _pluginProposalOptionalChaining = _interopRequireDefault(require("@babel/plugin-proposal-optional-chaining"));
var _pluginProposalPrivateMethods = _interopRequireDefault(require("@babel/plugin-proposal-private-methods"));
var _pluginProposalUnicodePropertyRegex = _interopRequireDefault(require("@babel/plugin-proposal-unicode-property-regex"));
var _pluginTransformAsyncToGenerator = _interopRequireDefault(require("@babel/plugin-transform-async-to-generator"));
var _pluginTransformArrowFunctions = _interopRequireDefault(require("@babel/plugin-transform-arrow-functions"));
var _pluginTransformBlockScopedFunctions = _interopRequireDefault(require("@babel/plugin-transform-block-scoped-functions"));
var _pluginTransformBlockScoping = _interopRequireDefault(require("@babel/plugin-transform-block-scoping"));
var _pluginTransformClasses = _interopRequireDefault(require("@babel/plugin-transform-classes"));
var _pluginTransformComputedProperties = _interopRequireDefault(require("@babel/plugin-transform-computed-properties"));
var _pluginTransformDestructuring = _interopRequireDefault(require("@babel/plugin-transform-destructuring"));
var _pluginTransformDotallRegex = _interopRequireDefault(require("@babel/plugin-transform-dotall-regex"));
var _pluginTransformDuplicateKeys = _interopRequireDefault(require("@babel/plugin-transform-duplicate-keys"));
var _pluginTransformExponentiationOperator = _interopRequireDefault(require("@babel/plugin-transform-exponentiation-operator"));
var _pluginTransformForOf = _interopRequireDefault(require("@babel/plugin-transform-for-of"));
var _pluginTransformFunctionName = _interopRequireDefault(require("@babel/plugin-transform-function-name"));
var _pluginTransformLiterals = _interopRequireDefault(require("@babel/plugin-transform-literals"));
var _pluginTransformMemberExpressionLiterals = _interopRequireDefault(require("@babel/plugin-transform-member-expression-literals"));
var _pluginTransformModulesAmd = _interopRequireDefault(require("@babel/plugin-transform-modules-amd"));
var _pluginTransformModulesCommonjs = _interopRequireDefault(require("@babel/plugin-transform-modules-commonjs"));
var _pluginTransformModulesSystemjs = _interopRequireDefault(require("@babel/plugin-transform-modules-systemjs"));
var _pluginTransformModulesUmd = _interopRequireDefault(require("@babel/plugin-transform-modules-umd"));
var _pluginTransformNamedCapturingGroupsRegex = _interopRequireDefault(require("@babel/plugin-transform-named-capturing-groups-regex"));
var _pluginTransformNewTarget = _interopRequireDefault(require("@babel/plugin-transform-new-target"));
var _pluginTransformObjectSuper = _interopRequireDefault(require("@babel/plugin-transform-object-super"));
var _pluginTransformParameters = _interopRequireDefault(require("@babel/plugin-transform-parameters"));
var _pluginTransformPropertyLiterals = _interopRequireDefault(require("@babel/plugin-transform-property-literals"));
var _pluginTransformRegenerator = _interopRequireDefault(require("@babel/plugin-transform-regenerator"));
var _pluginTransformReservedWords = _interopRequireDefault(require("@babel/plugin-transform-reserved-words"));
var _pluginTransformShorthandProperties = _interopRequireDefault(require("@babel/plugin-transform-shorthand-properties"));
var _pluginTransformSpread = _interopRequireDefault(require("@babel/plugin-transform-spread"));
var _pluginTransformStickyRegex = _interopRequireDefault(require("@babel/plugin-transform-sticky-regex"));
var _pluginTransformTemplateLiterals = _interopRequireDefault(require("@babel/plugin-transform-template-literals"));
var _pluginTransformTypeofSymbol = _interopRequireDefault(require("@babel/plugin-transform-typeof-symbol"));
var _pluginTransformUnicodeEscapes = _interopRequireDefault(require("@babel/plugin-transform-unicode-escapes"));
var _pluginTransformUnicodeRegex = _interopRequireDefault(require("@babel/plugin-transform-unicode-regex"));
var _transformAsyncArrowsInClass = _interopRequireDefault(require("@babel/preset-modules/lib/plugins/transform-async-arrows-in-class"));
var _transformEdgeDefaultParameters = _interopRequireDefault(require("@babel/preset-modules/lib/plugins/transform-edge-default-parameters"));
var _transformEdgeFunctionName = _interopRequireDefault(require("@babel/preset-modules/lib/plugins/transform-edge-function-name"));
var _transformTaggedTemplateCaching = _interopRequireDefault(require("@babel/preset-modules/lib/plugins/transform-tagged-template-caching"));
var _transformSafariBlockShadowing = _interopRequireDefault(require("@babel/preset-modules/lib/plugins/transform-safari-block-shadowing"));
var _transformSafariForShadowing = _interopRequireDefault(require("@babel/preset-modules/lib/plugins/transform-safari-for-shadowing"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = {
"bugfix/transform-async-arrows-in-class": _transformAsyncArrowsInClass.default,
"bugfix/transform-edge-default-parameters": _transformEdgeDefaultParameters.default,
"bugfix/transform-edge-function-name": _transformEdgeFunctionName.default,
"bugfix/transform-safari-block-shadowing": _transformSafariBlockShadowing.default,
"bugfix/transform-safari-for-shadowing": _transformSafariForShadowing.default,
"bugfix/transform-tagged-template-caching": _transformTaggedTemplateCaching.default,
"proposal-async-generator-functions": _pluginProposalAsyncGeneratorFunctions.default,
"proposal-class-properties": _pluginProposalClassProperties.default,
"proposal-dynamic-import": _pluginProposalDynamicImport.default,
"proposal-export-namespace-from": _pluginProposalExportNamespaceFrom.default,
"proposal-json-strings": _pluginProposalJsonStrings.default,
"proposal-logical-assignment-operators": _pluginProposalLogicalAssignmentOperators.default,
"proposal-nullish-coalescing-operator": _pluginProposalNullishCoalescingOperator.default,
"proposal-numeric-separator": _pluginProposalNumericSeparator.default,
"proposal-object-rest-spread": _pluginProposalObjectRestSpread.default,
"proposal-optional-catch-binding": _pluginProposalOptionalCatchBinding.default,
"proposal-optional-chaining": _pluginProposalOptionalChaining.default,
"proposal-private-methods": _pluginProposalPrivateMethods.default,
"proposal-unicode-property-regex": _pluginProposalUnicodePropertyRegex.default,
"syntax-async-generators": _pluginSyntaxAsyncGenerators.default,
"syntax-class-properties": _pluginSyntaxClassProperties.default,
"syntax-dynamic-import": _pluginSyntaxDynamicImport.default,
"syntax-export-namespace-from": _pluginSyntaxExportNamespaceFrom.default,
"syntax-json-strings": _pluginSyntaxJsonStrings.default,
"syntax-logical-assignment-operators": _pluginSyntaxLogicalAssignmentOperators.default,
"syntax-nullish-coalescing-operator": _pluginSyntaxNullishCoalescingOperator.default,
"syntax-numeric-separator": _pluginSyntaxNumericSeparator.default,
"syntax-object-rest-spread": _pluginSyntaxObjectRestSpread.default,
"syntax-optional-catch-binding": _pluginSyntaxOptionalCatchBinding.default,
"syntax-optional-chaining": _pluginSyntaxOptionalChaining.default,
"syntax-top-level-await": _pluginSyntaxTopLevelAwait.default,
"transform-arrow-functions": _pluginTransformArrowFunctions.default,
"transform-async-to-generator": _pluginTransformAsyncToGenerator.default,
"transform-block-scoped-functions": _pluginTransformBlockScopedFunctions.default,
"transform-block-scoping": _pluginTransformBlockScoping.default,
"transform-classes": _pluginTransformClasses.default,
"transform-computed-properties": _pluginTransformComputedProperties.default,
"transform-destructuring": _pluginTransformDestructuring.default,
"transform-dotall-regex": _pluginTransformDotallRegex.default,
"transform-duplicate-keys": _pluginTransformDuplicateKeys.default,
"transform-exponentiation-operator": _pluginTransformExponentiationOperator.default,
"transform-for-of": _pluginTransformForOf.default,
"transform-function-name": _pluginTransformFunctionName.default,
"transform-literals": _pluginTransformLiterals.default,
"transform-member-expression-literals": _pluginTransformMemberExpressionLiterals.default,
"transform-modules-amd": _pluginTransformModulesAmd.default,
"transform-modules-commonjs": _pluginTransformModulesCommonjs.default,
"transform-modules-systemjs": _pluginTransformModulesSystemjs.default,
"transform-modules-umd": _pluginTransformModulesUmd.default,
"transform-named-capturing-groups-regex": _pluginTransformNamedCapturingGroupsRegex.default,
"transform-new-target": _pluginTransformNewTarget.default,
"transform-object-super": _pluginTransformObjectSuper.default,
"transform-parameters": _pluginTransformParameters.default,
"transform-property-literals": _pluginTransformPropertyLiterals.default,
"transform-regenerator": _pluginTransformRegenerator.default,
"transform-reserved-words": _pluginTransformReservedWords.default,
"transform-shorthand-properties": _pluginTransformShorthandProperties.default,
"transform-spread": _pluginTransformSpread.default,
"transform-sticky-regex": _pluginTransformStickyRegex.default,
"transform-template-literals": _pluginTransformTemplateLiterals.default,
"transform-typeof-symbol": _pluginTransformTypeofSymbol.default,
"transform-unicode-escapes": _pluginTransformUnicodeEscapes.default,
"transform-unicode-regex": _pluginTransformUnicodeRegex.default
};
exports.default = _default;
@@ -0,0 +1,63 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.logUsagePolyfills = exports.logEntryPolyfills = exports.logPluginOrPolyfill = void 0;
var _helperCompilationTargets = require("@babel/helper-compilation-targets");
const wordEnds = size => {
return size > 1 ? "s" : "";
};
const logPluginOrPolyfill = (item, targetVersions, list) => {
const filteredList = (0, _helperCompilationTargets.getInclusionReasons)(item, targetVersions, list);
const formattedTargets = JSON.stringify(filteredList).replace(/,/g, ", ").replace(/^\{"/, '{ "').replace(/"\}$/, '" }');
console.log(` ${item} ${formattedTargets}`);
};
exports.logPluginOrPolyfill = logPluginOrPolyfill;
const logEntryPolyfills = (polyfillName, importPolyfillIncluded, polyfills, filename, polyfillTargets, allBuiltInsList) => {
if (process.env.BABEL_ENV === "test") {
filename = filename.replace(/\\/g, "/");
}
if (!importPolyfillIncluded) {
console.log(`\n[${filename}] Import of ${polyfillName} was not found.`);
return;
}
if (!polyfills.size) {
console.log(`\n[${filename}] Based on your targets, polyfills were not added.`);
return;
}
console.log(`\n[${filename}] Replaced ${polyfillName} entries with the following polyfill${wordEnds(polyfills.size)}:`);
for (const polyfill of polyfills) {
logPluginOrPolyfill(polyfill, polyfillTargets, allBuiltInsList);
}
};
exports.logEntryPolyfills = logEntryPolyfills;
const logUsagePolyfills = (polyfills, filename, polyfillTargets, allBuiltInsList) => {
if (process.env.BABEL_ENV === "test") {
filename = filename.replace(/\\/g, "/");
}
if (!polyfills.size) {
console.log(`\n[${filename}] Based on your code and targets, core-js polyfills were not added.`);
return;
}
console.log(`\n[${filename}] Added following core-js polyfill${wordEnds(polyfills.size)}:`);
for (const polyfill of polyfills) {
logPluginOrPolyfill(polyfill, polyfillTargets, allBuiltInsList);
}
};
exports.logUsagePolyfills = logUsagePolyfills;
@@ -0,0 +1,14 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.removeUnnecessaryItems = removeUnnecessaryItems;
function removeUnnecessaryItems(items, overlapping) {
items.forEach(item => {
var _overlapping$item;
(_overlapping$item = overlapping[item]) == null ? void 0 : _overlapping$item.forEach(name => items.delete(name));
});
}
@@ -0,0 +1,13 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
const defaultExcludesForLooseMode = ["transform-typeof-symbol"];
function _default({
loose
}) {
return loose ? defaultExcludesForLooseMode : null;
}
@@ -0,0 +1,332 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.isPluginRequired = isPluginRequired;
exports.default = exports.getPolyfillPlugins = exports.getModulesPluginNames = exports.transformIncludesAndExcludes = void 0;
var _semver = require("semver");
var _debug = require("./debug");
var _getOptionSpecificExcludes = _interopRequireDefault(require("./get-option-specific-excludes"));
var _filterItems = require("./filter-items");
var _moduleTransformations = _interopRequireDefault(require("./module-transformations"));
var _normalizeOptions = _interopRequireDefault(require("./normalize-options"));
var _shippedProposals = require("../data/shipped-proposals");
var _pluginsCompatData = require("./plugins-compat-data");
var _overlappingPlugins = _interopRequireDefault(require("@babel/compat-data/overlapping-plugins"));
var _usagePlugin = _interopRequireDefault(require("./polyfills/corejs2/usage-plugin"));
var _usagePlugin2 = _interopRequireDefault(require("./polyfills/corejs3/usage-plugin"));
var _usagePlugin3 = _interopRequireDefault(require("./polyfills/regenerator/usage-plugin"));
var _entryPlugin = _interopRequireDefault(require("./polyfills/corejs2/entry-plugin"));
var _entryPlugin2 = _interopRequireDefault(require("./polyfills/corejs3/entry-plugin"));
var _entryPlugin3 = _interopRequireDefault(require("./polyfills/regenerator/entry-plugin"));
var _helperCompilationTargets = _interopRequireWildcard(require("@babel/helper-compilation-targets"));
var _availablePlugins = _interopRequireDefault(require("./available-plugins"));
var _utils = require("./utils");
var _helperPluginUtils = require("@babel/helper-plugin-utils");
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function isPluginRequired(targets, support) {
return (0, _helperCompilationTargets.isRequired)("fake-name", targets, {
compatData: {
"fake-name": support
}
});
}
const pluginLists = {
withProposals: {
withoutBugfixes: _pluginsCompatData.plugins,
withBugfixes: Object.assign({}, _pluginsCompatData.plugins, _pluginsCompatData.pluginsBugfixes)
},
withoutProposals: {
withoutBugfixes: (0, _utils.filterStageFromList)(_pluginsCompatData.plugins, _shippedProposals.proposalPlugins),
withBugfixes: (0, _utils.filterStageFromList)(Object.assign({}, _pluginsCompatData.plugins, _pluginsCompatData.pluginsBugfixes), _shippedProposals.proposalPlugins)
}
};
function getPluginList(proposals, bugfixes) {
if (proposals) {
if (bugfixes) return pluginLists.withProposals.withBugfixes;else return pluginLists.withProposals.withoutBugfixes;
} else {
if (bugfixes) return pluginLists.withoutProposals.withBugfixes;else return pluginLists.withoutProposals.withoutBugfixes;
}
}
const getPlugin = pluginName => {
const plugin = _availablePlugins.default[pluginName];
if (!plugin) {
throw new Error(`Could not find plugin "${pluginName}". Ensure there is an entry in ./available-plugins.js for it.`);
}
return plugin;
};
const transformIncludesAndExcludes = opts => {
return opts.reduce((result, opt) => {
const target = opt.match(/^(es|es6|es7|esnext|web)\./) ? "builtIns" : "plugins";
result[target].add(opt);
return result;
}, {
all: opts,
plugins: new Set(),
builtIns: new Set()
});
};
exports.transformIncludesAndExcludes = transformIncludesAndExcludes;
const getModulesPluginNames = ({
modules,
transformations,
shouldTransformESM,
shouldTransformDynamicImport,
shouldTransformExportNamespaceFrom,
shouldParseTopLevelAwait
}) => {
const modulesPluginNames = [];
if (modules !== false && transformations[modules]) {
if (shouldTransformESM) {
modulesPluginNames.push(transformations[modules]);
}
if (shouldTransformDynamicImport && shouldTransformESM && modules !== "umd") {
modulesPluginNames.push("proposal-dynamic-import");
} else {
if (shouldTransformDynamicImport) {
console.warn("Dynamic import can only be supported when transforming ES modules" + " to AMD, CommonJS or SystemJS. Only the parser plugin will be enabled.");
}
modulesPluginNames.push("syntax-dynamic-import");
}
} else {
modulesPluginNames.push("syntax-dynamic-import");
}
if (shouldTransformExportNamespaceFrom) {
modulesPluginNames.push("proposal-export-namespace-from");
} else {
modulesPluginNames.push("syntax-export-namespace-from");
}
if (shouldParseTopLevelAwait) {
modulesPluginNames.push("syntax-top-level-await");
}
return modulesPluginNames;
};
exports.getModulesPluginNames = getModulesPluginNames;
const getPolyfillPlugins = ({
useBuiltIns,
corejs,
polyfillTargets,
include,
exclude,
proposals,
shippedProposals,
regenerator,
debug
}) => {
const polyfillPlugins = [];
if (useBuiltIns === "usage" || useBuiltIns === "entry") {
const pluginOptions = {
corejs,
polyfillTargets,
include,
exclude,
proposals,
shippedProposals,
regenerator,
debug
};
if (corejs) {
if (useBuiltIns === "usage") {
if (corejs.major === 2) {
polyfillPlugins.push([_usagePlugin.default, pluginOptions]);
} else {
polyfillPlugins.push([_usagePlugin2.default, pluginOptions]);
}
if (regenerator) {
polyfillPlugins.push([_usagePlugin3.default, pluginOptions]);
}
} else {
if (corejs.major === 2) {
polyfillPlugins.push([_entryPlugin.default, pluginOptions]);
} else {
polyfillPlugins.push([_entryPlugin2.default, pluginOptions]);
if (!regenerator) {
polyfillPlugins.push([_entryPlugin3.default, pluginOptions]);
}
}
}
}
}
return polyfillPlugins;
};
exports.getPolyfillPlugins = getPolyfillPlugins;
function supportsStaticESM(caller) {
return !!(caller == null ? void 0 : caller.supportsStaticESM);
}
function supportsDynamicImport(caller) {
return !!(caller == null ? void 0 : caller.supportsDynamicImport);
}
function supportsExportNamespaceFrom(caller) {
return !!(caller == null ? void 0 : caller.supportsExportNamespaceFrom);
}
function supportsTopLevelAwait(caller) {
return !!(caller == null ? void 0 : caller.supportsTopLevelAwait);
}
var _default = (0, _helperPluginUtils.declare)((api, opts) => {
api.assertVersion(7);
const {
bugfixes,
configPath,
debug,
exclude: optionsExclude,
forceAllTransforms,
ignoreBrowserslistConfig,
include: optionsInclude,
loose,
modules,
shippedProposals,
spec,
targets: optionsTargets,
useBuiltIns,
corejs: {
version: corejs,
proposals
},
browserslistEnv
} = (0, _normalizeOptions.default)(opts);
let hasUglifyTarget = false;
if (optionsTargets == null ? void 0 : optionsTargets.uglify) {
hasUglifyTarget = true;
delete optionsTargets.uglify;
console.log("");
console.log("The uglify target has been deprecated. Set the top level");
console.log("option `forceAllTransforms: true` instead.");
console.log("");
}
if ((optionsTargets == null ? void 0 : optionsTargets.esmodules) && optionsTargets.browsers) {
console.log("");
console.log("@babel/preset-env: esmodules and browsers targets have been specified together.");
console.log(`\`browsers\` target, \`${optionsTargets.browsers}\` will be ignored.`);
console.log("");
}
const targets = (0, _helperCompilationTargets.default)(optionsTargets, {
ignoreBrowserslistConfig,
configPath,
browserslistEnv
});
const include = transformIncludesAndExcludes(optionsInclude);
const exclude = transformIncludesAndExcludes(optionsExclude);
const transformTargets = forceAllTransforms || hasUglifyTarget ? {} : targets;
const compatData = getPluginList(shippedProposals, bugfixes);
const shouldSkipExportNamespaceFrom = modules === "auto" && (api.caller == null ? void 0 : api.caller(supportsExportNamespaceFrom)) || modules === false && !(0, _helperCompilationTargets.isRequired)("proposal-export-namespace-from", transformTargets, {
compatData,
includes: include.plugins,
excludes: exclude.plugins
});
const modulesPluginNames = getModulesPluginNames({
modules,
transformations: _moduleTransformations.default,
shouldTransformESM: modules !== "auto" || !(api.caller == null ? void 0 : api.caller(supportsStaticESM)),
shouldTransformDynamicImport: modules !== "auto" || !(api.caller == null ? void 0 : api.caller(supportsDynamicImport)),
shouldTransformExportNamespaceFrom: !shouldSkipExportNamespaceFrom,
shouldParseTopLevelAwait: !api.caller || api.caller(supportsTopLevelAwait)
});
const pluginNames = (0, _helperCompilationTargets.filterItems)(compatData, include.plugins, exclude.plugins, transformTargets, modulesPluginNames, (0, _getOptionSpecificExcludes.default)({
loose
}), _shippedProposals.pluginSyntaxMap);
(0, _filterItems.removeUnnecessaryItems)(pluginNames, _overlappingPlugins.default);
const polyfillPlugins = getPolyfillPlugins({
useBuiltIns,
corejs,
polyfillTargets: targets,
include: include.builtIns,
exclude: exclude.builtIns,
proposals,
shippedProposals,
regenerator: pluginNames.has("transform-regenerator"),
debug
});
const pluginUseBuiltIns = useBuiltIns !== false;
const plugins = Array.from(pluginNames).map(pluginName => {
if (pluginName === "proposal-class-properties" || pluginName === "proposal-private-methods" || pluginName === "proposal-private-property-in-object") {
return [getPlugin(pluginName), {
loose: loose ? "#__internal__@babel/preset-env__prefer-true-but-false-is-ok-if-it-prevents-an-error" : "#__internal__@babel/preset-env__prefer-false-but-true-is-ok-if-it-prevents-an-error"
}];
}
return [getPlugin(pluginName), {
spec,
loose,
useBuiltIns: pluginUseBuiltIns
}];
}).concat(polyfillPlugins);
if (debug) {
console.log("@babel/preset-env: `DEBUG` option");
console.log("\nUsing targets:");
console.log(JSON.stringify((0, _helperCompilationTargets.prettifyTargets)(targets), null, 2));
console.log(`\nUsing modules transform: ${modules.toString()}`);
console.log("\nUsing plugins:");
pluginNames.forEach(pluginName => {
(0, _debug.logPluginOrPolyfill)(pluginName, targets, _pluginsCompatData.plugins);
});
if (!useBuiltIns) {
console.log("\nUsing polyfills: No polyfills were added, since the `useBuiltIns` option was not set.");
} else {
console.log(`\nUsing polyfills with \`${useBuiltIns}\` option:`);
}
}
return {
plugins
};
});
exports.default = _default;
@@ -0,0 +1,15 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _default = {
auto: "transform-modules-commonjs",
amd: "transform-modules-amd",
commonjs: "transform-modules-commonjs",
cjs: "transform-modules-commonjs",
systemjs: "transform-modules-systemjs",
umd: "transform-modules-umd"
};
exports.default = _default;
@@ -0,0 +1,152 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.normalizeCoreJSOption = normalizeCoreJSOption;
exports.default = normalizeOptions;
exports.validateUseBuiltInsOption = exports.validateModulesOption = exports.checkDuplicateIncludeExcludes = exports.normalizePluginName = void 0;
var _data = _interopRequireDefault(require("core-js-compat/data"));
var _semver = require("semver");
var _corejs2BuiltIns = _interopRequireDefault(require("@babel/compat-data/corejs2-built-ins"));
var _pluginsCompatData = require("./plugins-compat-data");
var _moduleTransformations = _interopRequireDefault(require("./module-transformations"));
var _options = require("./options");
var _helperValidatorOption = require("@babel/helper-validator-option");
var _getPlatformSpecificDefault = require("./polyfills/corejs2/get-platform-specific-default");
var _package = require("../package.json");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const v = new _helperValidatorOption.OptionValidator(_package.name);
const allPluginsList = Object.keys(_pluginsCompatData.plugins);
const modulePlugins = ["proposal-dynamic-import", ...Object.keys(_moduleTransformations.default).map(m => _moduleTransformations.default[m])];
const getValidIncludesAndExcludes = (type, corejs) => new Set([...allPluginsList, ...(type === "exclude" ? modulePlugins : []), ...(corejs ? corejs == 2 ? [...Object.keys(_corejs2BuiltIns.default), ..._getPlatformSpecificDefault.defaultWebIncludes] : Object.keys(_data.default) : [])]);
const pluginToRegExp = plugin => {
if (plugin instanceof RegExp) return plugin;
try {
return new RegExp(`^${normalizePluginName(plugin)}$`);
} catch (e) {
return null;
}
};
const selectPlugins = (regexp, type, corejs) => Array.from(getValidIncludesAndExcludes(type, corejs)).filter(item => regexp instanceof RegExp && regexp.test(item));
const flatten = array => [].concat(...array);
const expandIncludesAndExcludes = (plugins = [], type, corejs) => {
if (plugins.length === 0) return [];
const selectedPlugins = plugins.map(plugin => selectPlugins(pluginToRegExp(plugin), type, corejs));
const invalidRegExpList = plugins.filter((p, i) => selectedPlugins[i].length === 0);
v.invariant(invalidRegExpList.length === 0, `The plugins/built-ins '${invalidRegExpList.join(", ")}' passed to the '${type}' option are not
valid. Please check data/[plugin-features|built-in-features].js in babel-preset-env`);
return flatten(selectedPlugins);
};
const normalizePluginName = plugin => plugin.replace(/^(@babel\/|babel-)(plugin-)?/, "");
exports.normalizePluginName = normalizePluginName;
const checkDuplicateIncludeExcludes = (include = [], exclude = []) => {
const duplicates = include.filter(opt => exclude.indexOf(opt) >= 0);
v.invariant(duplicates.length === 0, `The plugins/built-ins '${duplicates.join(", ")}' were found in both the "include" and
"exclude" options.`);
};
exports.checkDuplicateIncludeExcludes = checkDuplicateIncludeExcludes;
const normalizeTargets = targets => {
if (typeof targets === "string" || Array.isArray(targets)) {
return {
browsers: targets
};
}
return Object.assign({}, targets);
};
const validateModulesOption = (modulesOpt = _options.ModulesOption.auto) => {
v.invariant(_options.ModulesOption[modulesOpt.toString()] || modulesOpt === _options.ModulesOption.false, `The 'modules' option must be one of \n` + ` - 'false' to indicate no module processing\n` + ` - a specific module type: 'commonjs', 'amd', 'umd', 'systemjs'` + ` - 'auto' (default) which will automatically select 'false' if the current\n` + ` process is known to support ES module syntax, or "commonjs" otherwise\n`);
return modulesOpt;
};
exports.validateModulesOption = validateModulesOption;
const validateUseBuiltInsOption = (builtInsOpt = false) => {
v.invariant(_options.UseBuiltInsOption[builtInsOpt.toString()] || builtInsOpt === _options.UseBuiltInsOption.false, `The 'useBuiltIns' option must be either
'false' (default) to indicate no polyfill,
'"entry"' to indicate replacing the entry polyfill, or
'"usage"' to import only used polyfills per file`);
return builtInsOpt;
};
exports.validateUseBuiltInsOption = validateUseBuiltInsOption;
function normalizeCoreJSOption(corejs, useBuiltIns) {
let proposals = false;
let rawVersion;
if (useBuiltIns && corejs === undefined) {
rawVersion = 2;
console.warn("\nWARNING: We noticed you're using the `useBuiltIns` option without declaring a " + "core-js version. Currently, we assume version 2.x when no version " + "is passed. Since this default version will likely change in future " + "versions of Babel, we recommend explicitly setting the core-js version " + "you are using via the `corejs` option.\n" + "\nYou should also be sure that the version you pass to the `corejs` " + "option matches the version specified in your `package.json`'s " + "`dependencies` section. If it doesn't, you need to run one of the " + "following commands:\n\n" + " npm install --save core-js@2 npm install --save core-js@3\n" + " yarn add core-js@2 yarn add core-js@3\n");
} else if (typeof corejs === "object" && corejs !== null) {
rawVersion = corejs.version;
proposals = Boolean(corejs.proposals);
} else {
rawVersion = corejs;
}
const version = rawVersion ? (0, _semver.coerce)(String(rawVersion)) : false;
if (!useBuiltIns && version) {
console.log("\nThe `corejs` option only has an effect when the `useBuiltIns` option is not `false`\n");
}
if (useBuiltIns && (!version || version.major < 2 || version.major > 3)) {
throw new RangeError("Invalid Option: The version passed to `corejs` is invalid. Currently, " + "only core-js@2 and core-js@3 are supported.");
}
return {
version,
proposals
};
}
function normalizeOptions(opts) {
v.validateTopLevelOptions(opts, _options.TopLevelOptions);
const useBuiltIns = validateUseBuiltInsOption(opts.useBuiltIns);
const corejs = normalizeCoreJSOption(opts.corejs, useBuiltIns);
const include = expandIncludesAndExcludes(opts.include, _options.TopLevelOptions.include, !!corejs.version && corejs.version.major);
const exclude = expandIncludesAndExcludes(opts.exclude, _options.TopLevelOptions.exclude, !!corejs.version && corejs.version.major);
checkDuplicateIncludeExcludes(include, exclude);
return {
bugfixes: v.validateBooleanOption(_options.TopLevelOptions.bugfixes, opts.bugfixes, false),
configPath: v.validateStringOption(_options.TopLevelOptions.configPath, opts.configPath, process.cwd()),
corejs,
debug: v.validateBooleanOption(_options.TopLevelOptions.debug, opts.debug, false),
include,
exclude,
forceAllTransforms: v.validateBooleanOption(_options.TopLevelOptions.forceAllTransforms, opts.forceAllTransforms, false),
ignoreBrowserslistConfig: v.validateBooleanOption(_options.TopLevelOptions.ignoreBrowserslistConfig, opts.ignoreBrowserslistConfig, false),
loose: v.validateBooleanOption(_options.TopLevelOptions.loose, opts.loose, false),
modules: validateModulesOption(opts.modules),
shippedProposals: v.validateBooleanOption(_options.TopLevelOptions.shippedProposals, opts.shippedProposals, false),
spec: v.validateBooleanOption(_options.TopLevelOptions.spec, opts.spec, false),
targets: normalizeTargets(opts.targets),
useBuiltIns: useBuiltIns,
browserslistEnv: v.validateStringOption(_options.TopLevelOptions.browserslistEnv, opts.browserslistEnv)
};
}
@@ -0,0 +1,40 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.UseBuiltInsOption = exports.ModulesOption = exports.TopLevelOptions = void 0;
const TopLevelOptions = {
bugfixes: "bugfixes",
configPath: "configPath",
corejs: "corejs",
debug: "debug",
exclude: "exclude",
forceAllTransforms: "forceAllTransforms",
ignoreBrowserslistConfig: "ignoreBrowserslistConfig",
include: "include",
loose: "loose",
modules: "modules",
shippedProposals: "shippedProposals",
spec: "spec",
targets: "targets",
useBuiltIns: "useBuiltIns",
browserslistEnv: "browserslistEnv"
};
exports.TopLevelOptions = TopLevelOptions;
const ModulesOption = {
false: false,
auto: "auto",
amd: "amd",
commonjs: "commonjs",
cjs: "cjs",
systemjs: "systemjs",
umd: "umd"
};
exports.ModulesOption = ModulesOption;
const UseBuiltInsOption = {
false: false,
entry: "entry",
usage: "usage"
};
exports.UseBuiltInsOption = UseBuiltInsOption;
@@ -0,0 +1,33 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.pluginsBugfixes = exports.plugins = void 0;
var _plugins = _interopRequireDefault(require("@babel/compat-data/plugins"));
var _pluginBugfixes = _interopRequireDefault(require("@babel/compat-data/plugin-bugfixes"));
var _availablePlugins = _interopRequireDefault(require("./available-plugins"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const pluginsFiltered = {};
exports.plugins = pluginsFiltered;
const bugfixPluginsFiltered = {};
exports.pluginsBugfixes = bugfixPluginsFiltered;
for (const plugin of Object.keys(_plugins.default)) {
if (Object.hasOwnProperty.call(_availablePlugins.default, plugin)) {
pluginsFiltered[plugin] = _plugins.default[plugin];
}
}
for (const plugin of Object.keys(_pluginBugfixes.default)) {
if (Object.hasOwnProperty.call(_availablePlugins.default, plugin)) {
bugfixPluginsFiltered[plugin] = _pluginBugfixes.default[plugin];
}
}
pluginsFiltered["proposal-class-properties"] = pluginsFiltered["proposal-private-methods"];
@@ -0,0 +1,175 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.StaticProperties = exports.InstanceProperties = exports.BuiltIns = void 0;
const ArrayNatureIterators = ["es6.object.to-string", "es6.array.iterator", "web.dom.iterable"];
const CommonIterators = ["es6.string.iterator", ...ArrayNatureIterators];
const PromiseDependencies = ["es6.object.to-string", "es6.promise"];
const BuiltIns = {
DataView: "es6.typed.data-view",
Float32Array: "es6.typed.float32-array",
Float64Array: "es6.typed.float64-array",
Int8Array: "es6.typed.int8-array",
Int16Array: "es6.typed.int16-array",
Int32Array: "es6.typed.int32-array",
Map: ["es6.map", ...CommonIterators],
Number: "es6.number.constructor",
Promise: PromiseDependencies,
RegExp: ["es6.regexp.constructor"],
Set: ["es6.set", ...CommonIterators],
Symbol: ["es6.symbol", "es7.symbol.async-iterator"],
Uint8Array: "es6.typed.uint8-array",
Uint8ClampedArray: "es6.typed.uint8-clamped-array",
Uint16Array: "es6.typed.uint16-array",
Uint32Array: "es6.typed.uint32-array",
WeakMap: ["es6.weak-map", ...CommonIterators],
WeakSet: ["es6.weak-set", ...CommonIterators]
};
exports.BuiltIns = BuiltIns;
const InstanceProperties = {
__defineGetter__: ["es7.object.define-getter"],
__defineSetter__: ["es7.object.define-setter"],
__lookupGetter__: ["es7.object.lookup-getter"],
__lookupSetter__: ["es7.object.lookup-setter"],
anchor: ["es6.string.anchor"],
big: ["es6.string.big"],
bind: ["es6.function.bind"],
blink: ["es6.string.blink"],
bold: ["es6.string.bold"],
codePointAt: ["es6.string.code-point-at"],
copyWithin: ["es6.array.copy-within"],
endsWith: ["es6.string.ends-with"],
entries: ArrayNatureIterators,
every: ["es6.array.is-array"],
fill: ["es6.array.fill"],
filter: ["es6.array.filter"],
finally: ["es7.promise.finally", ...PromiseDependencies],
find: ["es6.array.find"],
findIndex: ["es6.array.find-index"],
fixed: ["es6.string.fixed"],
flags: ["es6.regexp.flags"],
flatMap: ["es7.array.flat-map"],
fontcolor: ["es6.string.fontcolor"],
fontsize: ["es6.string.fontsize"],
forEach: ["es6.array.for-each"],
includes: ["es6.string.includes", "es7.array.includes"],
indexOf: ["es6.array.index-of"],
italics: ["es6.string.italics"],
keys: ArrayNatureIterators,
lastIndexOf: ["es6.array.last-index-of"],
link: ["es6.string.link"],
map: ["es6.array.map"],
match: ["es6.regexp.match"],
name: ["es6.function.name"],
padStart: ["es7.string.pad-start"],
padEnd: ["es7.string.pad-end"],
reduce: ["es6.array.reduce"],
reduceRight: ["es6.array.reduce-right"],
repeat: ["es6.string.repeat"],
replace: ["es6.regexp.replace"],
search: ["es6.regexp.search"],
slice: ["es6.array.slice"],
small: ["es6.string.small"],
some: ["es6.array.some"],
sort: ["es6.array.sort"],
split: ["es6.regexp.split"],
startsWith: ["es6.string.starts-with"],
strike: ["es6.string.strike"],
sub: ["es6.string.sub"],
sup: ["es6.string.sup"],
toISOString: ["es6.date.to-iso-string"],
toJSON: ["es6.date.to-json"],
toString: ["es6.object.to-string", "es6.date.to-string", "es6.regexp.to-string"],
trim: ["es6.string.trim"],
trimEnd: ["es7.string.trim-right"],
trimLeft: ["es7.string.trim-left"],
trimRight: ["es7.string.trim-right"],
trimStart: ["es7.string.trim-left"],
values: ArrayNatureIterators
};
exports.InstanceProperties = InstanceProperties;
const StaticProperties = {
Array: {
from: ["es6.array.from", "es6.string.iterator"],
isArray: "es6.array.is-array",
of: "es6.array.of"
},
Date: {
now: "es6.date.now"
},
Object: {
assign: "es6.object.assign",
create: "es6.object.create",
defineProperty: "es6.object.define-property",
defineProperties: "es6.object.define-properties",
entries: "es7.object.entries",
freeze: "es6.object.freeze",
getOwnPropertyDescriptors: "es7.object.get-own-property-descriptors",
getOwnPropertySymbols: "es6.symbol",
is: "es6.object.is",
isExtensible: "es6.object.is-extensible",
isFrozen: "es6.object.is-frozen",
isSealed: "es6.object.is-sealed",
keys: "es6.object.keys",
preventExtensions: "es6.object.prevent-extensions",
seal: "es6.object.seal",
setPrototypeOf: "es6.object.set-prototype-of",
values: "es7.object.values"
},
Math: {
acosh: "es6.math.acosh",
asinh: "es6.math.asinh",
atanh: "es6.math.atanh",
cbrt: "es6.math.cbrt",
clz32: "es6.math.clz32",
cosh: "es6.math.cosh",
expm1: "es6.math.expm1",
fround: "es6.math.fround",
hypot: "es6.math.hypot",
imul: "es6.math.imul",
log1p: "es6.math.log1p",
log10: "es6.math.log10",
log2: "es6.math.log2",
sign: "es6.math.sign",
sinh: "es6.math.sinh",
tanh: "es6.math.tanh",
trunc: "es6.math.trunc"
},
String: {
fromCodePoint: "es6.string.from-code-point",
raw: "es6.string.raw"
},
Number: {
EPSILON: "es6.number.epsilon",
MIN_SAFE_INTEGER: "es6.number.min-safe-integer",
MAX_SAFE_INTEGER: "es6.number.max-safe-integer",
isFinite: "es6.number.is-finite",
isInteger: "es6.number.is-integer",
isSafeInteger: "es6.number.is-safe-integer",
isNaN: "es6.number.is-nan",
parseFloat: "es6.number.parse-float",
parseInt: "es6.number.parse-int"
},
Promise: {
all: CommonIterators,
race: CommonIterators
},
Reflect: {
apply: "es6.reflect.apply",
construct: "es6.reflect.construct",
defineProperty: "es6.reflect.define-property",
deleteProperty: "es6.reflect.delete-property",
get: "es6.reflect.get",
getOwnPropertyDescriptor: "es6.reflect.get-own-property-descriptor",
getPrototypeOf: "es6.reflect.get-prototype-of",
has: "es6.reflect.has",
isExtensible: "es6.reflect.is-extensible",
ownKeys: "es6.reflect.own-keys",
preventExtensions: "es6.reflect.prevent-extensions",
set: "es6.reflect.set",
setPrototypeOf: "es6.reflect.set-prototype-of"
}
};
exports.StaticProperties = StaticProperties;
@@ -0,0 +1,75 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _corejs2BuiltIns = _interopRequireDefault(require("@babel/compat-data/corejs2-built-ins"));
var _helperCompilationTargets = require("@babel/helper-compilation-targets");
var _getPlatformSpecificDefault = _interopRequireDefault(require("./get-platform-specific-default"));
var _utils = require("../../utils");
var _debug = require("../../debug");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function _default(_, {
include,
exclude,
polyfillTargets,
regenerator,
debug
}) {
const polyfills = (0, _helperCompilationTargets.filterItems)(_corejs2BuiltIns.default, include, exclude, polyfillTargets, (0, _getPlatformSpecificDefault.default)(polyfillTargets));
const isPolyfillImport = {
ImportDeclaration(path) {
if ((0, _utils.isPolyfillSource)((0, _utils.getImportSource)(path))) {
this.replaceBySeparateModulesImport(path);
}
},
Program(path) {
path.get("body").forEach(bodyPath => {
if ((0, _utils.isPolyfillSource)((0, _utils.getRequireSource)(bodyPath))) {
this.replaceBySeparateModulesImport(bodyPath);
}
});
}
};
return {
name: "corejs2-entry",
visitor: isPolyfillImport,
pre() {
this.importPolyfillIncluded = false;
this.replaceBySeparateModulesImport = function (path) {
this.importPolyfillIncluded = true;
if (regenerator) {
(0, _utils.createImport)(path, "regenerator-runtime");
}
const modules = Array.from(polyfills).reverse();
for (const module of modules) {
(0, _utils.createImport)(path, module);
}
path.remove();
};
},
post() {
if (debug) {
(0, _debug.logEntryPolyfills)("@babel/polyfill", this.importPolyfillIncluded, polyfills, this.file.opts.filename, polyfillTargets, _corejs2BuiltIns.default);
}
}
};
}
@@ -0,0 +1,16 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
exports.defaultWebIncludes = void 0;
const defaultWebIncludes = ["web.timers", "web.immediate", "web.dom.iterable"];
exports.defaultWebIncludes = defaultWebIncludes;
function _default(targets) {
const targetNames = Object.keys(targets);
const isAnyTarget = !targetNames.length;
const isWebTarget = targetNames.some(name => name !== "node");
return isAnyTarget || isWebTarget ? defaultWebIncludes : null;
}
@@ -0,0 +1,217 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _corejs2BuiltIns = _interopRequireDefault(require("@babel/compat-data/corejs2-built-ins"));
var _helperCompilationTargets = require("@babel/helper-compilation-targets");
var _getPlatformSpecificDefault = _interopRequireDefault(require("./get-platform-specific-default"));
var _builtInDefinitions = require("./built-in-definitions");
var _utils = require("../../utils");
var _debug = require("../../debug");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const NO_DIRECT_POLYFILL_IMPORT = `
When setting \`useBuiltIns: 'usage'\`, polyfills are automatically imported when needed.
Please remove the \`import '@babel/polyfill'\` call or use \`useBuiltIns: 'entry'\` instead.`;
function _default({
types: t
}, {
include,
exclude,
polyfillTargets,
debug
}) {
const polyfills = (0, _helperCompilationTargets.filterItems)(_corejs2BuiltIns.default, include, exclude, polyfillTargets, (0, _getPlatformSpecificDefault.default)(polyfillTargets));
const addAndRemovePolyfillImports = {
ImportDeclaration(path) {
if ((0, _utils.isPolyfillSource)((0, _utils.getImportSource)(path))) {
console.warn(NO_DIRECT_POLYFILL_IMPORT);
path.remove();
}
},
Program(path) {
path.get("body").forEach(bodyPath => {
if ((0, _utils.isPolyfillSource)((0, _utils.getRequireSource)(bodyPath))) {
console.warn(NO_DIRECT_POLYFILL_IMPORT);
bodyPath.remove();
}
});
},
ReferencedIdentifier({
node: {
name
},
parent,
scope
}) {
if (t.isMemberExpression(parent)) return;
if (!(0, _utils.has)(_builtInDefinitions.BuiltIns, name)) return;
if (scope.getBindingIdentifier(name)) return;
const BuiltInDependencies = _builtInDefinitions.BuiltIns[name];
this.addUnsupported(BuiltInDependencies);
},
CallExpression(path) {
if (path.node.arguments.length) return;
const callee = path.node.callee;
if (!t.isMemberExpression(callee)) return;
if (!callee.computed) return;
if (!path.get("callee.property").matchesPattern("Symbol.iterator")) {
return;
}
this.addImport("web.dom.iterable");
},
BinaryExpression(path) {
if (path.node.operator !== "in") return;
if (!path.get("left").matchesPattern("Symbol.iterator")) return;
this.addImport("web.dom.iterable");
},
YieldExpression(path) {
if (path.node.delegate) {
this.addImport("web.dom.iterable");
}
},
MemberExpression: {
enter(path) {
const {
node
} = path;
const {
object,
property
} = node;
if ((0, _utils.isNamespaced)(path.get("object"))) return;
let evaluatedPropType = object.name;
let propertyName = "";
let instanceType = "";
if (node.computed) {
if (t.isStringLiteral(property)) {
propertyName = property.value;
} else {
const result = path.get("property").evaluate();
if (result.confident && result.value) {
propertyName = result.value;
}
}
} else {
propertyName = property.name;
}
if (path.scope.getBindingIdentifier(object.name)) {
const result = path.get("object").evaluate();
if (result.value) {
instanceType = (0, _utils.getType)(result.value);
} else if (result.deopt && result.deopt.isIdentifier()) {
evaluatedPropType = result.deopt.node.name;
}
}
if ((0, _utils.has)(_builtInDefinitions.StaticProperties, evaluatedPropType)) {
const BuiltInProperties = _builtInDefinitions.StaticProperties[evaluatedPropType];
if ((0, _utils.has)(BuiltInProperties, propertyName)) {
const StaticPropertyDependencies = BuiltInProperties[propertyName];
this.addUnsupported(StaticPropertyDependencies);
}
}
if ((0, _utils.has)(_builtInDefinitions.InstanceProperties, propertyName)) {
let InstancePropertyDependencies = _builtInDefinitions.InstanceProperties[propertyName];
if (instanceType) {
InstancePropertyDependencies = InstancePropertyDependencies.filter(module => module.includes(instanceType));
}
this.addUnsupported(InstancePropertyDependencies);
}
},
exit(path) {
const {
name
} = path.node.object;
if (!(0, _utils.has)(_builtInDefinitions.BuiltIns, name)) return;
if (path.scope.getBindingIdentifier(name)) return;
const BuiltInDependencies = _builtInDefinitions.BuiltIns[name];
this.addUnsupported(BuiltInDependencies);
}
},
VariableDeclarator(path) {
const {
node
} = path;
const {
id,
init
} = node;
if (!t.isObjectPattern(id)) return;
if (init && path.scope.getBindingIdentifier(init.name)) return;
for (const {
key
} of id.properties) {
if (!node.computed && t.isIdentifier(key) && (0, _utils.has)(_builtInDefinitions.InstanceProperties, key.name)) {
const InstancePropertyDependencies = _builtInDefinitions.InstanceProperties[key.name];
this.addUnsupported(InstancePropertyDependencies);
}
}
}
};
return {
name: "corejs2-usage",
pre({
path
}) {
this.polyfillsSet = new Set();
this.addImport = function (builtIn) {
if (!this.polyfillsSet.has(builtIn)) {
this.polyfillsSet.add(builtIn);
(0, _utils.createImport)(path, builtIn);
}
};
this.addUnsupported = function (builtIn) {
const modules = Array.isArray(builtIn) ? builtIn : [builtIn];
for (const module of modules) {
if (polyfills.has(module)) {
this.addImport(module);
}
}
};
},
post() {
if (debug) {
(0, _debug.logUsagePolyfills)(this.polyfillsSet, this.file.opts.filename, polyfillTargets, _corejs2BuiltIns.default);
}
},
visitor: addAndRemovePolyfillImports
};
}
@@ -0,0 +1,304 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.PossibleGlobalObjects = exports.CommonInstanceDependencies = exports.StaticProperties = exports.InstanceProperties = exports.BuiltIns = exports.PromiseDependencies = exports.CommonIterators = void 0;
const ArrayNatureIterators = ["es.array.iterator", "web.dom-collections.iterator"];
const CommonIterators = ["es.string.iterator", ...ArrayNatureIterators];
exports.CommonIterators = CommonIterators;
const ArrayNatureIteratorsWithTag = ["es.object.to-string", ...ArrayNatureIterators];
const CommonIteratorsWithTag = ["es.object.to-string", ...CommonIterators];
const TypedArrayDependencies = ["es.typed-array.copy-within", "es.typed-array.every", "es.typed-array.fill", "es.typed-array.filter", "es.typed-array.find", "es.typed-array.find-index", "es.typed-array.for-each", "es.typed-array.includes", "es.typed-array.index-of", "es.typed-array.iterator", "es.typed-array.join", "es.typed-array.last-index-of", "es.typed-array.map", "es.typed-array.reduce", "es.typed-array.reduce-right", "es.typed-array.reverse", "es.typed-array.set", "es.typed-array.slice", "es.typed-array.some", "es.typed-array.sort", "es.typed-array.subarray", "es.typed-array.to-locale-string", "es.typed-array.to-string", "es.object.to-string", "es.array.iterator", "es.array-buffer.slice"];
const TypedArrayStaticMethods = {
from: "es.typed-array.from",
of: "es.typed-array.of"
};
const PromiseDependencies = ["es.promise", "es.object.to-string"];
exports.PromiseDependencies = PromiseDependencies;
const PromiseDependenciesWithIterators = [...PromiseDependencies, ...CommonIterators];
const SymbolDependencies = ["es.symbol", "es.symbol.description", "es.object.to-string"];
const MapDependencies = ["es.map", "esnext.map.delete-all", "esnext.map.every", "esnext.map.filter", "esnext.map.find", "esnext.map.find-key", "esnext.map.includes", "esnext.map.key-of", "esnext.map.map-keys", "esnext.map.map-values", "esnext.map.merge", "esnext.map.reduce", "esnext.map.some", "esnext.map.update", ...CommonIteratorsWithTag];
const SetDependencies = ["es.set", "esnext.set.add-all", "esnext.set.delete-all", "esnext.set.difference", "esnext.set.every", "esnext.set.filter", "esnext.set.find", "esnext.set.intersection", "esnext.set.is-disjoint-from", "esnext.set.is-subset-of", "esnext.set.is-superset-of", "esnext.set.join", "esnext.set.map", "esnext.set.reduce", "esnext.set.some", "esnext.set.symmetric-difference", "esnext.set.union", ...CommonIteratorsWithTag];
const WeakMapDependencies = ["es.weak-map", "esnext.weak-map.delete-all", ...CommonIteratorsWithTag];
const WeakSetDependencies = ["es.weak-set", "esnext.weak-set.add-all", "esnext.weak-set.delete-all", ...CommonIteratorsWithTag];
const URLSearchParamsDependencies = ["web.url", ...CommonIteratorsWithTag];
const BuiltIns = {
AggregateError: ["esnext.aggregate-error", ...CommonIterators],
ArrayBuffer: ["es.array-buffer.constructor", "es.array-buffer.slice", "es.object.to-string"],
DataView: ["es.data-view", "es.array-buffer.slice", "es.object.to-string"],
Date: ["es.date.to-string"],
Float32Array: ["es.typed-array.float32-array", ...TypedArrayDependencies],
Float64Array: ["es.typed-array.float64-array", ...TypedArrayDependencies],
Int8Array: ["es.typed-array.int8-array", ...TypedArrayDependencies],
Int16Array: ["es.typed-array.int16-array", ...TypedArrayDependencies],
Int32Array: ["es.typed-array.int32-array", ...TypedArrayDependencies],
Uint8Array: ["es.typed-array.uint8-array", ...TypedArrayDependencies],
Uint8ClampedArray: ["es.typed-array.uint8-clamped-array", ...TypedArrayDependencies],
Uint16Array: ["es.typed-array.uint16-array", ...TypedArrayDependencies],
Uint32Array: ["es.typed-array.uint32-array", ...TypedArrayDependencies],
Map: MapDependencies,
Number: ["es.number.constructor"],
Observable: ["esnext.observable", "esnext.symbol.observable", "es.object.to-string", ...CommonIteratorsWithTag],
Promise: PromiseDependencies,
RegExp: ["es.regexp.constructor", "es.regexp.exec", "es.regexp.to-string"],
Set: SetDependencies,
Symbol: SymbolDependencies,
URL: ["web.url", ...URLSearchParamsDependencies],
URLSearchParams: URLSearchParamsDependencies,
WeakMap: WeakMapDependencies,
WeakSet: WeakSetDependencies,
clearImmediate: ["web.immediate"],
compositeKey: ["esnext.composite-key"],
compositeSymbol: ["esnext.composite-symbol", ...SymbolDependencies],
fetch: PromiseDependencies,
globalThis: ["es.global-this", "esnext.global-this"],
parseFloat: ["es.parse-float"],
parseInt: ["es.parse-int"],
queueMicrotask: ["web.queue-microtask"],
setTimeout: ["web.timers"],
setInterval: ["web.timers"],
setImmediate: ["web.immediate"]
};
exports.BuiltIns = BuiltIns;
const InstanceProperties = {
at: ["esnext.string.at"],
anchor: ["es.string.anchor"],
big: ["es.string.big"],
bind: ["es.function.bind"],
blink: ["es.string.blink"],
bold: ["es.string.bold"],
codePointAt: ["es.string.code-point-at"],
codePoints: ["esnext.string.code-points"],
concat: ["es.array.concat"],
copyWithin: ["es.array.copy-within"],
description: ["es.symbol", "es.symbol.description"],
endsWith: ["es.string.ends-with"],
entries: ArrayNatureIteratorsWithTag,
every: ["es.array.every"],
exec: ["es.regexp.exec"],
fill: ["es.array.fill"],
filter: ["es.array.filter"],
finally: ["es.promise.finally", ...PromiseDependencies],
find: ["es.array.find"],
findIndex: ["es.array.find-index"],
fixed: ["es.string.fixed"],
flags: ["es.regexp.flags"],
flat: ["es.array.flat", "es.array.unscopables.flat"],
flatMap: ["es.array.flat-map", "es.array.unscopables.flat-map"],
fontcolor: ["es.string.fontcolor"],
fontsize: ["es.string.fontsize"],
forEach: ["es.array.for-each", "web.dom-collections.for-each"],
includes: ["es.array.includes", "es.string.includes"],
indexOf: ["es.array.index-of"],
italics: ["es.string.italics"],
join: ["es.array.join"],
keys: ArrayNatureIteratorsWithTag,
lastIndex: ["esnext.array.last-index"],
lastIndexOf: ["es.array.last-index-of"],
lastItem: ["esnext.array.last-item"],
link: ["es.string.link"],
match: ["es.string.match", "es.regexp.exec"],
matchAll: ["es.string.match-all", "esnext.string.match-all"],
map: ["es.array.map"],
name: ["es.function.name"],
padEnd: ["es.string.pad-end"],
padStart: ["es.string.pad-start"],
reduce: ["es.array.reduce"],
reduceRight: ["es.array.reduce-right"],
repeat: ["es.string.repeat"],
replace: ["es.string.replace", "es.regexp.exec"],
replaceAll: ["esnext.string.replace-all"],
reverse: ["es.array.reverse"],
search: ["es.string.search", "es.regexp.exec"],
slice: ["es.array.slice"],
small: ["es.string.small"],
some: ["es.array.some"],
sort: ["es.array.sort"],
splice: ["es.array.splice"],
split: ["es.string.split", "es.regexp.exec"],
startsWith: ["es.string.starts-with"],
strike: ["es.string.strike"],
sub: ["es.string.sub"],
sup: ["es.string.sup"],
toFixed: ["es.number.to-fixed"],
toISOString: ["es.date.to-iso-string"],
toJSON: ["es.date.to-json", "web.url.to-json"],
toPrecision: ["es.number.to-precision"],
toString: ["es.object.to-string", "es.regexp.to-string", "es.date.to-string"],
trim: ["es.string.trim"],
trimEnd: ["es.string.trim-end"],
trimLeft: ["es.string.trim-start"],
trimRight: ["es.string.trim-end"],
trimStart: ["es.string.trim-start"],
values: ArrayNatureIteratorsWithTag,
__defineGetter__: ["es.object.define-getter"],
__defineSetter__: ["es.object.define-setter"],
__lookupGetter__: ["es.object.lookup-getter"],
__lookupSetter__: ["es.object.lookup-setter"]
};
exports.InstanceProperties = InstanceProperties;
const StaticProperties = {
Array: {
from: ["es.array.from", "es.string.iterator"],
isArray: ["es.array.is-array"],
of: ["es.array.of"]
},
Date: {
now: "es.date.now"
},
Object: {
assign: "es.object.assign",
create: "es.object.create",
defineProperty: "es.object.define-property",
defineProperties: "es.object.define-properties",
entries: "es.object.entries",
freeze: "es.object.freeze",
fromEntries: ["es.object.from-entries", "es.array.iterator"],
getOwnPropertyDescriptor: "es.object.get-own-property-descriptor",
getOwnPropertyDescriptors: "es.object.get-own-property-descriptors",
getOwnPropertyNames: "es.object.get-own-property-names",
getOwnPropertySymbols: "es.symbol",
getPrototypeOf: "es.object.get-prototype-of",
is: "es.object.is",
isExtensible: "es.object.is-extensible",
isFrozen: "es.object.is-frozen",
isSealed: "es.object.is-sealed",
keys: "es.object.keys",
preventExtensions: "es.object.prevent-extensions",
seal: "es.object.seal",
setPrototypeOf: "es.object.set-prototype-of",
values: "es.object.values"
},
Math: {
DEG_PER_RAD: "esnext.math.deg-per-rad",
RAD_PER_DEG: "esnext.math.rad-per-deg",
acosh: "es.math.acosh",
asinh: "es.math.asinh",
atanh: "es.math.atanh",
cbrt: "es.math.cbrt",
clamp: "esnext.math.clamp",
clz32: "es.math.clz32",
cosh: "es.math.cosh",
degrees: "esnext.math.degrees",
expm1: "es.math.expm1",
fround: "es.math.fround",
fscale: "esnext.math.fscale",
hypot: "es.math.hypot",
iaddh: "esnext.math.iaddh",
imul: "es.math.imul",
imulh: "esnext.math.imulh",
isubh: "esnext.math.isubh",
log1p: "es.math.log1p",
log10: "es.math.log10",
log2: "es.math.log2",
radians: "esnext.math.radians",
scale: "esnext.math.scale",
seededPRNG: "esnext.math.seeded-prng",
sign: "es.math.sign",
signbit: "esnext.math.signbit",
sinh: "es.math.sinh",
tanh: "es.math.tanh",
trunc: "es.math.trunc",
umulh: "esnext.math.umulh"
},
String: {
fromCodePoint: "es.string.from-code-point",
raw: "es.string.raw"
},
Number: {
EPSILON: "es.number.epsilon",
MIN_SAFE_INTEGER: "es.number.min-safe-integer",
MAX_SAFE_INTEGER: "es.number.max-safe-integer",
fromString: "esnext.number.from-string",
isFinite: "es.number.is-finite",
isInteger: "es.number.is-integer",
isSafeInteger: "es.number.is-safe-integer",
isNaN: "es.number.is-nan",
parseFloat: "es.number.parse-float",
parseInt: "es.number.parse-int"
},
Map: {
from: ["esnext.map.from", ...MapDependencies],
groupBy: ["esnext.map.group-by", ...MapDependencies],
keyBy: ["esnext.map.key-by", ...MapDependencies],
of: ["esnext.map.of", ...MapDependencies]
},
Set: {
from: ["esnext.set.from", ...SetDependencies],
of: ["esnext.set.of", ...SetDependencies]
},
WeakMap: {
from: ["esnext.weak-map.from", ...WeakMapDependencies],
of: ["esnext.weak-map.of", ...WeakMapDependencies]
},
WeakSet: {
from: ["esnext.weak-set.from", ...WeakSetDependencies],
of: ["esnext.weak-set.of", ...WeakSetDependencies]
},
Promise: {
all: PromiseDependenciesWithIterators,
allSettled: ["es.promise.all-settled", "esnext.promise.all-settled", ...PromiseDependenciesWithIterators],
any: ["esnext.promise.any", "esnext.aggregate-error", ...PromiseDependenciesWithIterators],
race: PromiseDependenciesWithIterators,
try: ["esnext.promise.try", ...PromiseDependenciesWithIterators]
},
Reflect: {
apply: "es.reflect.apply",
construct: "es.reflect.construct",
defineMetadata: "esnext.reflect.define-metadata",
defineProperty: "es.reflect.define-property",
deleteMetadata: "esnext.reflect.delete-metadata",
deleteProperty: "es.reflect.delete-property",
get: "es.reflect.get",
getMetadata: "esnext.reflect.get-metadata",
getMetadataKeys: "esnext.reflect.get-metadata-keys",
getOwnMetadata: "esnext.reflect.get-own-metadata",
getOwnMetadataKeys: "esnext.reflect.get-own-metadata-keys",
getOwnPropertyDescriptor: "es.reflect.get-own-property-descriptor",
getPrototypeOf: "es.reflect.get-prototype-of",
has: "es.reflect.has",
hasMetadata: "esnext.reflect.has-metadata",
hasOwnMetadata: "esnext.reflect.has-own-metadata",
isExtensible: "es.reflect.is-extensible",
metadata: "esnext.reflect.metadata",
ownKeys: "es.reflect.own-keys",
preventExtensions: "es.reflect.prevent-extensions",
set: "es.reflect.set",
setPrototypeOf: "es.reflect.set-prototype-of"
},
Symbol: {
asyncIterator: ["es.symbol.async-iterator"],
dispose: ["esnext.symbol.dispose"],
hasInstance: ["es.symbol.has-instance", "es.function.has-instance"],
isConcatSpreadable: ["es.symbol.is-concat-spreadable", "es.array.concat"],
iterator: ["es.symbol.iterator", ...CommonIteratorsWithTag],
match: ["es.symbol.match", "es.string.match"],
observable: ["esnext.symbol.observable"],
patternMatch: ["esnext.symbol.pattern-match"],
replace: ["es.symbol.replace", "es.string.replace"],
search: ["es.symbol.search", "es.string.search"],
species: ["es.symbol.species", "es.array.species"],
split: ["es.symbol.split", "es.string.split"],
toPrimitive: ["es.symbol.to-primitive", "es.date.to-primitive"],
toStringTag: ["es.symbol.to-string-tag", "es.object.to-string", "es.math.to-string-tag", "es.json.to-string-tag"],
unscopables: ["es.symbol.unscopables"]
},
ArrayBuffer: {
isView: ["es.array-buffer.is-view"]
},
Int8Array: TypedArrayStaticMethods,
Uint8Array: TypedArrayStaticMethods,
Uint8ClampedArray: TypedArrayStaticMethods,
Int16Array: TypedArrayStaticMethods,
Uint16Array: TypedArrayStaticMethods,
Int32Array: TypedArrayStaticMethods,
Uint32Array: TypedArrayStaticMethods,
Float32Array: TypedArrayStaticMethods,
Float64Array: TypedArrayStaticMethods
};
exports.StaticProperties = StaticProperties;
const CommonInstanceDependencies = new Set(["es.object.to-string", "es.object.define-getter", "es.object.define-setter", "es.object.lookup-getter", "es.object.lookup-setter", "es.regexp.exec"]);
exports.CommonInstanceDependencies = CommonInstanceDependencies;
const PossibleGlobalObjects = new Set(["global", "globalThis", "self", "window"]);
exports.PossibleGlobalObjects = PossibleGlobalObjects;
@@ -0,0 +1,131 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _data = _interopRequireDefault(require("core-js-compat/data"));
var _entries = _interopRequireDefault(require("core-js-compat/entries"));
var _getModulesListForTargetVersion = _interopRequireDefault(require("core-js-compat/get-modules-list-for-target-version"));
var _helperCompilationTargets = require("@babel/helper-compilation-targets");
var _utils = require("../../utils");
var _debug = require("../../debug");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
function isBabelPolyfillSource(source) {
return source === "@babel/polyfill" || source === "babel-polyfill";
}
function isCoreJSSource(source) {
if (typeof source === "string") {
source = source.replace(/\\/g, "/").replace(/(\/(index)?)?(\.js)?$/i, "").toLowerCase();
}
return (0, _utils.has)(_entries.default, source) && _entries.default[source];
}
const BABEL_POLYFILL_DEPRECATION = `
\`@babel/polyfill\` is deprecated. Please, use required parts of \`core-js\`
and \`regenerator-runtime/runtime\` separately`;
function _default(_, {
corejs,
include,
exclude,
polyfillTargets,
debug
}) {
const polyfills = (0, _helperCompilationTargets.filterItems)(_data.default, include, exclude, polyfillTargets, null);
const available = new Set((0, _getModulesListForTargetVersion.default)(corejs.version));
function shouldReplace(source, modules) {
if (!modules) return false;
if (modules.length === 1 && polyfills.has(modules[0]) && available.has(modules[0]) && (0, _utils.getModulePath)(modules[0]) === source) {
return false;
}
return true;
}
const isPolyfillImport = {
ImportDeclaration(path) {
const source = (0, _utils.getImportSource)(path);
if (!source) return;
if (isBabelPolyfillSource(source)) {
console.warn(BABEL_POLYFILL_DEPRECATION);
} else {
const modules = isCoreJSSource(source);
if (shouldReplace(source, modules)) {
this.replaceBySeparateModulesImport(path, modules);
}
}
},
Program: {
enter(path) {
path.get("body").forEach(bodyPath => {
const source = (0, _utils.getRequireSource)(bodyPath);
if (!source) return;
if (isBabelPolyfillSource(source)) {
console.warn(BABEL_POLYFILL_DEPRECATION);
} else {
const modules = isCoreJSSource(source);
if (shouldReplace(source, modules)) {
this.replaceBySeparateModulesImport(bodyPath, modules);
}
}
});
},
exit(path) {
const filtered = (0, _utils.intersection)(polyfills, this.polyfillsSet, available);
const reversed = Array.from(filtered).reverse();
for (const module of reversed) {
if (!this.injectedPolyfills.has(module)) {
(0, _utils.createImport)(path, module);
}
}
filtered.forEach(module => this.injectedPolyfills.add(module));
}
}
};
return {
name: "corejs3-entry",
visitor: isPolyfillImport,
pre() {
this.injectedPolyfills = new Set();
this.polyfillsSet = new Set();
this.replaceBySeparateModulesImport = function (path, modules) {
for (const module of modules) {
this.polyfillsSet.add(module);
}
path.remove();
};
},
post() {
if (debug) {
(0, _debug.logEntryPolyfills)("core-js", this.injectedPolyfills.size > 0, this.injectedPolyfills, this.file.opts.filename, polyfillTargets, _data.default);
}
}
};
}
@@ -0,0 +1,280 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _data = _interopRequireDefault(require("core-js-compat/data"));
var _corejs3ShippedProposals = _interopRequireDefault(require("@babel/compat-data/corejs3-shipped-proposals"));
var _getModulesListForTargetVersion = _interopRequireDefault(require("core-js-compat/get-modules-list-for-target-version"));
var _helperCompilationTargets = require("@babel/helper-compilation-targets");
var _builtInDefinitions = require("./built-in-definitions");
var _utils = require("../../utils");
var _debug = require("../../debug");
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
const NO_DIRECT_POLYFILL_IMPORT = `
When setting \`useBuiltIns: 'usage'\`, polyfills are automatically imported when needed.
Please remove the direct import of \`core-js\` or use \`useBuiltIns: 'entry'\` instead.`;
const corejs3PolyfillsWithoutProposals = Object.keys(_data.default).filter(name => !name.startsWith("esnext.")).reduce((memo, key) => {
memo[key] = _data.default[key];
return memo;
}, {});
const corejs3PolyfillsWithShippedProposals = _corejs3ShippedProposals.default.reduce((memo, key) => {
memo[key] = _data.default[key];
return memo;
}, Object.assign({}, corejs3PolyfillsWithoutProposals));
function _default(_, {
corejs,
include,
exclude,
polyfillTargets,
proposals,
shippedProposals,
debug
}) {
const polyfills = (0, _helperCompilationTargets.filterItems)(proposals ? _data.default : shippedProposals ? corejs3PolyfillsWithShippedProposals : corejs3PolyfillsWithoutProposals, include, exclude, polyfillTargets, null);
const available = new Set((0, _getModulesListForTargetVersion.default)(corejs.version));
function resolveKey(path, computed) {
const {
node,
parent,
scope
} = path;
if (path.isStringLiteral()) return node.value;
const {
name
} = node;
const isIdentifier = path.isIdentifier();
if (isIdentifier && !(computed || parent.computed)) return name;
if (!isIdentifier || scope.getBindingIdentifier(name)) {
const {
value
} = path.evaluate();
if (typeof value === "string") return value;
}
}
function resolveSource(path) {
const {
node,
scope
} = path;
let builtIn, instanceType;
if (node) {
builtIn = node.name;
if (!path.isIdentifier() || scope.getBindingIdentifier(builtIn)) {
const {
deopt,
value
} = path.evaluate();
if (value !== undefined) {
instanceType = (0, _utils.getType)(value);
} else if (deopt == null ? void 0 : deopt.isIdentifier()) {
builtIn = deopt.node.name;
}
}
}
return {
builtIn,
instanceType,
isNamespaced: (0, _utils.isNamespaced)(path)
};
}
const addAndRemovePolyfillImports = {
ImportDeclaration(path) {
if ((0, _utils.isPolyfillSource)((0, _utils.getImportSource)(path))) {
console.warn(NO_DIRECT_POLYFILL_IMPORT);
path.remove();
}
},
Program: {
enter(path) {
path.get("body").forEach(bodyPath => {
if ((0, _utils.isPolyfillSource)((0, _utils.getRequireSource)(bodyPath))) {
console.warn(NO_DIRECT_POLYFILL_IMPORT);
bodyPath.remove();
}
});
},
exit(path) {
const filtered = (0, _utils.intersection)(polyfills, this.polyfillsSet, available);
const reversed = Array.from(filtered).reverse();
for (const module of reversed) {
if (!this.injectedPolyfills.has(module)) {
(0, _utils.createImport)(path, module);
}
}
filtered.forEach(module => this.injectedPolyfills.add(module));
}
},
Import() {
this.addUnsupported(_builtInDefinitions.PromiseDependencies);
},
Function({
node
}) {
if (node.async) {
this.addUnsupported(_builtInDefinitions.PromiseDependencies);
}
},
"ForOfStatement|ArrayPattern"() {
this.addUnsupported(_builtInDefinitions.CommonIterators);
},
SpreadElement({
parentPath
}) {
if (!parentPath.isObjectExpression()) {
this.addUnsupported(_builtInDefinitions.CommonIterators);
}
},
YieldExpression({
node
}) {
if (node.delegate) {
this.addUnsupported(_builtInDefinitions.CommonIterators);
}
},
ReferencedIdentifier({
node: {
name
},
scope
}) {
if (scope.getBindingIdentifier(name)) return;
this.addBuiltInDependencies(name);
},
MemberExpression(path) {
const source = resolveSource(path.get("object"));
const key = resolveKey(path.get("property"));
this.addPropertyDependencies(source, key);
},
ObjectPattern(path) {
const {
parentPath,
parent,
key
} = path;
let source;
if (parentPath.isVariableDeclarator()) {
source = resolveSource(parentPath.get("init"));
} else if (parentPath.isAssignmentExpression()) {
source = resolveSource(parentPath.get("right"));
} else if (parentPath.isFunctionExpression()) {
const grand = parentPath.parentPath;
if (grand.isCallExpression() || grand.isNewExpression()) {
if (grand.node.callee === parent) {
source = resolveSource(grand.get("arguments")[key]);
}
}
}
for (const property of path.get("properties")) {
if (property.isObjectProperty()) {
const key = resolveKey(property.get("key"));
this.addPropertyDependencies(source, key);
}
}
},
BinaryExpression(path) {
if (path.node.operator !== "in") return;
const source = resolveSource(path.get("right"));
const key = resolveKey(path.get("left"), true);
this.addPropertyDependencies(source, key);
}
};
return {
name: "corejs3-usage",
pre() {
this.injectedPolyfills = new Set();
this.polyfillsSet = new Set();
this.addUnsupported = function (builtIn) {
const modules = Array.isArray(builtIn) ? builtIn : [builtIn];
for (const module of modules) {
this.polyfillsSet.add(module);
}
};
this.addBuiltInDependencies = function (builtIn) {
if ((0, _utils.has)(_builtInDefinitions.BuiltIns, builtIn)) {
const BuiltInDependencies = _builtInDefinitions.BuiltIns[builtIn];
this.addUnsupported(BuiltInDependencies);
}
};
this.addPropertyDependencies = function (source = {}, key) {
const {
builtIn,
instanceType,
isNamespaced
} = source;
if (isNamespaced) return;
if (_builtInDefinitions.PossibleGlobalObjects.has(builtIn)) {
this.addBuiltInDependencies(key);
} else if ((0, _utils.has)(_builtInDefinitions.StaticProperties, builtIn)) {
const BuiltInProperties = _builtInDefinitions.StaticProperties[builtIn];
if ((0, _utils.has)(BuiltInProperties, key)) {
const StaticPropertyDependencies = BuiltInProperties[key];
return this.addUnsupported(StaticPropertyDependencies);
}
}
if (!(0, _utils.has)(_builtInDefinitions.InstanceProperties, key)) return;
let InstancePropertyDependencies = _builtInDefinitions.InstanceProperties[key];
if (instanceType) {
InstancePropertyDependencies = InstancePropertyDependencies.filter(m => m.includes(instanceType) || _builtInDefinitions.CommonInstanceDependencies.has(m));
}
this.addUnsupported(InstancePropertyDependencies);
};
},
post() {
if (debug) {
(0, _debug.logUsagePolyfills)(this.injectedPolyfills, this.file.opts.filename, polyfillTargets, _data.default);
}
},
visitor: addAndRemovePolyfillImports
};
}
@@ -0,0 +1,54 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _utils = require("../../utils");
function isRegeneratorSource(source) {
return source === "regenerator-runtime/runtime";
}
function _default() {
const visitor = {
ImportDeclaration(path) {
if (isRegeneratorSource((0, _utils.getImportSource)(path))) {
this.regeneratorImportExcluded = true;
path.remove();
}
},
Program(path) {
path.get("body").forEach(bodyPath => {
if (isRegeneratorSource((0, _utils.getRequireSource)(bodyPath))) {
this.regeneratorImportExcluded = true;
bodyPath.remove();
}
});
}
};
return {
name: "regenerator-entry",
visitor,
pre() {
this.regeneratorImportExcluded = false;
},
post() {
if (this.opts.debug && this.regeneratorImportExcluded) {
let filename = this.file.opts.filename;
if (process.env.BABEL_ENV === "test") {
filename = filename.replace(/\\/g, "/");
}
console.log(`\n[${filename}] Based on your targets, regenerator-runtime import excluded.`);
}
}
};
}
@@ -0,0 +1,45 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
var _utils = require("../../utils");
function _default() {
return {
name: "regenerator-usage",
pre() {
this.usesRegenerator = false;
},
visitor: {
Function(path) {
const {
node
} = path;
if (!this.usesRegenerator && (node.generator || node.async)) {
this.usesRegenerator = true;
(0, _utils.createImport)(path, "regenerator-runtime");
}
}
},
post() {
if (this.opts.debug && this.usesRegenerator) {
let filename = this.file.opts.filename;
if (process.env.BABEL_ENV === "test") {
filename = filename.replace(/\\/g, "/");
}
console.log(`\n[${filename}] Based on your code and targets, added regenerator-runtime.`);
}
}
};
}
@@ -0,0 +1,29 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
Object.defineProperty(exports, "default", {
enumerable: true,
get: function () {
return _helperCompilationTargets.default;
}
});
Object.defineProperty(exports, "isBrowsersQueryValid", {
enumerable: true,
get: function () {
return _helperCompilationTargets.isBrowsersQueryValid;
}
});
Object.defineProperty(exports, "semverMin", {
enumerable: true,
get: function () {
return _helperCompilationTargets.semverMin;
}
});
var _helperCompilationTargets = _interopRequireWildcard(require("@babel/helper-compilation-targets"));
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
@@ -0,0 +1,90 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.getType = getType;
exports.intersection = intersection;
exports.filterStageFromList = filterStageFromList;
exports.getImportSource = getImportSource;
exports.getRequireSource = getRequireSource;
exports.isPolyfillSource = isPolyfillSource;
exports.getModulePath = getModulePath;
exports.createImport = createImport;
exports.isNamespaced = isNamespaced;
exports.has = void 0;
var t = _interopRequireWildcard(require("@babel/types"));
var _helperModuleImports = require("@babel/helper-module-imports");
function _getRequireWildcardCache() { if (typeof WeakMap !== "function") return null; var cache = new WeakMap(); _getRequireWildcardCache = function () { return cache; }; return cache; }
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
const has = Object.hasOwnProperty.call.bind(Object.hasOwnProperty);
exports.has = has;
function getType(target) {
return Object.prototype.toString.call(target).slice(8, -1).toLowerCase();
}
function intersection(first, second, third) {
const result = new Set();
for (const el of first) {
if (second.has(el) && third.has(el)) result.add(el);
}
return result;
}
function filterStageFromList(list, stageList) {
return Object.keys(list).reduce((result, item) => {
if (!stageList.has(item)) {
result[item] = list[item];
}
return result;
}, {});
}
function getImportSource({
node
}) {
if (node.specifiers.length === 0) return node.source.value;
}
function getRequireSource({
node
}) {
if (!t.isExpressionStatement(node)) return;
const {
expression
} = node;
const isRequire = t.isCallExpression(expression) && t.isIdentifier(expression.callee) && expression.callee.name === "require" && expression.arguments.length === 1 && t.isStringLiteral(expression.arguments[0]);
if (isRequire) return expression.arguments[0].value;
}
function isPolyfillSource(source) {
return source === "@babel/polyfill" || source === "core-js";
}
const modulePathMap = {
"regenerator-runtime": "regenerator-runtime/runtime"
};
function getModulePath(mod) {
return modulePathMap[mod] || `core-js/modules/${mod}`;
}
function createImport(path, mod) {
return (0, _helperModuleImports.addSideEffect)(path, getModulePath(mod));
}
function isNamespaced(path) {
if (!path.node) return false;
const binding = path.scope.getBinding(path.node.name);
if (!binding) return false;
return binding.path.isImportNamespaceSpecifier();
}
@@ -0,0 +1,125 @@
{
"_from": "@babel/preset-env@7.12.1",
"_id": "@babel/preset-env@7.12.1",
"_inBundle": false,
"_integrity": "sha512-H8kxXmtPaAGT7TyBvSSkoSTUK6RHh61So05SyEbpmr0MCZrsNYn7mGMzzeYoOUCdHzww61k8XBft2TaES+xPLg==",
"_location": "/babel-preset-react-app/@babel/preset-env",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@babel/preset-env@7.12.1",
"name": "@babel/preset-env",
"escapedName": "@babel%2fpreset-env",
"scope": "@babel",
"rawSpec": "7.12.1",
"saveSpec": null,
"fetchSpec": "7.12.1"
},
"_requiredBy": [
"/babel-preset-react-app"
],
"_resolved": "https://registry.npmjs.org/@babel/preset-env/-/preset-env-7.12.1.tgz",
"_shasum": "9c7e5ca82a19efc865384bb4989148d2ee5d7ac2",
"_spec": "@babel/preset-env@7.12.1",
"_where": "/Users/tylerkoenig/Code/personal/react-scss2/node_modules/babel-preset-react-app",
"author": {
"name": "Henry Zhu",
"email": "hi@henryzoo.com"
},
"bugs": {
"url": "https://github.com/babel/babel/issues"
},
"bundleDependencies": false,
"dependencies": {
"@babel/compat-data": "^7.12.1",
"@babel/helper-compilation-targets": "^7.12.1",
"@babel/helper-module-imports": "^7.12.1",
"@babel/helper-plugin-utils": "^7.10.4",
"@babel/helper-validator-option": "^7.12.1",
"@babel/plugin-proposal-async-generator-functions": "^7.12.1",
"@babel/plugin-proposal-class-properties": "^7.12.1",
"@babel/plugin-proposal-dynamic-import": "^7.12.1",
"@babel/plugin-proposal-export-namespace-from": "^7.12.1",
"@babel/plugin-proposal-json-strings": "^7.12.1",
"@babel/plugin-proposal-logical-assignment-operators": "^7.12.1",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.12.1",
"@babel/plugin-proposal-numeric-separator": "^7.12.1",
"@babel/plugin-proposal-object-rest-spread": "^7.12.1",
"@babel/plugin-proposal-optional-catch-binding": "^7.12.1",
"@babel/plugin-proposal-optional-chaining": "^7.12.1",
"@babel/plugin-proposal-private-methods": "^7.12.1",
"@babel/plugin-proposal-unicode-property-regex": "^7.12.1",
"@babel/plugin-syntax-async-generators": "^7.8.0",
"@babel/plugin-syntax-class-properties": "^7.12.1",
"@babel/plugin-syntax-dynamic-import": "^7.8.0",
"@babel/plugin-syntax-export-namespace-from": "^7.8.3",
"@babel/plugin-syntax-json-strings": "^7.8.0",
"@babel/plugin-syntax-logical-assignment-operators": "^7.10.4",
"@babel/plugin-syntax-nullish-coalescing-operator": "^7.8.0",
"@babel/plugin-syntax-numeric-separator": "^7.10.4",
"@babel/plugin-syntax-object-rest-spread": "^7.8.0",
"@babel/plugin-syntax-optional-catch-binding": "^7.8.0",
"@babel/plugin-syntax-optional-chaining": "^7.8.0",
"@babel/plugin-syntax-top-level-await": "^7.12.1",
"@babel/plugin-transform-arrow-functions": "^7.12.1",
"@babel/plugin-transform-async-to-generator": "^7.12.1",
"@babel/plugin-transform-block-scoped-functions": "^7.12.1",
"@babel/plugin-transform-block-scoping": "^7.12.1",
"@babel/plugin-transform-classes": "^7.12.1",
"@babel/plugin-transform-computed-properties": "^7.12.1",
"@babel/plugin-transform-destructuring": "^7.12.1",
"@babel/plugin-transform-dotall-regex": "^7.12.1",
"@babel/plugin-transform-duplicate-keys": "^7.12.1",
"@babel/plugin-transform-exponentiation-operator": "^7.12.1",
"@babel/plugin-transform-for-of": "^7.12.1",
"@babel/plugin-transform-function-name": "^7.12.1",
"@babel/plugin-transform-literals": "^7.12.1",
"@babel/plugin-transform-member-expression-literals": "^7.12.1",
"@babel/plugin-transform-modules-amd": "^7.12.1",
"@babel/plugin-transform-modules-commonjs": "^7.12.1",
"@babel/plugin-transform-modules-systemjs": "^7.12.1",
"@babel/plugin-transform-modules-umd": "^7.12.1",
"@babel/plugin-transform-named-capturing-groups-regex": "^7.12.1",
"@babel/plugin-transform-new-target": "^7.12.1",
"@babel/plugin-transform-object-super": "^7.12.1",
"@babel/plugin-transform-parameters": "^7.12.1",
"@babel/plugin-transform-property-literals": "^7.12.1",
"@babel/plugin-transform-regenerator": "^7.12.1",
"@babel/plugin-transform-reserved-words": "^7.12.1",
"@babel/plugin-transform-shorthand-properties": "^7.12.1",
"@babel/plugin-transform-spread": "^7.12.1",
"@babel/plugin-transform-sticky-regex": "^7.12.1",
"@babel/plugin-transform-template-literals": "^7.12.1",
"@babel/plugin-transform-typeof-symbol": "^7.12.1",
"@babel/plugin-transform-unicode-escapes": "^7.12.1",
"@babel/plugin-transform-unicode-regex": "^7.12.1",
"@babel/preset-modules": "^0.1.3",
"@babel/types": "^7.12.1",
"core-js-compat": "^3.6.2",
"semver": "^5.5.0"
},
"deprecated": false,
"description": "A Babel preset for each environment.",
"devDependencies": {
"@babel/core": "^7.12.1",
"@babel/helper-plugin-test-runner": "7.10.4",
"@babel/plugin-syntax-dynamic-import": "^7.2.0"
},
"homepage": "https://babeljs.io/",
"license": "MIT",
"main": "lib/index.js",
"name": "@babel/preset-env",
"peerDependencies": {
"@babel/core": "^7.0.0-0"
},
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/babel/babel.git",
"directory": "packages/babel-preset-env"
},
"version": "7.12.1"
}
@@ -0,0 +1,22 @@
MIT License
Copyright (c) 2014-present Sebastian McKenzie and other contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
# @babel/preset-react
> Babel preset for all React plugins.
See our website [@babel/preset-react](https://babeljs.io/docs/en/next/babel-preset-react.html) for more information or the [issues](https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22area%3A%20react%22+is%3Aopen) associated with this package.
## Install
Using npm:
```sh
npm install --save-dev @babel/preset-react
```
or using yarn:
```sh
yarn add @babel/preset-react --dev
```
@@ -0,0 +1,65 @@
"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = void 0;
var _helperPluginUtils = require("@babel/helper-plugin-utils");
var _pluginTransformReactJsx = _interopRequireDefault(require("@babel/plugin-transform-react-jsx"));
var _pluginTransformReactJsxDevelopment = _interopRequireDefault(require("@babel/plugin-transform-react-jsx-development"));
var _pluginTransformReactDisplayName = _interopRequireDefault(require("@babel/plugin-transform-react-display-name"));
var _pluginTransformReactJsxSource = _interopRequireDefault(require("@babel/plugin-transform-react-jsx-source"));
var _pluginTransformReactJsxSelf = _interopRequireDefault(require("@babel/plugin-transform-react-jsx-self"));
var _pluginTransformReactPureAnnotations = _interopRequireDefault(require("@babel/plugin-transform-react-pure-annotations"));
function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
var _default = (0, _helperPluginUtils.declare)((api, opts) => {
api.assertVersion(7);
let {
pragma,
pragmaFrag
} = opts;
const {
pure,
throwIfNamespace = true,
useSpread,
runtime = "classic",
importSource
} = opts;
if (runtime === "classic") {
pragma = pragma || "React.createElement";
pragmaFrag = pragmaFrag || "React.Fragment";
}
const development = !!opts.development;
const useBuiltIns = !!opts.useBuiltIns;
if (typeof development !== "boolean") {
throw new Error("@babel/preset-react 'development' option must be a boolean.");
}
const transformReactJSXPlugin = runtime === "automatic" && development ? _pluginTransformReactJsxDevelopment.default : _pluginTransformReactJsx.default;
return {
plugins: [[transformReactJSXPlugin, {
importSource,
pragma,
pragmaFrag,
runtime,
throwIfNamespace,
useBuiltIns,
useSpread,
pure
}], _pluginTransformReactDisplayName.default, pure !== false && _pluginTransformReactPureAnnotations.default, development && runtime === "classic" && _pluginTransformReactJsxSource.default, development && runtime === "classic" && _pluginTransformReactJsxSelf.default].filter(Boolean)
};
});
exports.default = _default;
@@ -0,0 +1,65 @@
{
"_from": "@babel/preset-react@7.12.1",
"_id": "@babel/preset-react@7.12.1",
"_inBundle": false,
"_integrity": "sha512-euCExymHCi0qB9u5fKw7rvlw7AZSjw/NaB9h7EkdTt5+yHRrXdiRTh7fkG3uBPpJg82CqLfp1LHLqWGSCrab+g==",
"_location": "/babel-preset-react-app/@babel/preset-react",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "@babel/preset-react@7.12.1",
"name": "@babel/preset-react",
"escapedName": "@babel%2fpreset-react",
"scope": "@babel",
"rawSpec": "7.12.1",
"saveSpec": null,
"fetchSpec": "7.12.1"
},
"_requiredBy": [
"/babel-preset-react-app"
],
"_resolved": "https://registry.npmjs.org/@babel/preset-react/-/preset-react-7.12.1.tgz",
"_shasum": "7f022b13f55b6dd82f00f16d1c599ae62985358c",
"_spec": "@babel/preset-react@7.12.1",
"_where": "/Users/tylerkoenig/Code/personal/react-scss2/node_modules/babel-preset-react-app",
"author": {
"name": "Sebastian McKenzie",
"email": "sebmck@gmail.com"
},
"bugs": {
"url": "https://github.com/babel/babel/issues"
},
"bundleDependencies": false,
"dependencies": {
"@babel/helper-plugin-utils": "^7.10.4",
"@babel/plugin-transform-react-display-name": "^7.12.1",
"@babel/plugin-transform-react-jsx": "^7.12.1",
"@babel/plugin-transform-react-jsx-development": "^7.12.1",
"@babel/plugin-transform-react-jsx-self": "^7.12.1",
"@babel/plugin-transform-react-jsx-source": "^7.12.1",
"@babel/plugin-transform-react-pure-annotations": "^7.12.1"
},
"deprecated": false,
"description": "Babel preset for all React plugins.",
"devDependencies": {
"@babel/core": "^7.12.1",
"@babel/helper-plugin-test-runner": "7.10.4"
},
"homepage": "https://babeljs.io/",
"license": "MIT",
"main": "lib/index.js",
"name": "@babel/preset-react",
"peerDependencies": {
"@babel/core": "^7.0.0-0"
},
"publishConfig": {
"access": "public"
},
"repository": {
"type": "git",
"url": "git+https://github.com/babel/babel.git",
"directory": "packages/babel-preset-react"
},
"version": "7.12.1"
}
@@ -0,0 +1,22 @@
MIT License
Copyright (c) 2014-present Sebastian McKenzie and other contributors
Permission is hereby granted, free of charge, to any person obtaining
a copy of this software and associated documentation files (the
"Software"), to deal in the Software without restriction, including
without limitation the rights to use, copy, modify, merge, publish,
distribute, sublicense, and/or sell copies of the Software, and to
permit persons to whom the Software is furnished to do so, subject to
the following conditions:
The above copyright notice and this permission notice shall be
included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,19 @@
# @babel/runtime
> babel's modular runtime helpers
See our website [@babel/runtime](https://babeljs.io/docs/en/next/babel-runtime.html) for more information.
## Install
Using npm:
```sh
npm install --save @babel/runtime
```
or using yarn:
```sh
yarn add @babel/runtime
```
@@ -0,0 +1,100 @@
var AwaitValue = require("./AwaitValue");
function AsyncGenerator(gen) {
var front, back;
function send(key, arg) {
return new Promise(function (resolve, reject) {
var request = {
key: key,
arg: arg,
resolve: resolve,
reject: reject,
next: null
};
if (back) {
back = back.next = request;
} else {
front = back = request;
resume(key, arg);
}
});
}
function resume(key, arg) {
try {
var result = gen[key](arg);
var value = result.value;
var wrappedAwait = value instanceof AwaitValue;
Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) {
if (wrappedAwait) {
resume(key === "return" ? "return" : "next", arg);
return;
}
settle(result.done ? "return" : "normal", arg);
}, function (err) {
resume("throw", err);
});
} catch (err) {
settle("throw", err);
}
}
function settle(type, value) {
switch (type) {
case "return":
front.resolve({
value: value,
done: true
});
break;
case "throw":
front.reject(value);
break;
default:
front.resolve({
value: value,
done: false
});
break;
}
front = front.next;
if (front) {
resume(front.key, front.arg);
} else {
back = null;
}
}
this._invoke = send;
if (typeof gen["return"] !== "function") {
this["return"] = undefined;
}
}
if (typeof Symbol === "function" && Symbol.asyncIterator) {
AsyncGenerator.prototype[Symbol.asyncIterator] = function () {
return this;
};
}
AsyncGenerator.prototype.next = function (arg) {
return this._invoke("next", arg);
};
AsyncGenerator.prototype["throw"] = function (arg) {
return this._invoke("throw", arg);
};
AsyncGenerator.prototype["return"] = function (arg) {
return this._invoke("return", arg);
};
module.exports = AsyncGenerator;
@@ -0,0 +1,5 @@
function _AwaitValue(value) {
this.wrapped = value;
}
module.exports = _AwaitValue;
@@ -0,0 +1,30 @@
function _applyDecoratedDescriptor(target, property, decorators, descriptor, context) {
var desc = {};
Object.keys(descriptor).forEach(function (key) {
desc[key] = descriptor[key];
});
desc.enumerable = !!desc.enumerable;
desc.configurable = !!desc.configurable;
if ('value' in desc || desc.initializer) {
desc.writable = true;
}
desc = decorators.slice().reverse().reduce(function (desc, decorator) {
return decorator(target, property, desc) || desc;
}, desc);
if (context && desc.initializer !== void 0) {
desc.value = desc.initializer ? desc.initializer.call(context) : void 0;
desc.initializer = undefined;
}
if (desc.initializer === void 0) {
Object.defineProperty(target, property, desc);
desc = null;
}
return desc;
}
module.exports = _applyDecoratedDescriptor;
@@ -0,0 +1,11 @@
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length) len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++) {
arr2[i] = arr[i];
}
return arr2;
}
module.exports = _arrayLikeToArray;
@@ -0,0 +1,5 @@
function _arrayWithHoles(arr) {
if (Array.isArray(arr)) return arr;
}
module.exports = _arrayWithHoles;
@@ -0,0 +1,7 @@
var arrayLikeToArray = require("./arrayLikeToArray");
function _arrayWithoutHoles(arr) {
if (Array.isArray(arr)) return arrayLikeToArray(arr);
}
module.exports = _arrayWithoutHoles;
@@ -0,0 +1,9 @@
function _assertThisInitialized(self) {
if (self === void 0) {
throw new ReferenceError("this hasn't been initialised - super() hasn't been called");
}
return self;
}
module.exports = _assertThisInitialized;
@@ -0,0 +1,58 @@
function _asyncGeneratorDelegate(inner, awaitWrap) {
var iter = {},
waiting = false;
function pump(key, value) {
waiting = true;
value = new Promise(function (resolve) {
resolve(inner[key](value));
});
return {
done: false,
value: awaitWrap(value)
};
}
;
if (typeof Symbol === "function" && Symbol.iterator) {
iter[Symbol.iterator] = function () {
return this;
};
}
iter.next = function (value) {
if (waiting) {
waiting = false;
return value;
}
return pump("next", value);
};
if (typeof inner["throw"] === "function") {
iter["throw"] = function (value) {
if (waiting) {
waiting = false;
throw value;
}
return pump("throw", value);
};
}
if (typeof inner["return"] === "function") {
iter["return"] = function (value) {
if (waiting) {
waiting = false;
return value;
}
return pump("return", value);
};
}
return iter;
}
module.exports = _asyncGeneratorDelegate;
@@ -0,0 +1,19 @@
function _asyncIterator(iterable) {
var method;
if (typeof Symbol !== "undefined") {
if (Symbol.asyncIterator) {
method = iterable[Symbol.asyncIterator];
if (method != null) return method.call(iterable);
}
if (Symbol.iterator) {
method = iterable[Symbol.iterator];
if (method != null) return method.call(iterable);
}
}
throw new TypeError("Object is not async iterable");
}
module.exports = _asyncIterator;
@@ -0,0 +1,37 @@
function asyncGeneratorStep(gen, resolve, reject, _next, _throw, key, arg) {
try {
var info = gen[key](arg);
var value = info.value;
} catch (error) {
reject(error);
return;
}
if (info.done) {
resolve(value);
} else {
Promise.resolve(value).then(_next, _throw);
}
}
function _asyncToGenerator(fn) {
return function () {
var self = this,
args = arguments;
return new Promise(function (resolve, reject) {
var gen = fn.apply(self, args);
function _next(value) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "next", value);
}
function _throw(err) {
asyncGeneratorStep(gen, resolve, reject, _next, _throw, "throw", err);
}
_next(undefined);
});
};
}
module.exports = _asyncToGenerator;
@@ -0,0 +1,7 @@
var AwaitValue = require("./AwaitValue");
function _awaitAsyncGenerator(value) {
return new AwaitValue(value);
}
module.exports = _awaitAsyncGenerator;
@@ -0,0 +1,7 @@
function _classCallCheck(instance, Constructor) {
if (!(instance instanceof Constructor)) {
throw new TypeError("Cannot call a class as a function");
}
}
module.exports = _classCallCheck;
@@ -0,0 +1,5 @@
function _classNameTDZError(name) {
throw new Error("Class \"" + name + "\" cannot be referenced in computed property keys.");
}
module.exports = _classNameTDZError;
@@ -0,0 +1,28 @@
function _classPrivateFieldDestructureSet(receiver, privateMap) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to set private field on non-instance");
}
var descriptor = privateMap.get(receiver);
if (descriptor.set) {
if (!("__destrObj" in descriptor)) {
descriptor.__destrObj = {
set value(v) {
descriptor.set.call(receiver, v);
}
};
}
return descriptor.__destrObj;
} else {
if (!descriptor.writable) {
throw new TypeError("attempted to set read only private field");
}
return descriptor;
}
}
module.exports = _classPrivateFieldDestructureSet;
@@ -0,0 +1,15 @@
function _classPrivateFieldGet(receiver, privateMap) {
var descriptor = privateMap.get(receiver);
if (!descriptor) {
throw new TypeError("attempted to get private field on non-instance");
}
if (descriptor.get) {
return descriptor.get.call(receiver);
}
return descriptor.value;
}
module.exports = _classPrivateFieldGet;
@@ -0,0 +1,9 @@
function _classPrivateFieldBase(receiver, privateKey) {
if (!Object.prototype.hasOwnProperty.call(receiver, privateKey)) {
throw new TypeError("attempted to use private field on non-instance");
}
return receiver;
}
module.exports = _classPrivateFieldBase;
@@ -0,0 +1,7 @@
var id = 0;
function _classPrivateFieldKey(name) {
return "__private_" + id++ + "_" + name;
}
module.exports = _classPrivateFieldKey;
@@ -0,0 +1,21 @@
function _classPrivateFieldSet(receiver, privateMap, value) {
var descriptor = privateMap.get(receiver);
if (!descriptor) {
throw new TypeError("attempted to set private field on non-instance");
}
if (descriptor.set) {
descriptor.set.call(receiver, value);
} else {
if (!descriptor.writable) {
throw new TypeError("attempted to set read only private field");
}
descriptor.value = value;
}
return value;
}
module.exports = _classPrivateFieldSet;
@@ -0,0 +1,9 @@
function _classPrivateMethodGet(receiver, privateSet, fn) {
if (!privateSet.has(receiver)) {
throw new TypeError("attempted to get private field on non-instance");
}
return fn;
}
module.exports = _classPrivateMethodGet;
@@ -0,0 +1,5 @@
function _classPrivateMethodSet() {
throw new TypeError("attempted to reassign private method");
}
module.exports = _classPrivateMethodSet;
@@ -0,0 +1,13 @@
function _classStaticPrivateFieldSpecGet(receiver, classConstructor, descriptor) {
if (receiver !== classConstructor) {
throw new TypeError("Private static access of wrong provenance");
}
if (descriptor.get) {
return descriptor.get.call(receiver);
}
return descriptor.value;
}
module.exports = _classStaticPrivateFieldSpecGet;
@@ -0,0 +1,19 @@
function _classStaticPrivateFieldSpecSet(receiver, classConstructor, descriptor, value) {
if (receiver !== classConstructor) {
throw new TypeError("Private static access of wrong provenance");
}
if (descriptor.set) {
descriptor.set.call(receiver, value);
} else {
if (!descriptor.writable) {
throw new TypeError("attempted to set read only private field");
}
descriptor.value = value;
}
return value;
}
module.exports = _classStaticPrivateFieldSpecSet;
@@ -0,0 +1,9 @@
function _classStaticPrivateMethodGet(receiver, classConstructor, method) {
if (receiver !== classConstructor) {
throw new TypeError("Private static access of wrong provenance");
}
return method;
}
module.exports = _classStaticPrivateMethodGet;
@@ -0,0 +1,5 @@
function _classStaticPrivateMethodSet() {
throw new TypeError("attempted to set read only static private field");
}
module.exports = _classStaticPrivateMethodSet;
@@ -0,0 +1,22 @@
var setPrototypeOf = require("./setPrototypeOf");
var isNativeReflectConstruct = require("./isNativeReflectConstruct");
function _construct(Parent, args, Class) {
if (isNativeReflectConstruct()) {
module.exports = _construct = Reflect.construct;
} else {
module.exports = _construct = function _construct(Parent, args, Class) {
var a = [null];
a.push.apply(a, args);
var Constructor = Function.bind.apply(Parent, a);
var instance = new Constructor();
if (Class) setPrototypeOf(instance, Class.prototype);
return instance;
};
}
return _construct.apply(null, arguments);
}
module.exports = _construct;
@@ -0,0 +1,17 @@
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);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps) _defineProperties(Constructor.prototype, protoProps);
if (staticProps) _defineProperties(Constructor, staticProps);
return Constructor;
}
module.exports = _createClass;
@@ -0,0 +1,60 @@
var unsupportedIterableToArray = require("./unsupportedIterableToArray");
function _createForOfIteratorHelper(o, allowArrayLike) {
var it;
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
if (Array.isArray(o) || (it = unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
if (it) o = it;
var i = 0;
var F = function F() {};
return {
s: F,
n: function n() {
if (i >= o.length) return {
done: true
};
return {
done: false,
value: o[i++]
};
},
e: function e(_e) {
throw _e;
},
f: F
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
var normalCompletion = true,
didErr = false,
err;
return {
s: function s() {
it = o[Symbol.iterator]();
},
n: function n() {
var step = it.next();
normalCompletion = step.done;
return step;
},
e: function e(_e2) {
didErr = true;
err = _e2;
},
f: function f() {
try {
if (!normalCompletion && it["return"] != null) it["return"]();
} finally {
if (didErr) throw err;
}
}
};
}
module.exports = _createForOfIteratorHelper;
@@ -0,0 +1,28 @@
var unsupportedIterableToArray = require("./unsupportedIterableToArray");
function _createForOfIteratorHelperLoose(o, allowArrayLike) {
var it;
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
if (Array.isArray(o) || (it = unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") {
if (it) o = it;
var i = 0;
return function () {
if (i >= o.length) return {
done: true
};
return {
done: false,
value: o[i++]
};
};
}
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
it = o[Symbol.iterator]();
return it.next.bind(it);
}
module.exports = _createForOfIteratorHelperLoose;
@@ -0,0 +1,24 @@
var getPrototypeOf = require("./getPrototypeOf");
var isNativeReflectConstruct = require("./isNativeReflectConstruct");
var possibleConstructorReturn = require("./possibleConstructorReturn");
function _createSuper(Derived) {
var hasNativeReflectConstruct = isNativeReflectConstruct();
return function _createSuperInternal() {
var Super = getPrototypeOf(Derived),
result;
if (hasNativeReflectConstruct) {
var NewTarget = getPrototypeOf(this).constructor;
result = Reflect.construct(Super, arguments, NewTarget);
} else {
result = Super.apply(this, arguments);
}
return possibleConstructorReturn(this, result);
};
}
module.exports = _createSuper;
@@ -0,0 +1,400 @@
var toArray = require("./toArray");
var toPropertyKey = require("./toPropertyKey");
function _decorate(decorators, factory, superClass, mixins) {
var api = _getDecoratorsApi();
if (mixins) {
for (var i = 0; i < mixins.length; i++) {
api = mixins[i](api);
}
}
var r = factory(function initialize(O) {
api.initializeInstanceElements(O, decorated.elements);
}, superClass);
var decorated = api.decorateClass(_coalesceClassElements(r.d.map(_createElementDescriptor)), decorators);
api.initializeClassElements(r.F, decorated.elements);
return api.runClassFinishers(r.F, decorated.finishers);
}
function _getDecoratorsApi() {
_getDecoratorsApi = function _getDecoratorsApi() {
return api;
};
var api = {
elementsDefinitionOrder: [["method"], ["field"]],
initializeInstanceElements: function initializeInstanceElements(O, elements) {
["method", "field"].forEach(function (kind) {
elements.forEach(function (element) {
if (element.kind === kind && element.placement === "own") {
this.defineClassElement(O, element);
}
}, this);
}, this);
},
initializeClassElements: function initializeClassElements(F, elements) {
var proto = F.prototype;
["method", "field"].forEach(function (kind) {
elements.forEach(function (element) {
var placement = element.placement;
if (element.kind === kind && (placement === "static" || placement === "prototype")) {
var receiver = placement === "static" ? F : proto;
this.defineClassElement(receiver, element);
}
}, this);
}, this);
},
defineClassElement: function defineClassElement(receiver, element) {
var descriptor = element.descriptor;
if (element.kind === "field") {
var initializer = element.initializer;
descriptor = {
enumerable: descriptor.enumerable,
writable: descriptor.writable,
configurable: descriptor.configurable,
value: initializer === void 0 ? void 0 : initializer.call(receiver)
};
}
Object.defineProperty(receiver, element.key, descriptor);
},
decorateClass: function decorateClass(elements, decorators) {
var newElements = [];
var finishers = [];
var placements = {
"static": [],
prototype: [],
own: []
};
elements.forEach(function (element) {
this.addElementPlacement(element, placements);
}, this);
elements.forEach(function (element) {
if (!_hasDecorators(element)) return newElements.push(element);
var elementFinishersExtras = this.decorateElement(element, placements);
newElements.push(elementFinishersExtras.element);
newElements.push.apply(newElements, elementFinishersExtras.extras);
finishers.push.apply(finishers, elementFinishersExtras.finishers);
}, this);
if (!decorators) {
return {
elements: newElements,
finishers: finishers
};
}
var result = this.decorateConstructor(newElements, decorators);
finishers.push.apply(finishers, result.finishers);
result.finishers = finishers;
return result;
},
addElementPlacement: function addElementPlacement(element, placements, silent) {
var keys = placements[element.placement];
if (!silent && keys.indexOf(element.key) !== -1) {
throw new TypeError("Duplicated element (" + element.key + ")");
}
keys.push(element.key);
},
decorateElement: function decorateElement(element, placements) {
var extras = [];
var finishers = [];
for (var decorators = element.decorators, i = decorators.length - 1; i >= 0; i--) {
var keys = placements[element.placement];
keys.splice(keys.indexOf(element.key), 1);
var elementObject = this.fromElementDescriptor(element);
var elementFinisherExtras = this.toElementFinisherExtras((0, decorators[i])(elementObject) || elementObject);
element = elementFinisherExtras.element;
this.addElementPlacement(element, placements);
if (elementFinisherExtras.finisher) {
finishers.push(elementFinisherExtras.finisher);
}
var newExtras = elementFinisherExtras.extras;
if (newExtras) {
for (var j = 0; j < newExtras.length; j++) {
this.addElementPlacement(newExtras[j], placements);
}
extras.push.apply(extras, newExtras);
}
}
return {
element: element,
finishers: finishers,
extras: extras
};
},
decorateConstructor: function decorateConstructor(elements, decorators) {
var finishers = [];
for (var i = decorators.length - 1; i >= 0; i--) {
var obj = this.fromClassDescriptor(elements);
var elementsAndFinisher = this.toClassDescriptor((0, decorators[i])(obj) || obj);
if (elementsAndFinisher.finisher !== undefined) {
finishers.push(elementsAndFinisher.finisher);
}
if (elementsAndFinisher.elements !== undefined) {
elements = elementsAndFinisher.elements;
for (var j = 0; j < elements.length - 1; j++) {
for (var k = j + 1; k < elements.length; k++) {
if (elements[j].key === elements[k].key && elements[j].placement === elements[k].placement) {
throw new TypeError("Duplicated element (" + elements[j].key + ")");
}
}
}
}
}
return {
elements: elements,
finishers: finishers
};
},
fromElementDescriptor: function fromElementDescriptor(element) {
var obj = {
kind: element.kind,
key: element.key,
placement: element.placement,
descriptor: element.descriptor
};
var desc = {
value: "Descriptor",
configurable: true
};
Object.defineProperty(obj, Symbol.toStringTag, desc);
if (element.kind === "field") obj.initializer = element.initializer;
return obj;
},
toElementDescriptors: function toElementDescriptors(elementObjects) {
if (elementObjects === undefined) return;
return toArray(elementObjects).map(function (elementObject) {
var element = this.toElementDescriptor(elementObject);
this.disallowProperty(elementObject, "finisher", "An element descriptor");
this.disallowProperty(elementObject, "extras", "An element descriptor");
return element;
}, this);
},
toElementDescriptor: function toElementDescriptor(elementObject) {
var kind = String(elementObject.kind);
if (kind !== "method" && kind !== "field") {
throw new TypeError('An element descriptor\'s .kind property must be either "method" or' + ' "field", but a decorator created an element descriptor with' + ' .kind "' + kind + '"');
}
var key = toPropertyKey(elementObject.key);
var placement = String(elementObject.placement);
if (placement !== "static" && placement !== "prototype" && placement !== "own") {
throw new TypeError('An element descriptor\'s .placement property must be one of "static",' + ' "prototype" or "own", but a decorator created an element descriptor' + ' with .placement "' + placement + '"');
}
var descriptor = elementObject.descriptor;
this.disallowProperty(elementObject, "elements", "An element descriptor");
var element = {
kind: kind,
key: key,
placement: placement,
descriptor: Object.assign({}, descriptor)
};
if (kind !== "field") {
this.disallowProperty(elementObject, "initializer", "A method descriptor");
} else {
this.disallowProperty(descriptor, "get", "The property descriptor of a field descriptor");
this.disallowProperty(descriptor, "set", "The property descriptor of a field descriptor");
this.disallowProperty(descriptor, "value", "The property descriptor of a field descriptor");
element.initializer = elementObject.initializer;
}
return element;
},
toElementFinisherExtras: function toElementFinisherExtras(elementObject) {
var element = this.toElementDescriptor(elementObject);
var finisher = _optionalCallableProperty(elementObject, "finisher");
var extras = this.toElementDescriptors(elementObject.extras);
return {
element: element,
finisher: finisher,
extras: extras
};
},
fromClassDescriptor: function fromClassDescriptor(elements) {
var obj = {
kind: "class",
elements: elements.map(this.fromElementDescriptor, this)
};
var desc = {
value: "Descriptor",
configurable: true
};
Object.defineProperty(obj, Symbol.toStringTag, desc);
return obj;
},
toClassDescriptor: function toClassDescriptor(obj) {
var kind = String(obj.kind);
if (kind !== "class") {
throw new TypeError('A class descriptor\'s .kind property must be "class", but a decorator' + ' created a class descriptor with .kind "' + kind + '"');
}
this.disallowProperty(obj, "key", "A class descriptor");
this.disallowProperty(obj, "placement", "A class descriptor");
this.disallowProperty(obj, "descriptor", "A class descriptor");
this.disallowProperty(obj, "initializer", "A class descriptor");
this.disallowProperty(obj, "extras", "A class descriptor");
var finisher = _optionalCallableProperty(obj, "finisher");
var elements = this.toElementDescriptors(obj.elements);
return {
elements: elements,
finisher: finisher
};
},
runClassFinishers: function runClassFinishers(constructor, finishers) {
for (var i = 0; i < finishers.length; i++) {
var newConstructor = (0, finishers[i])(constructor);
if (newConstructor !== undefined) {
if (typeof newConstructor !== "function") {
throw new TypeError("Finishers must return a constructor.");
}
constructor = newConstructor;
}
}
return constructor;
},
disallowProperty: function disallowProperty(obj, name, objectType) {
if (obj[name] !== undefined) {
throw new TypeError(objectType + " can't have a ." + name + " property.");
}
}
};
return api;
}
function _createElementDescriptor(def) {
var key = toPropertyKey(def.key);
var descriptor;
if (def.kind === "method") {
descriptor = {
value: def.value,
writable: true,
configurable: true,
enumerable: false
};
} else if (def.kind === "get") {
descriptor = {
get: def.value,
configurable: true,
enumerable: false
};
} else if (def.kind === "set") {
descriptor = {
set: def.value,
configurable: true,
enumerable: false
};
} else if (def.kind === "field") {
descriptor = {
configurable: true,
writable: true,
enumerable: true
};
}
var element = {
kind: def.kind === "field" ? "field" : "method",
key: key,
placement: def["static"] ? "static" : def.kind === "field" ? "own" : "prototype",
descriptor: descriptor
};
if (def.decorators) element.decorators = def.decorators;
if (def.kind === "field") element.initializer = def.value;
return element;
}
function _coalesceGetterSetter(element, other) {
if (element.descriptor.get !== undefined) {
other.descriptor.get = element.descriptor.get;
} else {
other.descriptor.set = element.descriptor.set;
}
}
function _coalesceClassElements(elements) {
var newElements = [];
var isSameElement = function isSameElement(other) {
return other.kind === "method" && other.key === element.key && other.placement === element.placement;
};
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
var other;
if (element.kind === "method" && (other = newElements.find(isSameElement))) {
if (_isDataDescriptor(element.descriptor) || _isDataDescriptor(other.descriptor)) {
if (_hasDecorators(element) || _hasDecorators(other)) {
throw new ReferenceError("Duplicated methods (" + element.key + ") can't be decorated.");
}
other.descriptor = element.descriptor;
} else {
if (_hasDecorators(element)) {
if (_hasDecorators(other)) {
throw new ReferenceError("Decorators can't be placed on different accessors with for " + "the same property (" + element.key + ").");
}
other.decorators = element.decorators;
}
_coalesceGetterSetter(element, other);
}
} else {
newElements.push(element);
}
}
return newElements;
}
function _hasDecorators(element) {
return element.decorators && element.decorators.length;
}
function _isDataDescriptor(desc) {
return desc !== undefined && !(desc.value === undefined && desc.writable === undefined);
}
function _optionalCallableProperty(obj, name) {
var value = obj[name];
if (value !== undefined && typeof value !== "function") {
throw new TypeError("Expected '" + name + "' to be a function");
}
return value;
}
module.exports = _decorate;
@@ -0,0 +1,16 @@
function _defaults(obj, defaults) {
var keys = Object.getOwnPropertyNames(defaults);
for (var i = 0; i < keys.length; i++) {
var key = keys[i];
var value = Object.getOwnPropertyDescriptor(defaults, key);
if (value && value.configurable && obj[key] === undefined) {
Object.defineProperty(obj, key, value);
}
}
return obj;
}
module.exports = _defaults;
@@ -0,0 +1,24 @@
function _defineEnumerableProperties(obj, descs) {
for (var key in descs) {
var desc = descs[key];
desc.configurable = desc.enumerable = true;
if ("value" in desc) desc.writable = true;
Object.defineProperty(obj, key, desc);
}
if (Object.getOwnPropertySymbols) {
var objectSymbols = Object.getOwnPropertySymbols(descs);
for (var i = 0; i < objectSymbols.length; i++) {
var sym = objectSymbols[i];
var desc = descs[sym];
desc.configurable = desc.enumerable = true;
if ("value" in desc) desc.writable = true;
Object.defineProperty(obj, sym, desc);
}
}
return obj;
}
module.exports = _defineEnumerableProperties;
@@ -0,0 +1,16 @@
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;
}
module.exports = _defineProperty;
@@ -0,0 +1,97 @@
import AwaitValue from "@babel/runtime/helpers/esm/AwaitValue";
export default function AsyncGenerator(gen) {
var front, back;
function send(key, arg) {
return new Promise(function (resolve, reject) {
var request = {
key: key,
arg: arg,
resolve: resolve,
reject: reject,
next: null
};
if (back) {
back = back.next = request;
} else {
front = back = request;
resume(key, arg);
}
});
}
function resume(key, arg) {
try {
var result = gen[key](arg);
var value = result.value;
var wrappedAwait = value instanceof AwaitValue;
Promise.resolve(wrappedAwait ? value.wrapped : value).then(function (arg) {
if (wrappedAwait) {
resume(key === "return" ? "return" : "next", arg);
return;
}
settle(result.done ? "return" : "normal", arg);
}, function (err) {
resume("throw", err);
});
} catch (err) {
settle("throw", err);
}
}
function settle(type, value) {
switch (type) {
case "return":
front.resolve({
value: value,
done: true
});
break;
case "throw":
front.reject(value);
break;
default:
front.resolve({
value: value,
done: false
});
break;
}
front = front.next;
if (front) {
resume(front.key, front.arg);
} else {
back = null;
}
}
this._invoke = send;
if (typeof gen["return"] !== "function") {
this["return"] = undefined;
}
}
if (typeof Symbol === "function" && Symbol.asyncIterator) {
AsyncGenerator.prototype[Symbol.asyncIterator] = function () {
return this;
};
}
AsyncGenerator.prototype.next = function (arg) {
return this._invoke("next", arg);
};
AsyncGenerator.prototype["throw"] = function (arg) {
return this._invoke("throw", arg);
};
AsyncGenerator.prototype["return"] = function (arg) {
return this._invoke("return", arg);
};

Some files were not shown because too many files have changed in this diff Show More