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.21.4-esm.3 to 7.21.4-esm.4

lib/package.json

28

lib/babel-external-helpers.js

@@ -1,17 +0,3 @@

"use strict";
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;
}
import commander from "commander";
import { buildExternalHelpers } from "@babel/core";
function collect(value, previousValue) {

@@ -26,8 +12,8 @@ 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));
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));
//# sourceMappingURL=babel-external-helpers.js.map

@@ -1,32 +0,8 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
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); }); }; }
import slash from "slash";
import path from "path";
import fs from "fs";
import * as util from "./util.js";
import * as watcher from "./watcher.js";
const FILE_TYPE = Object.freeze({

@@ -39,8 +15,8 @@ NON_COMPILABLE: "NON_COMPILABLE",

function outputFileSync(filePath, data) {
(((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), {
(((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), {
recursive: true
});
_fs().writeFileSync(filePath, data);
fs.writeFileSync(filePath, data);
}
function _default(_x) {
export default function (_x) {
return _ref.apply(this, arguments);

@@ -58,11 +34,11 @@ }

_write = _asyncToGenerator(function* (src, base) {
let relative = _path().relative(base, src);
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);
relative = util.withExtension(relative, cliOptions.keepFileExtension ? path.extname(relative) : cliOptions.outFileExtension);
const dest = getDest(relative, base);
try {
const res = yield util.compile(src, Object.assign({}, babelOptions, {
sourceFileName: _slash()(_path().relative(dest + "/..", src))
sourceFileName: slash(path.relative(dest + "/..", src))
}));

@@ -82,3 +58,3 @@ if (!res) return FILE_TYPE.IGNORED;

}
res.map.file = _path().basename(relative);
res.map.file = path.basename(relative);
outputFileSync(mapLoc, JSON.stringify(res.map));

@@ -90,3 +66,3 @@ }

if (cliOptions.verbose) {
console.log(_path().relative(process.cwd(), src) + " -> " + dest);
console.log(path.relative(process.cwd(), src) + " -> " + dest);
}

@@ -106,5 +82,5 @@ return FILE_TYPE.COMPILED;

if (cliOptions.relative) {
return _path().join(base, cliOptions.outDir, filename);
return path.join(base, cliOptions.outDir, filename);
}
return _path().join(cliOptions.outDir, filename);
return path.join(cliOptions.outDir, filename);
}

@@ -118,5 +94,5 @@ function handleFile(_x4, _x5) {

if (cliOptions.copyFiles && written === FILE_TYPE.NON_COMPILABLE || cliOptions.copyIgnored && written === FILE_TYPE.IGNORED) {
const filename = _path().relative(base, src);
const filename = path.relative(base, src);
const dest = getDest(filename, base);
outputFileSync(dest, _fs().readFileSync(src));
outputFileSync(dest, fs.readFileSync(src));
util.chmod(src, dest);

@@ -133,4 +109,4 @@ }

_handle = _asyncToGenerator(function* (filenameOrDir) {
if (!_fs().existsSync(filenameOrDir)) return 0;
const stat = _fs().statSync(filenameOrDir);
if (!fs.existsSync(filenameOrDir)) return 0;
const stat = fs.statSync(filenameOrDir);
if (stat.isDirectory()) {

@@ -141,3 +117,3 @@ const dirname = filenameOrDir;

for (const filename of files) {
const src = _path().join(dirname, filename);
const src = path.join(dirname, filename);
const written = yield handleFile(src, dirname);

@@ -149,3 +125,3 @@ if (written) count += 1;

const filename = filenameOrDir;
const written = yield handleFile(filename, _path().dirname(filename));
const written = yield handleFile(filename, path.dirname(filename));
return written ? 1 : 0;

@@ -174,3 +150,3 @@ }

}
(((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, {
(((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, {
recursive: true

@@ -195,13 +171,13 @@ });

const base = filenames[0];
const absoluteBase = _path().resolve(base);
const absoluteBase = path.resolve(base);
getBase = filename => {
return filename === absoluteBase ? _path().dirname(base) : base;
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 absoluteFilename = path.resolve(filename);
return [absoluteFilename, path.dirname(filename)];
}));
const absoluteFilenames = new Map(filenames.map(filename => {
const absoluteFilename = _path().resolve(filename);
const absoluteFilename = path.resolve(filename);
return [absoluteFilename, filename];

@@ -211,3 +187,3 @@ }));

sep
} = _path();
} = path;
getBase = filename => {

@@ -214,0 +190,0 @@ const base = filenameToBaseMap.get(filename);

@@ -1,47 +0,11 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.default = _default;
function _convertSourceMap() {
const data = require("convert-source-map");
_convertSourceMap = function () {
return data;
};
return data;
}
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) {
import convertSourceMap from "convert-source-map";
import { AnyMap, encodedMap } from "@jridgewell/trace-mapping";
import slash from "slash";
import path from "path";
import fs from "fs";
import * as util from "./util.js";
import * as watcher from "./watcher.js";
export default function (_x) {
return _ref.apply(this, arguments);

@@ -77,5 +41,5 @@ }

}
const map = new (_traceMapping().AnyMap)({
const map = new AnyMap({
version: 3,
file: cliOptions.sourceMapTarget || _path().basename(cliOptions.outFile || "") || "stdout",
file: cliOptions.sourceMapTarget || path.basename(cliOptions.outFile || "") || "stdout",
sections: mapSections

@@ -85,3 +49,3 @@ });

if (babelOptions.sourceMaps === "inline" || !cliOptions.outFile && babelOptions.sourceMaps) {
code += "\n" + _convertSourceMap().fromObject((0, _traceMapping().encodedMap)(map)).toComment();
code += "\n" + convertSourceMap.fromObject(encodedMap(map)).toComment();
}

@@ -105,3 +69,3 @@ return {

if (cliOptions.outFile) {
(((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), {
(((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), {
recursive: true

@@ -120,5 +84,5 @@ });

}
_fs().writeFileSync(mapLoc, JSON.stringify((0, _traceMapping().encodedMap)(result.map)));
fs.writeFileSync(mapLoc, JSON.stringify(encodedMap(result.map)));
}
_fs().writeFileSync(cliOptions.outFile, result.code);
fs.writeFileSync(cliOptions.outFile, result.code);
} else {

@@ -162,8 +126,8 @@ process.stdout.write(result.code + "\n");

filenames.forEach(function (filename) {
if (!_fs().existsSync(filename)) return;
const stat = _fs().statSync(filename);
if (!fs.existsSync(filename)) return;
const stat = fs.statSync(filename);
if (stat.isDirectory()) {
const dirname = filename;
util.readdirForCompilable(filename, cliOptions.includeDotfiles, cliOptions.extensions).forEach(function (filename) {
_filenames.push(_path().join(dirname, filename));
_filenames.push(path.join(dirname, filename));
});

@@ -177,5 +141,5 @@ } else {

if (cliOptions.outFile) {
sourceFilename = _path().relative(_path().dirname(cliOptions.outFile), sourceFilename);
sourceFilename = path.relative(path.dirname(cliOptions.outFile), sourceFilename);
}
sourceFilename = _slash()(sourceFilename);
sourceFilename = slash(sourceFilename);
try {

@@ -182,0 +146,0 @@ return yield util.compile(filename, Object.assign({}, babelOptions, {

#!/usr/bin/env node
"use strict";
var _options = require("./options");
var _dir = require("./dir");
var _file = require("./file");
const opts = (0, _options.default)(process.argv);
import parseArgv from "./options.js";
import dirCommand from "./dir.js";
import fileCommand from "./file.js";
const opts = parseArgv(process.argv);
if (opts) {
const fn = opts.cliOptions.outDir ? _dir.default : _file.default;
const fn = opts.cliOptions.outDir ? dirCommand : fileCommand;
fn(opts).catch(err => {

@@ -11,0 +9,0 @@ console.error(err);

@@ -1,83 +0,53 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
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, 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 fs from "fs";
import 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.");
{
_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("--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. [" + _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.21.4-esm.3" + " (@babel/core " + _core().version + ")");
_commander().usage("[options] <files ...>");
_commander().action(() => {});
function parseArgv(args) {
_commander().parse(args);
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("7.21.4-esm.4" + " (@babel/core " + version + ")");
commander.usage("[options] <files ...>");
commander.action(() => {});
export default function parseArgv(args) {
commander.parse(args);
const errors = [];
let filenames = _commander().args.reduce(function (globbed, input) {
let files = _glob().sync(input);
let filenames = commander.args.reduce(function (globbed, input) {
let files = glob.sync(input);
if (!files.length) files = [input];

@@ -89,17 +59,17 @@ globbed.push(...files);

filenames.forEach(function (filename) {
if (!_fs().existsSync(filename)) {
if (!fs.existsSync(filename)) {
errors.push(filename + " does not exist");
}
});
if (_commander().outDir && !filenames.length) {
if (commander.outDir && !filenames.length) {
errors.push("--out-dir requires filenames");
}
if (_commander().outFile && _commander().outDir) {
if (commander.outFile && commander.outDir) {
errors.push("--out-file and --out-dir cannot be used together");
}
if (_commander().relative && !_commander().outDir) {
if (commander.relative && !commander.outDir) {
errors.push("--relative requires --out-dir usage");
}
if (_commander().watch) {
if (!_commander().outFile && !_commander().outDir) {
if (commander.watch) {
if (!commander.outFile && !commander.outDir) {
errors.push("--watch requires --out-file or --out-dir");

@@ -111,15 +81,15 @@ }

}
if (_commander().skipInitialBuild && !_commander().watch) {
if (commander.skipInitialBuild && !commander.watch) {
errors.push("--skip-initial-build requires --watch");
}
if (_commander().deleteDirOnStart && !_commander().outDir) {
if (commander.deleteDirOnStart && !commander.outDir) {
errors.push("--delete-dir-on-start requires --out-dir");
}
if (_commander().verbose && _commander().quiet) {
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) {
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) {
if (commander.keepFileExtension && commander.outFileExtension) {
errors.push("--out-file-extension cannot be used with --keep-file-extension");

@@ -134,3 +104,3 @@ }

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

@@ -137,0 +107,0 @@ presets: opts.presets,

@@ -1,51 +0,11 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
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.transformRepl = transformRepl;
exports.withExtension = withExtension;
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;
}
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) {
import readdirRecursive from "fs-readdir-recursive";
import * as babel from "@babel/core";
import path from "path";
import fs from "fs";
import * as watcher from "./watcher.js";
export function chmod(src, dest) {
try {
_fs().chmodSync(dest, _fs().statSync(src).mode);
fs.chmodSync(dest, fs.statSync(src).mode);
} catch (err) {

@@ -55,5 +15,5 @@ console.warn(`Cannot change permissions of ${dest}`);

}
function readdir(dirname, includeDotfiles, filter) {
return _fsReaddirRecursive()(dirname, (filename, index, currentDirectory) => {
const stat = _fs().statSync(_path().join(currentDirectory, filename));
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;

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

}
function readdirForCompilable(dirname, includeDotfiles, altExts) {
export function readdirForCompilable(dirname, includeDotfiles, altExts) {
return readdir(dirname, includeDotfiles, function (filename) {

@@ -69,11 +29,11 @@ return isCompilableExtension(filename, altExts);

}
function isCompilableExtension(filename, altExts) {
const exts = altExts || babel().DEFAULT_EXTENSIONS;
const ext = _path().extname(filename);
export 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);
export function addSourceMappingUrl(code, loc) {
return code + "\n//# sourceMappingURL=" + path.basename(loc);
}
function hasDataSourcemap(code) {
export function hasDataSourcemap(code) {
const pos = code.lastIndexOf("\n", code.length - 2);

@@ -85,3 +45,3 @@ return pos != -1 && code.lastIndexOf("//# sourceMappingURL") < pos;

};
function transformRepl(filename, code, opts) {
export function transformRepl(filename, code, opts) {
opts = Object.assign({}, opts, {

@@ -92,3 +52,3 @@ caller: CALLER,

return new Promise((resolve, reject) => {
babel().transform(code, opts, (err, result) => {
babel.transform(code, opts, (err, result) => {
if (err) reject(err);else resolve(result);

@@ -98,3 +58,3 @@ });

}
function compile(_x, _x2) {
export function compile(_x, _x2) {
return _compile.apply(this, arguments);

@@ -108,3 +68,3 @@ }

const result = yield new Promise((resolve, reject) => {
babel().transformFile(filename, opts, (err, result) => {
babel.transformFile(filename, opts, (err, result) => {
if (err) reject(err);else resolve(result);

@@ -123,13 +83,13 @@ });

}
function deleteDir(path) {
if (_fs().existsSync(path)) {
_fs().readdirSync(path).forEach(function (file) {
export function deleteDir(path) {
if (fs.existsSync(path)) {
fs.readdirSync(path).forEach(function (file) {
const curPath = path + "/" + file;
if (_fs().lstatSync(curPath).isDirectory()) {
if (fs.lstatSync(curPath).isDirectory()) {
deleteDir(curPath);
} else {
_fs().unlinkSync(curPath);
fs.unlinkSync(curPath);
}
});
_fs().rmdirSync(path);
fs.rmdirSync(path);
}

@@ -141,7 +101,7 @@ }

});
function withExtension(filename, ext = ".js") {
const newBasename = _path().basename(filename, _path().extname(filename)) + ext;
return _path().join(_path().dirname(filename), newBasename);
export function withExtension(filename, ext = ".js") {
const newBasename = path.basename(filename, path.extname(filename)) + ext;
return path.join(path.dirname(filename), newBasename);
}
function debounce(fn, time) {
export function debounce(fn, time) {
let timer;

@@ -148,0 +108,0 @@ function debounced() {

@@ -1,18 +0,3 @@

"use strict";
Object.defineProperty(exports, "__esModule", {
value: true
});
exports.enable = enable;
exports.onFilesChange = onFilesChange;
exports.startWatcher = startWatcher;
exports.updateExternalDependencies = updateExternalDependencies;
exports.watch = watch;
function _path() {
const data = require("path");
_path = function () {
return data;
};
return data;
}
import { createRequire } from "module";
import path from "path";
const fileToDeps = new Map();

@@ -24,3 +9,3 @@ const depToFiles = new Map();

let hasStarted = false;
function enable({
export function enable({
enableGlobbing

@@ -44,3 +29,3 @@ }) {

}
function startWatcher() {
export function startWatcher() {
hasStarted = true;

@@ -55,3 +40,3 @@ for (const dep of watchQueue) {

}
function watch(filename) {
export function watch(filename) {
if (!isWatchMode) {

@@ -61,8 +46,8 @@ throw new Error("Internal Babel error: .watch called when not in watch mode.");

if (!hasStarted) {
watchQueue.add(_path().resolve(filename));
watchQueue.add(path.resolve(filename));
} else {
watcher.add(_path().resolve(filename));
watcher.add(path.resolve(filename));
}
}
function onFilesChange(callback) {
export function onFilesChange(callback) {
if (!isWatchMode) {

@@ -74,10 +59,10 @@ throw new Error("Internal Babel error: .onFilesChange called when not in watch mode.");

if (event !== "change" && event !== "add") return;
const absoluteFile = _path().resolve(filename);
const absoluteFile = path.resolve(filename);
callback([absoluteFile, ...((_depToFiles$get = depToFiles.get(absoluteFile)) != null ? _depToFiles$get : [])], event, absoluteFile);
});
}
function updateExternalDependencies(filename, dependencies) {
export function updateExternalDependencies(filename, dependencies) {
if (!isWatchMode) return;
const absFilename = _path().resolve(filename);
const absDependencies = new Set(Array.from(dependencies, dep => _path().resolve(dep)));
const absFilename = path.resolve(filename);
const absDependencies = new Set(Array.from(dependencies, dep => path.resolve(dep)));
const deps = fileToDeps.get(absFilename);

@@ -126,2 +111,3 @@ if (deps) {

function requireChokidar() {
const require = createRequire(import.meta.url);
try {

@@ -128,0 +114,0 @@ return parseInt(process.versions.node) >= 8 ? require("chokidar") : require("@nicolo-ribaudo/chokidar-2");

{
"name": "@babel/cli",
"version": "7.21.4-esm.3",
"version": "7.21.4-esm.4",
"description": "Babel command line.",

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

"devDependencies": {
"@babel/core": "7.21.4-esm.3",
"@babel/helper-fixtures": "7.21.4-esm.3",
"@babel/core": "7.21.4-esm.4",
"@babel/helper-fixtures": "7.21.4-esm.4",
"@types/fs-readdir-recursive": "^1.1.0",

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

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