Socket
Socket
Sign inDemoInstall

@babel/cli

Package Overview
Dependencies
Maintainers
4
Versions
125
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.24.5 to 7.24.6

20

lib/babel-external-helpers.js
"use strict";
function _commander() {
const data = require("commander");
_commander = function () {
function commander() {
const data = _interopRequireWildcard(require("commander"), true);
commander = function () {
return data;

@@ -17,2 +17,5 @@ };

}
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
const program = commander().default.program;
function collect(value, previousValue) {

@@ -27,8 +30,9 @@ if (typeof value !== "string") return previousValue;

}
_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));
program.option("-l, --whitelist [whitelist]", "Whitelist of helpers to ONLY include", collect);
program.option("-t, --output-type [type]", "Type of output (global|umd|var)", "global");
program.usage("[options]");
program.parse(process.argv);
const opts = program.opts();
console.log((0, _core().buildExternalHelpers)(opts.whitelist, opts.outputType));
//# sourceMappingURL=babel-external-helpers.js.map

3

lib/babel/dir.js

@@ -134,4 +134,3 @@ "use strict";

for (const filename of files) {
const src = _path().join(dirname, filename);
const written = yield handleFile(src, dirname);
const written = yield handleFile(filename, dirname);
if (written) count += 1;

@@ -138,0 +137,0 @@ }

@@ -161,6 +161,3 @@ "use strict";

