Socket
Socket
Sign inDemoInstall

babel-core

Package Overview
Dependencies
51
Maintainers
6
Versions
257
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 6.13.2 to 6.14.0

14

lib/api/browser.js

@@ -149,6 +149,2 @@ "use strict";

/**
* Transform and execute script. Ensures correct load order.
*/
function exec() {

@@ -163,6 +159,2 @@ var param = scripts[index];

/**
* Load, transform, and execute all scripts.
*/
function run(script, i) {

@@ -182,4 +174,2 @@ var opts = {};

// Collect scripts with Babel `types`.
var _scripts = global.document.getElementsByTagName("script");

@@ -199,6 +189,2 @@

/**
* Register load event to transform and execute scripts.
*/
if (global.addEventListener) {

@@ -205,0 +191,0 @@ global.addEventListener("DOMContentLoaded", runScripts, false);

@@ -90,4 +90,2 @@ "use strict";

//
exports.util = util;

@@ -102,4 +100,2 @@ exports.messages = messages;

//
exports.Pipeline = _pipeline2.default;

@@ -113,4 +109,2 @@

//
function transformFile(filename, opts, callback) {

@@ -117,0 +111,0 @@ if ((0, _isFunction2.default)(opts)) {

8

lib/helpers/normalize-ast.js

@@ -23,8 +23,2 @@ "use strict";

module.exports = exports["default"];
/**
* Normalize an AST.
*
* - Wrap `Program` node with a `File` node.
*/
module.exports = exports["default"];

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

// we're in the browser, probably
if ((typeof _module2.default === "undefined" ? "undefined" : (0, _typeof3.default)(_module2.default)) === "object") return null;

@@ -21,8 +20,2 @@

// We need to define an id and filename on our "fake" relative` module so that
// Node knows what "." means in the case of us trying to resolve a plugin
// such as "./myPlugins/somePlugin.js". If we don't specify id and filename here,
// Node presumes "." is process.cwd(), not our relative path.
// Since this fake module is never "loaded", we don't have to worry about mutating
// any global Node module cache state here.
var filename = _path2.default.join(relative, ".babelrc");

@@ -29,0 +22,0 @@ relativeMod.id = filename;

@@ -59,4 +59,2 @@ "use strict";

/* eslint max-len: 0 */
var buildUmdWrapper = (0, _babelTemplate2.default)("\n (function (root, factory) {\n if (typeof define === \"function\" && define.amd) {\n define(AMD_ARGUMENTS, factory);\n } else if (typeof exports === \"object\") {\n factory(COMMON_ARGUMENTS);\n } else {\n factory(BROWSER_ARGUMENTS);\n }\n })(UMD_ROOT, function (FACTORY_PARAMETERS) {\n FACTORY_BODY\n });\n");

@@ -63,0 +61,0 @@

33

lib/transformation/file/index.js

@@ -112,5 +112,2 @@ "use strict";

/* global BabelFileResult, BabelParserOptions, BabelFileMetadata */
/* eslint max-len: 0 */
var INTERNAL_PLUGINS = [[_blockHoist2.default], [_shadowFunctions2.default]];

@@ -154,9 +151,5 @@

// Plugins for top-level options.
_this.buildPluginsForOptions(_this.opts);
// If we are in the "pass per preset" mode, build
// also plugins for each preset.
if (_this.opts.passPerPreset) {
// All the "per preset" options are inherited from the main options.
_this.perPresetOpts = [];

@@ -272,3 +265,2 @@ _this.opts.presets.forEach(function (presetOpts) {

// init plugins!
for (var _iterator2 = plugins, _isArray2 = Array.isArray(_iterator2), _i2 = 0, _iterator2 = _isArray2 ? _iterator2 : (0, _getIterator3.default)(_iterator2);;) {

@@ -288,4 +280,5 @@ var _ref2;

var plugin = ref[0];
var pluginOpts = ref[1]; // todo: fix - can't embed in loop head because of flow bug
var pluginOpts = ref[1];
currentPluginVisitors.push(plugin.visitor);

@@ -309,3 +302,2 @@ currentPluginPasses.push(new _pluginPass2.default(this, plugin, pluginOpts));

// moduleId is n/a if a `getModuleId()` is provided
if (opts.moduleId != null && !opts.getModuleId) {

@@ -327,3 +319,2 @@ return opts.moduleId;

if (opts.sourceRoot != null) {
// remove sourceRoot from filename
var sourceRootRegEx = new RegExp("^" + opts.sourceRoot + "\/?");

@@ -333,3 +324,2 @@ filenameRelative = filenameRelative.replace(sourceRootRegEx, "");

// remove extension
filenameRelative = filenameRelative.replace(/\.(\w*?)$/, "");

@@ -339,7 +329,5 @@

// normalize path separators
moduleName = moduleName.replace(/\\/g, "/");
if (opts.getModuleId) {
// If return is falsy, assume they want us to use our generated default name
return opts.getModuleId(moduleName) || moduleName;

@@ -426,4 +414,2 @@ } else {

File.prototype.addTemplateObject = function addTemplateObject(helperName, strings, raw) {
// Generate a unique name based on the string literals so we dedupe
// identical strings used in the program.
var stringIds = raw.elements.map(function (string) {

@@ -445,4 +431,3 @@ return string.value;

init: init,
_blockHoist: 1.9 // This ensures that we don't fail if not using function expression helpers
});
_blockHoist: 1.9 });
return uid;

@@ -488,4 +473,2 @@ };

// This assumes the output map always has a single source, since Babel always compiles a single source file to a
// single output file.
var source = outputMapConsumer.sources[0];

@@ -553,4 +536,2 @@

File.prototype.transform = function transform() {
// In the "pass per preset" mode, we have grouped passes.
// Otherwise, there is only one plain pluginPasses array.
for (var i = 0; i < this.pluginPasses.length; i++) {

@@ -560,3 +541,6 @@ var pluginPasses = this.pluginPasses[i];

this.log.debug("Start transform traverse");
(0, _babelTraverse2.default)(this.ast, _babelTraverse2.default.visitors.merge(this.pluginVisitors[i], pluginPasses), this.scope);
var visitor = _babelTraverse2.default.visitors.merge(this.pluginVisitors[i], pluginPasses, this.opts.wrapPluginVisitorMethod);
(0, _babelTraverse2.default)(this.ast, visitor, this.scope);
this.log.debug("End transform traverse");

@@ -594,4 +578,2 @@ this.call("post", pluginPasses);

if (process.browser) {
// chrome has it's own pretty stringifier which doesn't use the stack property
// https://github.com/babel/babel/issues/2175
err.message = message;

@@ -715,3 +697,2 @@ }

if (this.shebang) {
// add back shebang
result.code = this.shebang + "\n" + result.code;

@@ -718,0 +699,0 @@ }

@@ -49,6 +49,4 @@ "use strict";

// already seen this message
if (seenDeprecatedMessages.indexOf(msg) >= 0) return;
// make sure we don't see it again
seenDeprecatedMessages.push(msg);

@@ -55,0 +53,0 @@

@@ -97,4 +97,2 @@ "use strict";

// export function foo() {}
// export let foo = "bar";
var declar = path.get("declaration");

@@ -132,3 +130,2 @@ if (declar.isStatement()) {

// export foo from "bar";
if (t.isExportDefaultSpecifier(specifier)) {

@@ -143,3 +140,2 @@ exports.specifiers.push({

// export * as foo from "bar";
if (t.isExportNamespaceSpecifier(specifier)) {

@@ -156,4 +152,2 @@ exports.specifiers.push({

// export { foo } from "bar";
// export { foo as bar } from "bar";
if (source) {

@@ -168,4 +162,2 @@ exports.specifiers.push({

// export { foo };
// export { foo as bar };
if (!source) {

@@ -181,3 +173,2 @@ exports.specifiers.push({

// export * from "bar";
if (path.isExportAllDeclaration()) {

@@ -184,0 +175,0 @@ exports.specifiers.push({

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

// resolve all .babelrc files
if (opts.babelrc !== false) {

@@ -187,3 +186,2 @@ builder.findConfigs(filename);

// add extends clause
if (options.extends) {

@@ -206,3 +204,2 @@ var extendsLoc = (0, _resolve2.default)(options.extends, dirname);

// env
var envOpts = void 0;

@@ -209,0 +206,0 @@ var envKey = process.env.BABEL_ENV || process.env.NODE_ENV || "development";

"use strict";
/* eslint max-len: 0 */
module.exports = {

@@ -107,2 +105,7 @@ filename: {

wrapPluginVisitorMethod: {
hidden: true,
description: "optional callback to wrap all visitor methods"
},
compact: {

@@ -109,0 +112,0 @@ type: "booleanString",

@@ -75,4 +75,2 @@ "use strict";

/* eslint max-len: 0 */
var OptionManager = function () {

@@ -140,3 +138,2 @@ function OptionManager(log) {

if (!(plugin instanceof _plugin3.default)) {
// allow plugin containers to be specified so they don't have to manually require
if (typeof plugin === "function" || (typeof plugin === "undefined" ? "undefined" : (0, _typeof3.default)(plugin)) === "object") {

@@ -163,3 +160,2 @@ plugin = OptionManager.memoisePluginContainer(plugin, loc, i, alias);

// destructure plugins
if (Array.isArray(val)) {

@@ -174,3 +170,2 @@ plugin = val[0];

// allow plugins to be specified as strings
if (typeof plugin === "string") {

@@ -191,12 +186,2 @@ var pluginLoc = (0, _resolve2.default)("babel-plugin-" + plugin, dirname) || (0, _resolve2.default)(plugin, dirname);

/**
* This is called when we want to merge the input `opts` into the
* base options (passed as the `extendingOpts`: at top-level it's the
* main options, at presets level it's presets options).
*
* - `alias` is used to output pretty traces back to the original source.
* - `loc` is used to point to the original config.
* - `dirname` is used to resolve plugins relative to it.
*/
OptionManager.prototype.mergeOptions = function mergeOptions(_ref2) {

@@ -214,3 +199,2 @@ var _this = this;

//
if ((typeof rawOpts === "undefined" ? "undefined" : (0, _typeof3.default)(rawOpts)) !== "object" || Array.isArray(rawOpts)) {

@@ -220,3 +204,2 @@ this.log.error("Invalid options type for " + alias, TypeError);

//
var opts = (0, _cloneDeepWith2.default)(rawOpts, function (val) {

@@ -228,3 +211,2 @@ if (val instanceof _plugin3.default) {

//
dirname = dirname || process.cwd();

@@ -236,3 +218,2 @@ loc = loc || alias;

// check for an unknown option
if (!option && this.log) {

@@ -249,6 +230,4 @@ var pluginOptsInfo = "Check out http://babeljs.io/docs/usage/options/ for more info";

// normalise options
(0, _index.normaliseOptions)(opts);
// resolve plugins
if (opts.plugins) {

@@ -258,6 +237,3 @@ opts.plugins = OptionManager.normalisePlugins(loc, dirname, opts.plugins);

// resolve presets
if (opts.presets) {
// If we're in the "pass per preset" mode, we resolve the presets
// and keep them for further execution to calculate the options.
if (opts.passPerPreset) {

@@ -274,3 +250,2 @@ opts.presets = this.resolvePresets(opts.presets, dirname, function (preset, presetLoc) {

} else {
// Otherwise, just merge presets options into the main options.
this.mergePresets(opts.presets, dirname);

@@ -281,5 +256,2 @@ delete opts.presets;

// Merge them into current extending options in case of top-level
// options. In case of presets, just re-assign options which are got
// normalized during the `mergeOptions`.
if (rawOpts === extendingOpts) {

@@ -292,8 +264,2 @@ (0, _assign2.default)(extendingOpts, opts);

/**
* Merges all presets into the main options in case we are not in the
* "pass per preset" mode. Otherwise, options are calculated per preset.
*/
OptionManager.prototype.mergePresets = function mergePresets(presets, dirname) {

@@ -312,8 +278,2 @@ var _this2 = this;

/**
* Resolves presets options which can be either direct object data,
* or a module name to require.
*/
OptionManager.prototype.resolvePresets = function resolvePresets(presets, dirname, onResolve) {

@@ -342,5 +302,2 @@ return presets.map(function (val) {

// For compatibility with babel-core < 6.13.x, allow presets to export an object with a
// a 'buildPreset' function that will return the preset itself, while still exporting a
// simple object (rather than a function), for supporting old Babel versions.
if ((typeof val === "undefined" ? "undefined" : (0, _typeof3.default)(val)) === "object" && val.buildPreset) val = val.buildPreset;

@@ -370,6 +327,4 @@

// optional
if (!val && option.optional) continue;
// aliases
if (option.alias) {

@@ -403,3 +358,2 @@ opts[option.alias] = opts[option.alias] || val;

// normalise
this.normaliseOptions(opts);

@@ -406,0 +360,0 @@

"use strict";
/* eslint max-len: 0 */
module.exports = {

@@ -27,5 +25,3 @@ "auxiliaryComment": {

},
// "keepModuleIdExtensions": {
// "message": ""
// },
"loose": {

@@ -32,0 +28,0 @@ "message": "Specify the `loose` option for the relevant plugin you are using or use a preset that sets the option."

@@ -16,13 +16,5 @@ "use strict";

exports.default = new _plugin2.default({
/**
* [Please add a description.]
*
* Priority:
*
* - 0 We want this to be at the **very** bottom
* - 1 Default node position
* - 2 Priority over normal nodes
* - 3 We want this to be at the **very** top
*/
name: "internal.blockHoist",
visitor: {

@@ -48,3 +40,2 @@ Block: {

// Higher priorities should move toward the top.
return -1 * priority;

@@ -51,0 +42,0 @@ });

@@ -37,2 +37,4 @@ "use strict";

exports.default = new _plugin2.default({
name: "internal.shadowFunctions",
visitor: {

@@ -60,3 +62,2 @@ ThisExpression: function ThisExpression(path) {

function remap(path, key) {
// ensure that we're shadowed
var shadowPath = path.inShadow(key);

@@ -72,3 +73,2 @@ if (!shouldShadow(path, shadowPath)) return;

if (path.isProgram() || path.isFunction()) {
// catch current function in case this is the shadowed one and we can ignore it
currentFunction = currentFunction || path;

@@ -96,5 +96,2 @@ }

if (shadowFunction && fnPath.isProgram() && !shadowFunction.isProgram()) {
// If the shadow wasn't found, take the closest function as a backup.
// This is a bit of a hack, but it will allow the parameter transforms to work properly
// without introducing yet another shadow-controlling flag.
fnPath = path.findParent(function (p) {

@@ -105,7 +102,4 @@ return p.isProgram() || p.isFunction();

// no point in realiasing if we're in this function
if (fnPath === currentFunction) return;
// If the only functions that were encountered are arrow functions, skip remapping the
// binding since arrow function syntax already does that.
if (!passedShadowFunction) return;

@@ -112,0 +106,0 @@

@@ -78,6 +78,5 @@ "use strict";

return Pipeline;
}(); /* global BabelFileResult, BabelFileMetadata */
}();
exports.default = Pipeline;
module.exports = exports["default"];

@@ -21,6 +21,2 @@ "use strict";

var _babelTraverse = require("babel-traverse");
var _babelTraverse2 = _interopRequireDefault(_babelTraverse);
var _file5 = require("./file");

@@ -42,2 +38,3 @@

_this.plugin = plugin;
_this.key = plugin.key;
_this.file = file;

@@ -48,9 +45,2 @@ _this.opts = options;

PluginPass.prototype.transform = function transform() {
var file = this.file;
file.log.debug("Start transformer " + this.key);
(0, _babelTraverse2.default)(file.ast, this.plugin.visitor, file.scope, file);
file.log.debug("Finish transformer " + this.key);
};
PluginPass.prototype.addHelper = function addHelper() {

@@ -57,0 +47,0 @@ var _file;

@@ -49,4 +49,2 @@ "use strict";

/* eslint max-len: 0 */
var GLOBAL_VISITOR_PROPS = ["enter", "exit"];

@@ -64,3 +62,3 @@

_this.raw = (0, _assign2.default)({}, plugin);
_this.key = key;
_this.key = _this.take("name") || key;

@@ -128,7 +126,2 @@ _this.manipulateOptions = _this.take("manipulateOptions");

/**
* We lazy initialise parts of a plugin that rely on contextual information such as
* position on disk and how it was specified.
*/
Plugin.prototype.init = function init(loc, i) {

@@ -135,0 +128,0 @@ if (this.initialized) return;

@@ -69,6 +69,2 @@ "use strict";

/**
* Test if a filename ends with a compilable extension.
*/
function canCompile(filename, altExts) {

@@ -80,12 +76,4 @@ var exts = altExts || canCompile.EXTENSIONS;

/**
* Default set of compilable extensions.
*/
canCompile.EXTENSIONS = [".js", ".jsx", ".es6", ".es"];
/**
* Create an array from any value, splitting strings by ",".
*/
function list(val) {

@@ -103,6 +91,2 @@ if (!val) {

/**
* Create a RegExp from a string, array, or regexp.
*/
function regexify(val) {

@@ -118,6 +102,4 @@ if (!val) {

if (typeof val === "string") {
// normalise path separators
val = (0, _slash2.default)(val);
// remove starting wildcards or relative separator if present
if ((0, _startsWith2.default)(val, "./") || (0, _startsWith2.default)(val, "*/")) val = val.slice(2);

@@ -137,6 +119,2 @@ if ((0, _startsWith2.default)(val, "**/")) val = val.slice(3);

/**
* Create an array from a boolean, string, or array, mapped by and optional function.
*/
function arrayify(val, mapFn) {

@@ -155,6 +133,2 @@ if (!val) return [];

/**
* Makes boolean-like strings into booleans.
*/
function booleanify(val) {

@@ -172,6 +146,2 @@ if (val === "true" || val == 1) {

/**
* Tests if a filename should be ignored based on "ignore" and "only" options.
*/
function shouldIgnore(filename) {

@@ -223,7 +193,2 @@ var ignore = arguments.length <= 1 || arguments[1] === undefined ? [] : arguments[1];

/**
* Returns result of calling function with filename if pattern is a function.
* Otherwise returns result of matching pattern Regex with filename.
*/
function _shouldIgnore(pattern, filename) {

@@ -230,0 +195,0 @@ if (typeof pattern === "function") {

{
"name": "babel-core",
"version": "6.13.2",
"version": "6.14.0",
"description": "Babel compiler core.",

@@ -28,11 +28,11 @@ "author": "Sebastian McKenzie <sebmck@gmail.com>",

"babel-code-frame": "^6.8.0",
"babel-generator": "^6.11.4",
"babel-generator": "^6.14.0",
"babel-helpers": "^6.8.0",
"babel-messages": "^6.8.0",
"babel-template": "^6.9.0",
"babel-template": "^6.14.0",
"babel-runtime": "^6.9.1",
"babel-register": "^6.9.0",
"babel-traverse": "^6.13.0",
"babel-types": "^6.13.0",
"babylon": "^6.7.0",
"babel-register": "^6.14.0",
"babel-traverse": "^6.14.0",
"babel-types": "^6.14.0",
"babylon": "^6.9.0",
"convert-source-map": "^1.1.0",

@@ -39,0 +39,0 @@ "debug": "^2.1.1",

SocketSocket SOC 2 Logo

Product

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc