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 8.0.0-alpha.8 to 8.0.0-alpha.9

tsconfig.json

14

lib/babel-external-helpers.js

@@ -1,3 +0,4 @@

import commander from "commander";
import * as commander from "commander";
import { buildExternalHelpers } from "@babel/core";
const program = commander.default.program;
function collect(value, previousValue) {

@@ -12,8 +13,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(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(buildExternalHelpers(opts.whitelist, opts.outputType));
//# sourceMappingURL=babel-external-helpers.js.map

@@ -38,3 +38,3 @@ import slash from "slash";

outputMap = "external";
} else if (babelOptions.sourceMaps == undefined) {
} else if (babelOptions.sourceMaps == null) {
outputMap = util.hasDataSourcemap(res.code) ? "external" : "both";

@@ -89,4 +89,3 @@ }

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

@@ -93,0 +92,0 @@ }

@@ -67,3 +67,3 @@ import convertSourceMap from "convert-source-map";

outputMap = "external";
} else if (babelOptions.sourceMaps == undefined && result.hasRawMap) {
} else if (babelOptions.sourceMaps == null && result.hasRawMap) {
outputMap = util.hasDataSourcemap(result.code) ? "external" : "both";

@@ -110,6 +110,3 @@ }

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 {

@@ -116,0 +113,0 @@ _filenames.push(filename);

import fs from "fs";
import commander from "commander";
import * as commander from "commander";
import { version, DEFAULT_EXTENSIONS } from "@babel/core";
import glob from "glob";
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.");
import * as glob from "glob";
import { alphasort } from "./util.js";
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("-x, --extensions [extensions]", "List of extensions to compile when a directory has been the input. [" + 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("8.0.0-alpha.8" + " (@babel/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. [" + 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("8.0.0-alpha.9" + " (@babel/core " + version + ")");
program.usage("[options] <files ...>");
program.action(() => {});
export default 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, {
dotRelative: true
}).sort(alphasort);
if (!files.length) files = [input];

@@ -59,13 +64,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");

@@ -77,15 +82,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");

@@ -100,3 +105,2 @@ }

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

@@ -153,7 +157,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;

@@ -160,0 +163,0 @@ }

@@ -13,8 +13,16 @@ import readdirRecursive from "fs-readdir-recursive";

}
export function alphasort(a, b) {
return a.localeCompare(b, "en");
}
export function readdir(dirname, includeDotfiles, filter) {
return readdirRecursive(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 fs.readdirSync(dirname, {
recursive: true,
withFileTypes: true
}).filter(dirent => {
if (dirent.isDirectory()) return false;
const filename = dirent.name;
return (includeDotfiles || filename[0] !== ".") && (!filter || filter(filename));
}).map(dirent => path.join(dirent.path, dirent.name)).sort(alphasort);
}
}

@@ -36,3 +44,3 @@ export function readdirForCompilable(dirname, includeDotfiles, altExts) {

const pos = code.lastIndexOf("\n", code.length - 2);
return pos != -1 && code.lastIndexOf("//# sourceMappingURL") < pos;
return pos !== -1 && code.lastIndexOf("//# sourceMappingURL") < pos;
}

@@ -65,13 +73,6 @@ const CALLER = {

export 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(path, {
force: true,
recursive: true
});
}

@@ -78,0 +79,0 @@ process.on("uncaughtException", function (err) {

{
"name": "@babel/cli",
"version": "8.0.0-alpha.8",
"version": "8.0.0-alpha.9",
"description": "Babel command line.",

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

"@jridgewell/trace-mapping": "^0.3.25",
"commander": "^4.0.1",
"commander": "^12.1.0",
"convert-source-map": "^2.0.0",
"fs-readdir-recursive": "^1.1.0",
"glob": "^7.2.0",
"glob": "^10.3.12",
"slash": "^3.0.0"

@@ -39,7 +39,7 @@ },

"peerDependencies": {
"@babel/core": "^8.0.0-alpha.8"
"@babel/core": "^8.0.0-alpha.9"
},
"devDependencies": {
"@babel/core": "^8.0.0-alpha.8",
"@babel/helper-transform-fixture-test-runner": "^8.0.0-alpha.8",
"@babel/core": "^8.0.0-alpha.9",
"@babel/helper-transform-fixture-test-runner": "^8.0.0-alpha.9",
"@types/fs-readdir-recursive": "^1.1.0",

@@ -54,6 +54,9 @@ "@types/glob": "^7.2.0",

"engines": {
"node": "^16.20.0 || ^18.16.0 || >=20.0.0"
"node": "^18.20.0 || ^20.10.0 || >=21.0.0"
},
"exports": {
".": "./lib/index.js",
".": {
"types": "./lib/index.d.ts",
"default": "./lib/index.js"
},
"./package.json": "./package.json"

@@ -60,0 +63,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

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