Innovenergy_trunk/frontend/node_modules/testcafe/lib/compiler/babel/load-libs.js

69 lines
9.0 KiB
JavaScript

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
const get_exportable_lib_path_1 = __importDefault(require("../test-file/get-exportable-lib-path"));
function getPresetEnvForTestCodeOpts(dontUseModules) {
const opts = {
targets: { node: 'current' },
loose: true,
exclude: ['transform-regenerator'],
};
if (dontUseModules)
opts.modules = false;
return opts;
}
function getPresetEnvForClientFunctionOpts() {
return {
loose: true,
exclude: ['transform-typeof-symbol', 'transform-for-of'],
};
}
function getModuleResolverOpts(experimentalEsm) {
return {
resolvePath(source) {
//NOTE: Prevent module caching to import 'fixture' and 'test' in ESM mode.
if (source === 'testcafe')
return (0, get_exportable_lib_path_1.default)(experimentalEsm);
return source;
},
};
}
function getTransformForOfOptions() {
// NOTE: allowArrayLike is required to allow iterating non-iterable objects (e.g. NodeList)
// to preserve compatibility with older TestCafe code
return { loose: true, allowArrayLike: true };
}
function getTransformRuntimeOpts() {
// NOTE: We are forced to import helpers to each compiled file
// because of '@babel/plugin-transform-runtime' plugin cannot correctly resolve path
// to the helpers from the '@babel/runtime' module.
return {
'helpers': false,
};
}
function getPresetReact() {
const presetReact = require('@babel/preset-react');
presetReact.presets = []; // disables flow so it doesn't confict w/ presetFlow
return presetReact;
}
// NOTE: lazy load heavy dependencies
function loadLibs({ isCompilerServiceMode, experimentalEsm } = {}) {
return {
babel: require('@babel/core'),
presetStage2: require('./preset-stage-2'),
presetFlow: require('@babel/preset-flow'),
transformRuntime: [require('@babel/plugin-transform-runtime'), getTransformRuntimeOpts()],
transformForOfAsArray: [require('@babel/plugin-transform-for-of'), getTransformForOfOptions()],
presetEnvForClientFunction: [require('@babel/preset-env'), getPresetEnvForClientFunctionOpts()],
presetEnvForTestCode: [require('@babel/preset-env'), getPresetEnvForTestCodeOpts(isCompilerServiceMode || experimentalEsm)],
moduleResolver: [require('babel-plugin-module-resolver'), getModuleResolverOpts(experimentalEsm)],
presetReact: getPresetReact(),
proposalPrivateMethods: [require('@babel/plugin-proposal-private-methods'), { loose: true }],
proposalClassProperties: [require('@babel/plugin-proposal-class-properties'), { loose: true }],
};
}
exports.default = loadLibs;
module.exports = exports.default;
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9hZC1saWJzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NvbXBpbGVyL2JhYmVsL2xvYWQtbGlicy5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLG1HQUF3RTtBQUV4RSxTQUFTLDJCQUEyQixDQUFFLGNBQWM7SUFDaEQsTUFBTSxJQUFJLEdBQUc7UUFDVCxPQUFPLEVBQUUsRUFBRSxJQUFJLEVBQUUsU0FBUyxFQUFFO1FBQzVCLEtBQUssRUFBSSxJQUFJO1FBQ2IsT0FBTyxFQUFFLENBQUMsdUJBQXVCLENBQUM7S0FDckMsQ0FBQztJQUVGLElBQUksY0FBYztRQUNkLElBQUksQ0FBQyxPQUFPLEdBQUcsS0FBSyxDQUFDO0lBRXpCLE9BQU8sSUFBSSxDQUFDO0FBQ2hCLENBQUM7QUFFRCxTQUFTLGlDQUFpQztJQUN0QyxPQUFPO1FBQ0gsS0FBSyxFQUFJLElBQUk7UUFDYixPQUFPLEVBQUUsQ0FBQyx5QkFBeUIsRUFBRSxrQkFBa0IsQ0FBQztLQUMzRCxDQUFDO0FBQ04sQ0FBQztBQUVELFNBQVMscUJBQXFCLENBQUUsZUFBZTtJQUMzQyxPQUFPO1FBQ0gsV0FBVyxDQUFFLE1BQU07WUFDZiwwRUFBMEU7WUFDMUUsSUFBSSxNQUFNLEtBQUssVUFBVTtnQkFDckIsT0FBTyxJQUFBLGlDQUFvQixFQUFDLGVBQWUsQ0FBQyxDQUFDO1lBRWpELE9BQU8sTU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