Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
_getTargets() {
let targets = this.project && this.project.targets;
let parser = require('@babel/preset-env/lib/targets-parser').default;
if (typeof targets === 'object' && targets !== null) {
return parser(targets);
} else {
return targets;
}
},
toObject() {
return targetsParser({ browsers: this.toQuery() });
}
function getPolyfills (targets, includes, { ignoreBrowserslistConfig, configPath }) {
const { isPluginRequired } = require('@babel/preset-env')
const builtInsList = require('core-js-compat/data')
const getTargets = require('@babel/preset-env/lib/targets-parser').default
const builtInTargets = getTargets(targets, {
ignoreBrowserslistConfig,
configPath
})
return includes.filter(item => {
return isPluginRequired(builtInTargets, builtInsList[item])
})
}
function getPolyfills (targets, includes, { ignoreBrowserslistConfig, configPath, corejs }) {
const { isPluginRequired } = require('@babel/preset-env')
const builtInsList = require(coreJsMeta[corejs.version].builtIns)
const getTargets = require('@babel/preset-env/lib/targets-parser').default
const builtInTargets = getTargets(targets, {
ignoreBrowserslistConfig,
configPath
})
return includes.filter(item => isPluginRequired(builtInTargets, builtInsList[item]))
}
static parse(query) {
if (query === 'esmodules') {
let list = targetsParser({ esmodules: true });
query = Object.keys(list).map((browser) => `${browser} ${list[browser].replace(/(\.0)*$/, '')}`).join(', ');
} else if (query === 'node') {
let list = targetsParser({ node: true });
query = Object.keys(list).map((browser) => `${browser} ${list[browser].replace(/(\.0)*$/, '')}`).join(', ');
} else if (Array.isArray(query)) {
query = query.join(', ');
} else if (typeof query === 'object') {
query = Object.keys(query).map((browser) => `${browser} ${query[browser]}`).join(', ');
}
return new Targets(query);
}