69 lines
9.0 KiB
JavaScript
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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoibG9hZC1saWJzLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vLi4vLi4vc3JjL2NvbXBpbGVyL2JhYmVsL2xvYWQtbGlicy5qcyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiOzs7OztBQUFBLG1HQUF3RTtBQUV4RSxTQUFTLDJCQUEyQixDQUFFLGNBQWM7SUFDaEQsTUFBTSxJQUFJLEdBQUc7UUFDVCxPQUFPLEVBQUUsRUFBRSxJQUFJLEVBQUUsU0FBUyxFQUFFO1FBQzVCLEtBQUssRUFBSSxJQUFJO1FBQ2IsT0FBTyxFQUFFLENBQUMsdUJBQXVCLENBQUM7S0FDckMsQ0FBQztJQUVGLElBQUksY0FBYztRQUNkLElBQUksQ0FBQyxPQUFPLEdBQUcsS0FBSyxDQUFDO0lB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