if (stat.isDirectory()) {
const dirname = filename;
util.readdirForCompilable(filename, cliOptions.includeDotfiles, cliOptions.extensions).forEach(function (filename) {
_filenames.push(_path().join(dirname, filename));
});
_filenames.push(...util.readdirForCompilable(filename, cliOptions.includeDotfiles, cliOptions.extensions));
} else {

@@ -167,0 +164,0 @@ _filenames.push(filename);

@@ -14,5 +14,5 @@ "use strict";

}
function _commander() {
const data = require("commander");
_commander = function () {
function Commander() {
const data = _interopRequireWildcard(require("commander"), true);
Commander = function () {
return data;

@@ -29,5 +29,5 @@ };

}
function _glob() {
const data = require("glob");
_glob = function () {
function glob() {
const data = _interopRequireWildcard(require("glob"), true);
glob = function () {
return data;

@@ -37,50 +37,55 @@ };

}
_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, 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.");
var _util = require("./util.js");
function _getRequireWildcardCache(e) { if ("function" != typeof WeakMap) return null; var r = new WeakMap(), t = new WeakMap(); return (_getRequireWildcardCache = function (e) { return e ? t : r; })(e); }
function _interopRequireWildcard(e, r) { if (!r && e && e.__esModule) return e; if (null === e || "object" != typeof e && "function" != typeof e) return { default: e }; var t = _getRequireWildcardCache(r); if (t && t.has(e)) return t.get(e); var n = { __proto__: null }, a = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var u in e) if ("default" !== u && {}.hasOwnProperty.call(e, u)) { var i = a ? Object.getOwnPropertyDescriptor(e, u) : null; i && (i.get || i.set) ? Object.defineProperty(n, u, i) : n[u] = e[u]; } return n.default = e, t && t.set(e, n), n; }
const program = Commander().default.program;
program.option("-f, --filename [filename]", "The filename to use when reading from stdin. This will be used in source-maps, errors etc.");
program.option("--presets [list]", "A comma-separated list of preset names.", collect);
program.option("--plugins [list]", "A comma-separated list of plugin names.", collect);
program.option("--config-file [path]", "Path to a .babelrc file to use.");
program.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'.");
program.option("--root-mode [mode]", "The project-root resolution mode. " + "One of 'root' (the default), 'upward', or 'upward-optional'.");
program.option("--source-type [script|module]", "");
program.option("--no-babelrc", "Whether or not to look up .babelrc and .babelignore files.");
program.option("--ignore [list]", "List of glob paths to **not** compile.", collect);
program.option("--only [list]", "List of glob paths to **only** compile.", collect);
program.option("--no-highlight-code", "Enable or disable ANSI syntax highlighting of code frames. (on by default)");
program.option("--no-comments", "Write comments to generated output. (true by default)");
program.option("--retain-lines", "Retain line numbers. This will result in really ugly code.");
program.option("--compact [true|false|auto]", "Do not include superfluous whitespace characters and line terminators.", booleanify);
program.option("--minified", "Save as many bytes when printing. (false by default)");
program.option("--auxiliary-comment-before [string]", "Print a comment before any injected non-user code.");
program.option("--auxiliary-comment-after [string]", "Print a comment after any injected non-user code.");
program.option("-s, --source-maps [true|false|inline|both]", "", booleanify, undefined);
program.option("--source-map-target [string]", "Set `file` on returned source map.");
program.option("--source-file-name [string]", "Set `sources[0]` on returned source map.");
program.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.");
program.option("--module-root [filename]", "Optional prefix for the AMD module formatter that will be prepended to the filename on module definitions.");
program.option("-M, --module-ids", "Insert an explicit id for modules.");
program.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. [" + _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.24.5" + " (@babel/core " + _core().version + ")");
_commander().usage("[options] <files ...>");
_commander().action(() => {});
program.option("-x, --extensions [extensions]", "List of extensions to compile when a directory has been the input. [" + _core().DEFAULT_EXTENSIONS.join() + "]", collect);
program.option("--keep-file-extension", "Preserve the file extensions of the input files.");
program.option("-w, --watch", "Recompile files on changes.");
program.option("--skip-initial-build", "Do not compile files before watching.");
program.option("-o, --out-file [out]", "Compile all input files into a single file.");
program.option("-d, --out-dir [out]", "Compile an input directory of modules into an output directory.");
program.option("--relative", "Compile into an output directory relative to input directory or file. Requires --out-dir [out]");
program.option("-D, --copy-files", "When compiling a directory copy over non-compilable files.");
program.option("--include-dotfiles", "Include dotfiles when compiling and copying non-compilable files.");
program.option("--no-copy-ignored", "Exclude ignored files when copying non-compilable files.");
program.option("--verbose", "Log everything. This option conflicts with --quiet");
program.option("--quiet", "Don't log anything. This option conflicts with --verbose");
program.option("--delete-dir-on-start", "Delete the out directory before compilation.");
program.option("--out-file-extension [string]", "Use a specific extension for the output files");
program.version("7.24.6" + " (@babel/core " + _core().version + ")");
program.usage("[options] <files ...>");
program.action(() => {});
function parseArgv(args) {
_commander().parse(args);
program.parse(args);
const opts = program.opts();
const errors = [];
let filenames = _commander().args.reduce(function (globbed, input) {
let files = _glob().sync(input);
let filenames = program.args.reduce(function (globbed, input) {
let files = glob().sync(input);
if (!files.length) files = [input];

@@ -96,13 +101,13 @@ globbed.push(...files);

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

@@ -114,15 +119,15 @@ }

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

@@ -137,3 +142,2 @@ }

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

@@ -196,7 +200,6 @@ presets: opts.presets,

function booleanify(val) {
if (val === undefined) return undefined;
if (val === "true" || val == 1) {
if (val === "true" || val === "1") {
return true;
}
if (val === "false" || val == 0 || !val) {
if (val === "false" || val === "0" || val === "") {
return false;

@@ -203,0 +206,0 @@ }

@@ -7,2 +7,3 @@ "use strict";

exports.addSourceMappingUrl = addSourceMappingUrl;
exports.alphasort = alphasort;
exports.chmod = chmod;

@@ -56,8 +57,13 @@ exports.compile = compile;

}
function alphasort(a, b) {
return a.localeCompare(b, "en");
}
function readdir(dirname, includeDotfiles, filter) {
return _fsReaddirRecursive()(dirname, (filename, index, currentDirectory) => {
const stat = _fs().statSync(_path().join(currentDirectory, filename));
if (stat.isDirectory()) return true;
return (includeDotfiles || filename[0] !== ".") && (!filter || filter(filename));
});
{
return _fsReaddirRecursive()("", (filename, index, currentDirectory) => {
const stat = _fs().statSync(_path().join(currentDirectory, filename));
if (stat.isDirectory()) return true;
return (includeDotfiles || filename[0] !== ".") && (!filter || filter(filename));
}, [], dirname);
}
}

@@ -119,13 +125,18 @@ function readdirForCompilable(dirname, includeDotfiles, altExts) {

function deleteDir(path) {
if (_fs().existsSync(path)) {
_fs().readdirSync(path).forEach(function (file) {
const curPath = path + "/" + file;
if (_fs().lstatSync(curPath).isDirectory()) {
deleteDir(curPath);
} else {
_fs().unlinkSync(curPath);
}
});
_fs().rmdirSync(path);
}
(_fs().rmSync || function d(p) {
if (_fs().existsSync(p)) {
_fs().readdirSync(p).forEach(function (f) {
const c = p + "/" + f;
if (_fs().lstatSync(c).isDirectory()) {
d(c);
} else {
_fs().unlinkSync(c);
}
});
_fs().rmdirSync(p);
}
})(path, {
force: true,
recursive: true
});
}

@@ -132,0 +143,0 @@ process.on("uncaughtException", function (err) {

{
"name": "@babel/cli",
"version": "7.24.5",
"version": "7.24.6",
"description": "Babel command line.",

@@ -28,3 +28,3 @@ "author": "The Babel Team (https://babel.dev/team)",

"@jridgewell/trace-mapping": "^0.3.25",
"commander": "^4.0.1",
"commander": "^6.2.0",
"convert-source-map": "^2.0.0",

@@ -44,4 +44,4 @@ "fs-readdir-recursive": "^1.1.0",

"devDependencies": {
"@babel/core": "^7.24.5",
"@babel/helper-transform-fixture-test-runner": "^7.24.5",
"@babel/core": "^7.24.6",
"@babel/helper-transform-fixture-test-runner": "^7.24.6",
"@types/fs-readdir-recursive": "^1.1.0",

@@ -48,0 +48,0 @@ "@types/glob": "^7.2.0",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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