Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@babel/cli

Package Overview
Dependencies
Maintainers
4
Versions
128
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/cli - npm Package Compare versions

Comparing version 7.14.3 to 7.22.5

lib/babel-external-helpers.js.map

19

lib/babel-external-helpers.js

@@ -5,34 +5,29 @@ "use strict";

const data = require("commander");
_commander = function () {
return data;
};
return data;
}
function _core() {
const data = require("@babel/core");
_core = function () {
return data;
};
return data;
}
function collect(value, previousValue) {
if (typeof value !== "string") return previousValue;
const values = value.split(",");
return previousValue ? previousValue.concat(values) : values;
if (previousValue) {
previousValue.push(...values);
return previousValue;
}
return values;
}
_commander().option("-l, --whitelist [whitelist]", "Whitelist of helpers to ONLY include", collect);
_commander().option("-t, --output-type [type]", "Type of output (global|umd|var)", "global");
_commander().usage("[options]");
_commander().parse(process.argv);
console.log((0, _core().buildExternalHelpers)(_commander().whitelist, _commander().outputType));
console.log((0, _core().buildExternalHelpers)(_commander().whitelist, _commander().outputType));
//# sourceMappingURL=babel-external-helpers.js.map

@@ -7,39 +7,27 @@ "use strict";

exports.default = _default;
function _slash() {
const data = require("slash");
_slash = function () {
return data;
};
return data;
}
function _path() {
const data = require("path");
_path = function () {
return data;
};
return data;
}
function _fs() {
const data = require("fs");
_fs = function () {
return data;
};
return data;
}
var util = require("./util");
var watcher = require("./watcher");
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); }); }; }
const FILE_TYPE = Object.freeze({

@@ -51,3 +39,2 @@ NON_COMPILABLE: "NON_COMPILABLE",

});
function outputFileSync(filePath, data) {

@@ -57,10 +44,7 @@ (((v, w) => (v = v.split("."), w = w.split("."), +v[0] > +w[0] || v[0] == w[0] && +v[1] >= +w[1]))(process.versions.node, "10.12") ? _fs().mkdirSync : require("make-dir").sync)(_path().dirname(filePath), {

});
_fs().writeFileSync(filePath, data);
}
function _default(_x) {
return _ref.apply(this, arguments);
}
function _ref() {

@@ -71,19 +55,13 @@ _ref = _asyncToGenerator(function* ({

}) {
const filenames = cliOptions.filenames;
function write(_x2, _x3) {
return _write.apply(this, arguments);
}
function _write() {
_write = _asyncToGenerator(function* (src, base) {
let relative = _path().relative(base, src);
if (!util.isCompilableExtension(relative, cliOptions.extensions)) {
return FILE_TYPE.NON_COMPILABLE;
}
relative = util.withExtension(relative, cliOptions.keepFileExtension ? _path().extname(relative) : cliOptions.outFileExtension);
const dest = getDest(relative, base);
try {

@@ -94,17 +72,23 @@ const res = yield util.compile(src, Object.assign({}, babelOptions, {

if (!res) return FILE_TYPE.IGNORED;
if (res.map && babelOptions.sourceMaps && babelOptions.sourceMaps !== "inline") {
const mapLoc = dest + ".map";
res.code = util.addSourceMappingUrl(res.code, mapLoc);
res.map.file = _path().basename(relative);
outputFileSync(mapLoc, JSON.stringify(res.map));
if (res.map) {
let outputMap = false;
if (babelOptions.sourceMaps && babelOptions.sourceMaps !== "inline") {
outputMap = "external";
} else if (babelOptions.sourceMaps == undefined) {
outputMap = util.hasDataSourcemap(res.code) ? "external" : "both";
}
if (outputMap) {
const mapLoc = dest + ".map";
if (outputMap === "external") {
res.code = util.addSourceMappingUrl(res.code, mapLoc);
}
res.map.file = _path().basename(relative);
outputFileSync(mapLoc, JSON.stringify(res.map));
}
}
outputFileSync(dest, res.code);
util.chmod(src, dest);
if (cliOptions.verbose) {
console.log(src + " -> " + dest);
console.log(_path().relative(process.cwd(), src) + " -> " + dest);
}
return FILE_TYPE.COMPILED;

@@ -116,3 +100,2 @@ } catch (err) {

}
throw err;

@@ -123,3 +106,2 @@ }

}
function getDest(filename, base) {

@@ -129,17 +111,12 @@ if (cliOptions.relative) {

}
return _path().join(cliOptions.outDir, filename);
}
function handleFile(_x4, _x5) {
return _handleFile.apply(this, arguments);
}
function _handleFile() {
_handleFile = _asyncToGenerator(function* (src, base) {
const written = yield write(src, base);
if (cliOptions.copyFiles && written === FILE_TYPE.NON_COMPILABLE || cliOptions.copyIgnored && written === FILE_TYPE.IGNORED) {
const filename = _path().relative(base, src);
const dest = getDest(filename, base);

@@ -149,3 +126,2 @@ outputFileSync(dest, _fs().readFileSync(src));

}
return written === FILE_TYPE.COMPILED;

@@ -155,13 +131,9 @@ });

}
function handle(_x6) {
return _handle.apply(this, arguments);
}
function _handle() {
_handle = _asyncToGenerator(function* (filenameOrDir) {
if (!_fs().existsSync(filenameOrDir)) return 0;
const stat = _fs().statSync(filenameOrDir);
if (stat.isDirectory()) {

@@ -171,10 +143,7 @@ const dirname = filenameOrDir;

const files = util.readdir(dirname, cliOptions.includeDotfiles);
for (const filename of files) {
const src = _path().join(dirname, filename);
const written = yield handleFile(src, dirname);
if (written) count += 1;
}
return count;

@@ -189,3 +158,2 @@ } else {

}
let compiledFiles = 0;

@@ -197,3 +165,2 @@ let startTime = null;

}
const diff = process.hrtime(startTime);

@@ -204,3 +171,5 @@ console.log(`Successfully compiled ${compiledFiles} ${compiledFiles !== 1 ? "files" : "file"} with Babel (${diff[0] * 1e3 + Math.round(diff[1] / 1e6)}ms).`);

}, 100);
if (cliOptions.watch) watcher.enable({
enableGlobbing: true
});
if (!cliOptions.skipInitialBuild) {

@@ -210,3 +179,2 @@ if (cliOptions.deleteDirOnStart) {

}
(((v, w) => (v = v.split("."), w = w.split("."), +v[0] > +w[0] || v[0] == w[0] && +v[1] >= +w[1]))(process.versions.node, "10.12") ? _fs().mkdirSync : require("make-dir").sync)(cliOptions.outDir, {

@@ -216,7 +184,5 @@ recursive: true

startTime = process.hrtime();
for (const filename of cliOptions.filenames) {
compiledFiles += yield handle(filename);
}
if (!cliOptions.quiet) {

@@ -227,41 +193,61 @@ logSuccess();

}
if (cliOptions.watch) {
const chokidar = util.requireChokidar();
filenames.forEach(function (filenameOrDir) {
const watcher = chokidar.watch(filenameOrDir, {
persistent: true,
ignoreInitial: true,
awaitWriteFinish: {
stabilityThreshold: 50,
pollInterval: 10
let processing = 0;
const {
filenames
} = cliOptions;
let getBase;
if (filenames.length === 1) {
const base = filenames[0];
const absoluteBase = _path().resolve(base);
getBase = filename => {
return filename === absoluteBase ? _path().dirname(base) : base;
};
} else {
const filenameToBaseMap = new Map(filenames.map(filename => {
const absoluteFilename = _path().resolve(filename);
return [absoluteFilename, _path().dirname(filename)];
}));
const absoluteFilenames = new Map(filenames.map(filename => {
const absoluteFilename = _path().resolve(filename);
return [absoluteFilename, filename];
}));
const {
sep
} = _path();
getBase = filename => {
const base = filenameToBaseMap.get(filename);
if (base !== undefined) {
return base;
}
});
let processing = 0;
["add", "change"].forEach(function (type) {
watcher.on(type, function () {
var _ref2 = _asyncToGenerator(function* (filename) {
processing++;
if (startTime === null) startTime = process.hrtime();
try {
yield handleFile(filename, filename === filenameOrDir ? _path().dirname(filenameOrDir) : filenameOrDir);
compiledFiles++;
} catch (err) {
console.error(err);
}
processing--;
if (processing === 0 && !cliOptions.quiet) logSuccess();
});
return function (_x7) {
return _ref2.apply(this, arguments);
};
}());
});
for (const [absoluteFilenameOrDir, relative] of absoluteFilenames) {
if (filename.startsWith(absoluteFilenameOrDir + sep)) {
filenameToBaseMap.set(filename, relative);
return relative;
}
}
return "";
};
}
filenames.forEach(filenameOrDir => {
watcher.watch(filenameOrDir);
});
watcher.startWatcher();
watcher.onFilesChange(_asyncToGenerator(function* (filenames) {
processing++;
if (startTime === null) startTime = process.hrtime();
try {
const written = yield Promise.all(filenames.map(filename => handleFile(filename, getBase(filename))));
compiledFiles += written.filter(Boolean).length;
} catch (err) {
console.error(err);
}
processing--;
if (processing === 0 && !cliOptions.quiet) logSuccess();
}));
}
});
return _ref.apply(this, arguments);
}
}
//# sourceMappingURL=dir.js.map

@@ -7,63 +7,44 @@ "use strict";

exports.default = _default;
function _convertSourceMap() {
const data = require("convert-source-map");
_convertSourceMap = function () {
return data;
};
return data;
}
function _sourceMap() {
const data = require("source-map");
_sourceMap = function () {
function _traceMapping() {
const data = require("@jridgewell/trace-mapping");
_traceMapping = function () {
return data;
};
return data;
}
function _slash() {
const data = require("slash");
_slash = function () {
return data;
};
return data;
}
function _path() {
const data = require("path");
_path = function () {
return data;
};
return data;
}
function _fs() {
const data = require("fs");
_fs = function () {
return data;
};
return data;
}
var util = require("./util");
var watcher = require("./watcher");
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); }); }; }
function _default(_x) {
return _ref.apply(this, arguments);
}
function _ref() {

@@ -75,54 +56,49 @@ _ref = _asyncToGenerator(function* ({

function buildResult(fileResults) {
const map = new (_sourceMap().SourceMapGenerator)({
file: cliOptions.sourceMapTarget || _path().basename(cliOptions.outFile || "") || "stdout",
sourceRoot: babelOptions.sourceRoot
});
const mapSections = [];
let code = "";
let offset = 0;
let hasRawMap = false;
for (const result of fileResults) {
if (!result) continue;
hasRawMap = !!result.map;
mapSections.push({
offset: {
line: offset,
column: 0
},
map: result.map || {
version: 3,
names: [],
sources: [],
mappings: []
}
});
code += result.code + "\n";
if (result.map) {
const consumer = new (_sourceMap().SourceMapConsumer)(result.map);
const sources = new Set();
consumer.eachMapping(function (mapping) {
if (mapping.source != null) sources.add(mapping.source);
map.addMapping({
generated: {
line: mapping.generatedLine + offset,
column: mapping.generatedColumn
},
source: mapping.source,
original: mapping.source == null ? null : {
line: mapping.originalLine,
column: mapping.originalColumn
}
});
});
sources.forEach(source => {
const content = consumer.sourceContentFor(source, true);
if (content !== null) {
map.setSourceContent(source, content);
}
});
offset = code.split("\n").length - 1;
}
offset += countNewlines(result.code) + 1;
}
const map = new (_traceMapping().AnyMap)({
version: 3,
file: cliOptions.sourceMapTarget || _path().basename(cliOptions.outFile || "") || "stdout",
sections: mapSections
});
map.sourceRoot = babelOptions.sourceRoot;
if (babelOptions.sourceMaps === "inline" || !cliOptions.outFile && babelOptions.sourceMaps) {
code += "\n" + _convertSourceMap().fromObject(map).toComment();
code += "\n" + _convertSourceMap().fromObject((0, _traceMapping().encodedMap)(map)).toComment();
}
return {
map: map,
code: code
code: code,
hasRawMap: hasRawMap
};
}
function countNewlines(code) {
let count = 0;
let index = -1;
while ((index = code.indexOf("\n", index + 1)) !== -1) {
count++;
}
return count;
}
function output(fileResults) {
const result = buildResult(fileResults);
if (cliOptions.outFile) {

@@ -132,10 +108,15 @@ (((v, w) => (v = v.split("."), w = w.split("."), +v[0] > +w[0] || v[0] == w[0] && +v[1] >= +w[1]))(process.versions.node, "10.12") ? _fs().mkdirSync : require("make-dir").sync)(_path().dirname(cliOptions.outFile), {

});
let outputMap = false;
if (babelOptions.sourceMaps && babelOptions.sourceMaps !== "inline") {
outputMap = "external";
} else if (babelOptions.sourceMaps == undefined && result.hasRawMap) {
outputMap = util.hasDataSourcemap(result.code) ? "external" : "both";
}
if (outputMap) {
const mapLoc = cliOptions.outFile + ".map";
result.code = util.addSourceMappingUrl(result.code, mapLoc);
_fs().writeFileSync(mapLoc, JSON.stringify(result.map));
if (outputMap === "external") {
result.code = util.addSourceMappingUrl(result.code, mapLoc);
}
_fs().writeFileSync(mapLoc, JSON.stringify((0, _traceMapping().encodedMap)(result.map)));
}
_fs().writeFileSync(cliOptions.outFile, result.code);

@@ -146,3 +127,2 @@ } else {

}
function readStdin() {

@@ -162,11 +142,9 @@ return new Promise((resolve, reject) => {

}
function stdin() {
return _stdin.apply(this, arguments);
}
function _stdin() {
_stdin = _asyncToGenerator(function* () {
const code = yield readStdin();
const res = yield util.transform(cliOptions.filename, code, Object.assign({}, babelOptions, {
const res = yield util.transformRepl(cliOptions.filename, code, Object.assign({}, babelOptions, {
sourceFileName: "stdin"

@@ -178,7 +156,5 @@ }));

}
function walk(_x2) {
return _walk.apply(this, arguments);
}
function _walk() {

@@ -189,5 +165,3 @@ _walk = _asyncToGenerator(function* (filenames) {

if (!_fs().existsSync(filename)) return;
const stat = _fs().statSync(filename);
if (stat.isDirectory()) {

@@ -202,31 +176,21 @@ const dirname = filename;

});
const results = yield Promise.all(_filenames.map(function () {
var _ref2 = _asyncToGenerator(function* (filename) {
let sourceFilename = filename;
if (cliOptions.outFile) {
sourceFilename = _path().relative(_path().dirname(cliOptions.outFile), sourceFilename);
const results = yield Promise.all(_filenames.map(_asyncToGenerator(function* (filename) {
let sourceFilename = filename;
if (cliOptions.outFile) {
sourceFilename = _path().relative(_path().dirname(cliOptions.outFile), sourceFilename);
}
sourceFilename = _slash()(sourceFilename);
try {
return yield util.compile(filename, Object.assign({}, babelOptions, {
sourceFileName: sourceFilename,
sourceMaps: babelOptions.sourceMaps === "inline" ? true : babelOptions.sourceMaps
}));
} catch (err) {
if (!cliOptions.watch) {
throw err;
}
sourceFilename = _slash()(sourceFilename);
try {
return yield util.compile(filename, Object.assign({}, babelOptions, {
sourceFileName: sourceFilename,
sourceMaps: babelOptions.sourceMaps === "inline" ? true : babelOptions.sourceMaps
}));
} catch (err) {
if (!cliOptions.watch) {
throw err;
}
console.error(err);
return null;
}
});
return function (_x4) {
return _ref2.apply(this, arguments);
};
}()));
console.error(err);
return null;
}
})));
output(results);

@@ -236,37 +200,27 @@ });

}
function files(_x3) {
return _files.apply(this, arguments);
}
function _files() {
_files = _asyncToGenerator(function* (filenames) {
if (cliOptions.watch) {
watcher.enable({
enableGlobbing: false
});
}
if (!cliOptions.skipInitialBuild) {
yield walk(filenames);
}
if (cliOptions.watch) {
const chokidar = util.requireChokidar();
chokidar.watch(filenames, {
disableGlobbing: true,
persistent: true,
ignoreInitial: true,
awaitWriteFinish: {
stabilityThreshold: 50,
pollInterval: 10
filenames.forEach(watcher.watch);
watcher.startWatcher();
watcher.onFilesChange((changes, event, cause) => {
const actionableChange = changes.some(filename => util.isCompilableExtension(filename, cliOptions.extensions) || filenames.includes(filename));
if (!actionableChange) return;
if (cliOptions.verbose) {
console.log(`${event} ${cause}`);
}
}).on("all", function (type, filename) {
if (!util.isCompilableExtension(filename, cliOptions.extensions) && !filenames.includes(filename)) {
return;
}
if (type === "add" || type === "change") {
if (cliOptions.verbose) {
console.log(type + " " + filename);
}
walk(filenames).catch(err => {
console.error(err);
});
}
walk(filenames).catch(err => {
console.error(err);
});
});

@@ -277,3 +231,2 @@ }

}
if (cliOptions.filenames.length) {

@@ -286,2 +239,4 @@ yield files(cliOptions.filenames);

return _ref.apply(this, arguments);
}
}
//# sourceMappingURL=file.js.map

@@ -5,9 +5,5 @@ #!/usr/bin/env node

var _options = require("./options");
var _dir = require("./dir");
var _file = require("./file");
const opts = (0, _options.default)(process.argv);
if (opts) {

@@ -21,2 +17,4 @@ const fn = opts.cliOptions.outDir ? _dir.default : _file.default;

process.exitCode = 2;
}
}
//# sourceMappingURL=index.js.map

@@ -7,139 +7,82 @@ "use strict";

exports.default = parseArgv;
function _fs() {
const data = require("fs");
_fs = function () {
return data;
};
return data;
}
function _commander() {
const data = require("commander");
_commander = function () {
return data;
};
return data;
}
function _core() {
const data = require("@babel/core");
_core = function () {
return data;
};
return data;
}
function _glob() {
const data = require("glob");
_glob = function () {
return data;
};
return data;
}
_commander().option("-f, --filename [filename]", "The filename to use when reading from stdin. This will be used in source-maps, errors etc.");
_commander().option("--presets [list]", "A comma-separated list of preset names.", collect);
_commander().option("--plugins [list]", "A comma-separated list of plugin names.", collect);
_commander().option("--config-file [path]", "Path to a .babelrc file to use.");
_commander().option("--env-name [name]", "The name of the 'env' to use when loading configs and plugins. " + "Defaults to the value of BABEL_ENV, or else NODE_ENV, or else 'development'.");
_commander().option("--root-mode [mode]", "The project-root resolution mode. " + "One of 'root' (the default), 'upward', or 'upward-optional'.");
_commander().option("--source-type [script|module]", "");
_commander().option("--no-babelrc", "Whether or not to look up .babelrc and .babelignore files.");
_commander().option("--ignore [list]", "List of glob paths to **not** compile.", collect);
_commander().option("--only [list]", "List of glob paths to **only** compile.", collect);
_commander().option("--no-highlight-code", "Enable or disable ANSI syntax highlighting of code frames. (on by default)");
_commander().option("--no-comments", "Write comments to generated output. (true by default)");
_commander().option("--retain-lines", "Retain line numbers. This will result in really ugly code.");
_commander().option("--compact [true|false|auto]", "Do not include superfluous whitespace characters and line terminators.", booleanify);
_commander().option("--minified", "Save as many bytes when printing. (false by default)");
_commander().option("--auxiliary-comment-before [string]", "Print a comment before any injected non-user code.");
_commander().option("--auxiliary-comment-after [string]", "Print a comment after any injected non-user code.");
_commander().option("-s, --source-maps [true|false|inline|both]", "", booleanify);
_commander().option("-s, --source-maps [true|false|inline|both]", "", booleanify, undefined);
_commander().option("--source-map-target [string]", "Set `file` on returned source map.");
_commander().option("--source-file-name [string]", "Set `sources[0]` on returned source map.");
_commander().option("--source-root [filename]", "The root from which all sources are relative.");
{
_commander().option("--module-root [filename]", "Optional prefix for the AMD module formatter that will be prepended to the filename on module definitions.");
_commander().option("-M, --module-ids", "Insert an explicit id for modules.");
_commander().option("--module-id [string]", "Specify a custom name for module ids.");
}
_commander().option("-x, --extensions [extensions]", "List of extensions to compile when a directory has been the input. [.es6,.js,.es,.jsx,.mjs]", collect);
_commander().option("-x, --extensions [extensions]", "List of extensions to compile when a directory has been the input. [" + _core().DEFAULT_EXTENSIONS.join() + "]", collect);
_commander().option("--keep-file-extension", "Preserve the file extensions of the input files.");
_commander().option("-w, --watch", "Recompile files on changes.");
_commander().option("--skip-initial-build", "Do not compile files before watching.");
_commander().option("-o, --out-file [out]", "Compile all input files into a single file.");
_commander().option("-d, --out-dir [out]", "Compile an input directory of modules into an output directory.");
_commander().option("--relative", "Compile into an output directory relative to input directory or file. Requires --out-dir [out]");
_commander().option("-D, --copy-files", "When compiling a directory copy over non-compilable files.");
_commander().option("--include-dotfiles", "Include dotfiles when compiling and copying non-compilable files.");
_commander().option("--no-copy-ignored", "Exclude ignored files when copying non-compilable files.");
_commander().option("--verbose", "Log everything. This option conflicts with --quiet");
_commander().option("--quiet", "Don't log anything. This option conflicts with --verbose");
_commander().option("--delete-dir-on-start", "Delete the out directory before compilation.");
_commander().option("--out-file-extension [string]", "Use a specific extension for the output files");
_commander().version("7.14.3" + " (@babel/core " + _core().version + ")");
_commander().version("7.22.5" + " (@babel/core " + _core().version + ")");
_commander().usage("[options] <files ...>");
_commander().action(() => {});
function parseArgv(args) {
_commander().parse(args);
const errors = [];
let filenames = _commander().args.reduce(function (globbed, input) {
let files = _glob().sync(input);
if (!files.length) files = [input];
return globbed.concat(files);
globbed.push(...files);
return globbed;
}, []);
filenames = Array.from(new Set(filenames));

@@ -151,15 +94,11 @@ filenames.forEach(function (filename) {

});
if (_commander().outDir && !filenames.length) {
errors.push("--out-dir requires filenames");
}
if (_commander().outFile && _commander().outDir) {
errors.push("--out-file and --out-dir cannot be used together");
}
if (_commander().relative && !_commander().outDir) {
errors.push("--relative requires --out-dir usage");
}
if (_commander().watch) {

@@ -169,3 +108,2 @@ if (!_commander().outFile && !_commander().outDir) {

}
if (!filenames.length) {

@@ -175,23 +113,17 @@ errors.push("--watch requires filenames");

}
if (_commander().skipInitialBuild && !_commander().watch) {
errors.push("--skip-initial-build requires --watch");
}
if (_commander().deleteDirOnStart && !_commander().outDir) {
errors.push("--delete-dir-on-start requires --out-dir");
}
if (_commander().verbose && _commander().quiet) {
errors.push("--verbose and --quiet cannot be used together");
}
if (!_commander().outDir && filenames.length === 0 && typeof _commander().filename !== "string" && _commander().babelrc !== false) {
errors.push("stdin compilation requires either -f/--filename [filename] or --no-babelrc");
}
if (_commander().keepFileExtension && _commander().outFileExtension) {
errors.push("--out-file-extension cannot be used with --keep-file-extension");
}
if (errors.length) {

@@ -204,5 +136,3 @@ console.error("babel:");

}
const opts = _commander().opts();
const babelOptions = {

@@ -236,3 +166,2 @@ presets: opts.presets,

}
for (const key of Object.keys(babelOptions)) {

@@ -243,3 +172,2 @@ if (babelOptions[key] === undefined) {

}
return {

@@ -268,19 +196,22 @@ babelOptions,

}
function booleanify(val) {
if (val === undefined) return undefined;
if (val === "true" || val == 1) {
return true;
}
if (val === "false" || val == 0 || !val) {
return false;
}
return val;
}
function collect(value, previousValue) {
if (typeof value !== "string") return previousValue;
const values = value.split(",");
return previousValue ? previousValue.concat(values) : values;
}
if (previousValue) {
previousValue.push(...values);
return previousValue;
}
return values;
}
//# sourceMappingURL=options.js.map

@@ -6,64 +6,44 @@ "use strict";

});
exports.addSourceMappingUrl = addSourceMappingUrl;
exports.chmod = chmod;
exports.compile = compile;
exports.debounce = debounce;
exports.deleteDir = deleteDir;
exports.hasDataSourcemap = hasDataSourcemap;
exports.isCompilableExtension = isCompilableExtension;
exports.readdir = readdir;
exports.readdirForCompilable = readdirForCompilable;
exports.isCompilableExtension = isCompilableExtension;
exports.addSourceMappingUrl = addSourceMappingUrl;
exports.transform = transform;
exports.compile = compile;
exports.deleteDir = deleteDir;
exports.requireChokidar = requireChokidar;
exports.transformRepl = transformRepl;
exports.withExtension = withExtension;
exports.debounce = debounce;
function _fsReaddirRecursive() {
const data = require("fs-readdir-recursive");
_fsReaddirRecursive = function () {
return data;
};
return data;
}
function babel() {
const data = require("@babel/core");
babel = function () {
return data;
};
return data;
}
function _path() {
const data = require("path");
_path = function () {
return data;
};
return data;
}
function _fs() {
const data = require("fs");
_fs = function () {
return data;
};
return data;
}
function _module() {
const data = require("module");
_module = function () {
return data;
};
return data;
}
var watcher = require("./watcher");
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); }); }; }
function chmod(src, dest) {

@@ -76,7 +56,5 @@ try {

}
function readdir(dirname, includeDotfiles, filter) {
return _fsReaddirRecursive()(dirname, (filename, _index, currentDirectory) => {
return _fsReaddirRecursive()(dirname, (filename, index, currentDirectory) => {
const stat = _fs().statSync(_path().join(currentDirectory, filename));
if (stat.isDirectory()) return true;

@@ -86,3 +64,2 @@ return (includeDotfiles || filename[0] !== ".") && (!filter || filter(filename));

}
function readdirForCompilable(dirname, includeDotfiles, altExts) {

@@ -93,20 +70,18 @@ return readdir(dirname, includeDotfiles, function (filename) {

}
function isCompilableExtension(filename, altExts) {
const exts = altExts || babel().DEFAULT_EXTENSIONS;
const ext = _path().extname(filename);
return exts.includes(ext);
}
function addSourceMappingUrl(code, loc) {
return code + "\n//# sourceMappingURL=" + _path().basename(loc);
}
function hasDataSourcemap(code) {
const pos = code.lastIndexOf("\n", code.length - 2);
return pos != -1 && code.lastIndexOf("//# sourceMappingURL") < pos;
}
const CALLER = {
name: "@babel/cli"
};
function transform(filename, code, opts) {
function transformRepl(filename, code, opts) {
opts = Object.assign({}, opts, {

@@ -122,14 +97,25 @@ caller: CALLER,

}
function compile(filename, opts) {
opts = Object.assign({}, opts, {
caller: CALLER
});
return new Promise((resolve, reject) => {
babel().transformFile(filename, opts, (err, result) => {
if (err) reject(err);else resolve(result);
function compile(_x, _x2) {
return _compile.apply(this, arguments);
}
function _compile() {
_compile = _asyncToGenerator(function* (filename, opts) {
opts = Object.assign({}, opts, {
caller: CALLER
});
const result = yield new Promise((resolve, reject) => {
babel().transformFile(filename, opts, (err, result) => {
if (err) reject(err);else resolve(result);
});
});
if (result) {
{
if (!result.externalDependencies) return result;
}
watcher.updateExternalDependencies(filename, result.externalDependencies);
}
return result;
});
return _compile.apply(this, arguments);
}
function deleteDir(path) {

@@ -139,3 +125,2 @@ if (_fs().existsSync(path)) {

const curPath = path + "/" + file;
if (_fs().lstatSync(curPath).isDirectory()) {

@@ -147,7 +132,5 @@ deleteDir(curPath);

});
_fs().rmdirSync(path);
}
}
process.on("uncaughtException", function (err) {

@@ -157,12 +140,2 @@ console.error(err);

});
function requireChokidar() {
try {
return parseInt(process.versions.node) >= 8 ? require("chokidar") : require("@nicolo-ribaudo/chokidar-2");
} catch (err) {
console.error("The optional dependency chokidar failed to install and is required for " + "--watch. Chokidar is likely not supported on your platform.");
throw err;
}
}
function withExtension(filename, ext = ".js") {

@@ -172,6 +145,4 @@ const newBasename = _path().basename(filename, _path().extname(filename)) + ext;

}
function debounce(fn, time) {
let timer;
function debounced() {

@@ -181,3 +152,2 @@ clearTimeout(timer);

}
debounced.flush = () => {

@@ -187,4 +157,5 @@ clearTimeout(timer);

};
return debounced;
}
return debounced;
}
//# sourceMappingURL=util.js.map
{
"name": "@babel/cli",
"version": "7.14.3",
"version": "7.22.5",
"description": "Babel command line.",
"author": "Sebastian McKenzie <sebmck@gmail.com>",
"author": "The Babel Team (https://babel.dev/team)",
"homepage": "https://babel.dev/docs/en/next/babel-cli",

@@ -27,12 +27,12 @@ "bugs": "https://github.com/babel/babel/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A%22pkg%3A%20cli%22+is%3Aopen",

"dependencies": {
"@jridgewell/trace-mapping": "^0.3.17",
"commander": "^4.0.1",
"convert-source-map": "^1.1.0",
"fs-readdir-recursive": "^1.1.0",
"glob": "^7.0.0",
"glob": "^7.2.0",
"make-dir": "^2.1.0",
"slash": "^2.0.0",
"source-map": "^0.5.0"
"slash": "^2.0.0"
},
"optionalDependencies": {
"@nicolo-ribaudo/chokidar-2": "2.1.8-no-fsevents",
"@nicolo-ribaudo/chokidar-2": "2.1.8-no-fsevents.3",
"chokidar": "^3.4.0"

@@ -44,5 +44,8 @@ },

"devDependencies": {
"@babel/core": "7.14.3",
"@babel/helper-fixtures": "7.13.13",
"rimraf": "^3.0.0"
"@babel/core": "^7.22.5",
"@babel/helper-fixtures": "^7.22.5",
"@types/fs-readdir-recursive": "^1.1.0",
"@types/glob": "^7.2.0",
"rimraf": "^3.0.0",
"semver": "^6.3.0"
},

@@ -52,3 +55,7 @@ "bin": {

"babel-external-helpers": "./bin/babel-external-helpers.js"
}
},
"engines": {
"node": ">=6.9.0"
},
"type": "commonjs"
}
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc