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

@babel/core

Package Overview
Dependencies
Maintainers
4
Versions
196
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@babel/core - npm Package Compare versions

Comparing version 8.0.0-alpha.4 to 8.0.0-alpha.5

9

lib/config/files/plugins.js

@@ -8,2 +8,3 @@ import buildDebug from "debug";

import { createRequire } from "module";
import { existsSync } from "fs";
const require = createRequire(import.meta.url);

@@ -135,3 +136,9 @@ const debug = buildDebug("babel:config:loading:files:plugins");

try {
return resolveStandardizedNameForImport(type, name, dirname);
const resolved = resolveStandardizedNameForImport(type, name, dirname);
if (!existsSync(resolved)) {
throw Object.assign(new Error(`Could not resolve "${name}" in file ${dirname}.`), {
type: "MODULE_NOT_FOUND"
});
}
return resolved;
} catch (e) {

@@ -138,0 +145,0 @@ try {

3

lib/config/helpers/config-api.js

@@ -53,5 +53,2 @@ import semver from "semver";

}
{
range += ` || ^8.0.0-0`;
}
if (semver.satisfies(coreVersion, range)) return;

@@ -58,0 +55,0 @@ const limit = Error.stackTraceLimit;

;
export const version = "8.0.0-alpha.4";
export const version = "8.0.0-alpha.5";
export { default as File } from "./transformation/file/file.js";

@@ -4,0 +4,0 @@ export { default as buildExternalHelpers } from "./tools/build-external-helpers.js";

@@ -9,3 +9,2 @@ import assert from 'assert';

import { format, inspect } from 'util';
const isWindows = process.platform === 'win32';
const own$1 = {}.hasOwnProperty;

@@ -88,4 +87,4 @@ const classRegExp = /^([A-Z][a-z\d]*)+$/;

}, Error);
codes.ERR_MODULE_NOT_FOUND = createError('ERR_MODULE_NOT_FOUND', (path, base, type = 'package') => {
return `Cannot find ${type} '${path}' imported from ${base}`;
codes.ERR_MODULE_NOT_FOUND = createError('ERR_MODULE_NOT_FOUND', (path, base, exactUrl = false) => {
return `Cannot find ${exactUrl ? 'module' : 'package'} '${path}' imported from ${base}`;
}, Error);

@@ -112,10 +111,2 @@ codes.ERR_NETWORK_IMPORT_DISALLOWED = createError('ERR_NETWORK_IMPORT_DISALLOWED', "import of '%s' by %s is not supported: %s", Error);

}, TypeError);
codes.ERR_UNSUPPORTED_ESM_URL_SCHEME = createError('ERR_UNSUPPORTED_ESM_URL_SCHEME', (url, supported) => {
let message = `Only URLs with a scheme in: ${formatList(supported)} are supported by the default ESM loader`;
if (isWindows && url.protocol.length === 2) {
message += '. On Windows, absolute paths must be valid file:// URLs';
}
message += `. Received protocol '${url.protocol}'`;
return message;
}, Error);
function createError(sym, value, def) {

@@ -221,2 +212,7 @@ messages.set(sym, value);

}
const hasOwnProperty$1 = {}.hasOwnProperty;
const {
ERR_INVALID_PACKAGE_CONFIG: ERR_INVALID_PACKAGE_CONFIG$1
} = codes;
const cache = new Map();
const reader = {

@@ -226,81 +222,80 @@ read

var packageJsonReader = reader;
function read(jsonPath) {
try {
const string = fs.readFileSync(path.toNamespacedPath(path.join(path.dirname(jsonPath), 'package.json')), 'utf8');
return {
string
};
} catch (error) {
const exception = error;
if (exception.code === 'ENOENT') {
return {
string: undefined
};
}
throw exception;
}
}
const {
ERR_INVALID_PACKAGE_CONFIG: ERR_INVALID_PACKAGE_CONFIG$1
} = codes;
const packageJsonCache = new Map();
function getPackageConfig(path, specifier, base) {
const existing = packageJsonCache.get(path);
if (existing !== undefined) {
function read(jsonPath, {
base,
specifier
}) {
const existing = cache.get(jsonPath);
if (existing) {
return existing;
}
const source = packageJsonReader.read(path).string;
if (source === undefined) {
const packageConfig = {
pjsonPath: path,
exists: false,
main: undefined,
name: undefined,
type: 'none',
exports: undefined,
imports: undefined
};
packageJsonCache.set(path, packageConfig);
return packageConfig;
}
let packageJson;
let string;
try {
packageJson = JSON.parse(source);
string = fs.readFileSync(path.toNamespacedPath(jsonPath), 'utf8');
} catch (error) {
const exception = error;
throw new ERR_INVALID_PACKAGE_CONFIG$1(path, (base ? `"${specifier}" from ` : '') + fileURLToPath(base || specifier), exception.message);
if (exception.code !== 'ENOENT') {
throw exception;
}
}
const {
exports,
imports,
main,
name,
type
} = packageJson;
const packageConfig = {
pjsonPath: path,
exists: true,
main: typeof main === 'string' ? main : undefined,
name: typeof name === 'string' ? name : undefined,
type: type === 'module' || type === 'commonjs' ? type : 'none',
exports,
imports: imports && typeof imports === 'object' ? imports : undefined
const result = {
exists: false,
pjsonPath: jsonPath,
main: undefined,
name: undefined,
type: 'none',
exports: undefined,
imports: undefined
};
packageJsonCache.set(path, packageConfig);
return packageConfig;
if (string !== undefined) {
let parsed;
try {
parsed = JSON.parse(string);
} catch (error_) {
const cause = error_;
const error = new ERR_INVALID_PACKAGE_CONFIG$1(jsonPath, (base ? `"${specifier}" from ` : '') + fileURLToPath(base || specifier), cause.message);
error.cause = cause;
throw error;
}
result.exists = true;
if (hasOwnProperty$1.call(parsed, 'name') && typeof parsed.name === 'string') {
result.name = parsed.name;
}
if (hasOwnProperty$1.call(parsed, 'main') && typeof parsed.main === 'string') {
result.main = parsed.main;
}
if (hasOwnProperty$1.call(parsed, 'exports')) {
result.exports = parsed.exports;
}
if (hasOwnProperty$1.call(parsed, 'imports')) {
result.imports = parsed.imports;
}
if (hasOwnProperty$1.call(parsed, 'type') && (parsed.type === 'commonjs' || parsed.type === 'module')) {
result.type = parsed.type;
}
}
cache.set(jsonPath, result);
return result;
}
function getPackageScopeConfig(resolved) {
let packageJsonUrl = new URL('package.json', resolved);
let packageJSONUrl = new URL('package.json', resolved);
while (true) {
const packageJsonPath = packageJsonUrl.pathname;
if (packageJsonPath.endsWith('node_modules/package.json')) break;
const packageConfig = getPackageConfig(fileURLToPath(packageJsonUrl), resolved);
if (packageConfig.exists) return packageConfig;
const lastPackageJsonUrl = packageJsonUrl;
packageJsonUrl = new URL('../package.json', packageJsonUrl);
if (packageJsonUrl.pathname === lastPackageJsonUrl.pathname) break;
const packageJSONPath = packageJSONUrl.pathname;
if (packageJSONPath.endsWith('node_modules/package.json')) {
break;
}
const packageConfig = packageJsonReader.read(fileURLToPath(packageJSONUrl), {
specifier: resolved
});
if (packageConfig.exists) {
return packageConfig;
}
const lastPackageJSONUrl = packageJSONUrl;
packageJSONUrl = new URL('../package.json', packageJSONUrl);
if (packageJSONUrl.pathname === lastPackageJSONUrl.pathname) {
break;
}
}
const packageJsonPath = fileURLToPath(packageJsonUrl);
const packageConfig = {
pjsonPath: packageJsonPath,
const packageJSONPath = fileURLToPath(packageJSONUrl);
return {
pjsonPath: packageJSONPath,
exists: false,

@@ -313,4 +308,2 @@ main: undefined,

};
packageJsonCache.set(packageJsonPath, packageConfig);
return packageConfig;
}

@@ -370,4 +363,15 @@ function getPackageType(url) {

if (ext === '.js') {
return getPackageType(url) === 'module' ? 'module' : 'commonjs';
const packageType = getPackageType(url);
if (packageType !== 'none') {
return packageType;
}
return 'commonjs';
}
if (ext === '') {
const packageType = getPackageType(url);
if (packageType === 'none' || packageType === 'commonjs') {
return 'commonjs';
}
return 'module';
}
const format = extensionFormatMap[ext];

@@ -383,6 +387,7 @@ if (format) return format;

function defaultGetFormatWithoutErrors(url, context) {
if (!hasOwnProperty.call(protocolHandlers, url.protocol)) {
const protocol = url.protocol;
if (!hasOwnProperty.call(protocolHandlers, protocol)) {
return null;
}
return protocolHandlers[url.protocol](url, context, true) || null;
return protocolHandlers[protocol](url, context, true) || null;
}

@@ -410,3 +415,2 @@ const {

const RegExpPrototypeSymbolReplace = RegExp.prototype[Symbol.replace];
const experimentalNetworkImports = false;
const {

@@ -420,4 +424,3 @@ ERR_NETWORK_IMPORT_DISALLOWED,

ERR_PACKAGE_PATH_NOT_EXPORTED,
ERR_UNSUPPORTED_DIR_IMPORT,
ERR_UNSUPPORTED_ESM_URL_SCHEME
ERR_UNSUPPORTED_DIR_IMPORT
} = codes;

@@ -433,2 +436,5 @@ const own = {}.hasOwnProperty;

function emitInvalidSegmentDeprecation(target, request, match, packageJsonUrl, internal, base, isTarget) {
if (process.noDeprecation) {
return;
}
const pjsonPath = fileURLToPath(packageJsonUrl);

@@ -439,2 +445,5 @@ const double = doubleSlashRegEx.exec(isTarget ? target : request) !== null;

function emitLegacyIndexDeprecation(url, packageJsonUrl, base, main) {
if (process.noDeprecation) {
return;
}
const format = defaultGetFormatWithoutErrors(url, {

@@ -444,6 +453,10 @@ parentURL: base.href

if (format !== 'module') return;
const path = fileURLToPath(url.href);
const urlPath = fileURLToPath(url.href);
const pkgPath = fileURLToPath(new URL('.', packageJsonUrl));
const basePath = fileURLToPath(base);
if (main) process.emitWarning(`Package ${pkgPath} has a "main" field set to ${JSON.stringify(main)}, ` + `excluding the full filename and extension to the resolved file at "${path.slice(pkgPath.length)}", imported from ${basePath}.\n Automatic extension resolution of the "main" field is` + 'deprecated for ES modules.', 'DeprecationWarning', 'DEP0151');else process.emitWarning(`No "main" or "exports" field defined in the package.json for ${pkgPath} resolving the main entry point "${path.slice(pkgPath.length)}", imported from ${basePath}.\nDefault "index" lookups for the main are deprecated for ES modules.`, 'DeprecationWarning', 'DEP0151');
if (!main) {
process.emitWarning(`No "main" or "exports" field defined in the package.json for ${pkgPath} resolving the main entry point "${urlPath.slice(pkgPath.length)}", imported from ${basePath}.\nDefault "index" lookups for the main are deprecated for ES modules.`, 'DeprecationWarning', 'DEP0151');
} else if (path.resolve(pkgPath, main) !== urlPath) {
process.emitWarning(`Package ${pkgPath} has a "main" field set to "${main}", ` + `excluding the full filename and extension to the resolved file at "${urlPath.slice(pkgPath.length)}", imported from ${basePath}.\n Automatic extension resolution of the "main" field is ` + 'deprecated for ES modules.', 'DeprecationWarning', 'DEP0151');
}
}

@@ -495,4 +508,18 @@ function tryStatSync(path) {

function finalizeResolution(resolved, base, preserveSymlinks) {
if (encodedSepRegEx.exec(resolved.pathname) !== null) throw new ERR_INVALID_MODULE_SPECIFIER(resolved.pathname, 'must not include encoded "/" or "\\" characters', fileURLToPath(base));
const filePath = fileURLToPath(resolved);
if (encodedSepRegEx.exec(resolved.pathname) !== null) {
throw new ERR_INVALID_MODULE_SPECIFIER(resolved.pathname, 'must not include encoded "/" or "\\" characters', fileURLToPath(base));
}
let filePath;
try {
filePath = fileURLToPath(resolved);
} catch (error) {
const cause = error;
Object.defineProperty(cause, 'input', {
value: String(resolved)
});
Object.defineProperty(cause, 'module', {
value: String(base)
});
throw cause;
}
const stats = tryStatSync(filePath.endsWith('/') ? filePath.slice(-1) : filePath);

@@ -505,3 +532,5 @@ if (stats.isDirectory()) {

if (!stats.isFile()) {
throw new ERR_MODULE_NOT_FOUND(filePath || resolved.pathname, base && fileURLToPath(base), 'module');
const error = new ERR_MODULE_NOT_FOUND(filePath || resolved.pathname, base && fileURLToPath(base), true);
error.url = String(resolved);
throw error;
}

@@ -664,2 +693,5 @@ if (!preserveSymlinks) {

function emitTrailingSlashPatternDeprecation(match, pjsonUrl, base) {
if (process.noDeprecation) {
return;
}
const pjsonPath = fileURLToPath(pjsonUrl);

@@ -823,3 +855,6 @@ if (emittedPackageWarnings.has(pjsonPath + '|' + match)) return;

}
const packageConfig = getPackageConfig(packageJsonPath, specifier, base);
const packageConfig = packageJsonReader.read(packageJsonPath, {
base,
specifier
});
if (packageConfig.exports !== undefined && packageConfig.exports !== null) {

@@ -833,3 +868,3 @@ return packageExportsResolve(packageJsonUrl, packageSubpath, packageConfig, base, conditions);

} while (packageJsonPath.length !== lastPath.length);
throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base));
throw new ERR_MODULE_NOT_FOUND(packageName, fileURLToPath(base), false);
}

@@ -904,14 +939,2 @@ function isRelativeSpecifier(specifier) {

}
function throwIfUnsupportedURLProtocol(url) {
const protocol = url.protocol;
if (protocol !== 'file:' && protocol !== 'data:' && protocol !== 'node:') {
throw new ERR_UNSUPPORTED_ESM_URL_SCHEME(url);
}
}
function throwIfUnsupportedURLScheme(parsed, experimentalNetworkImports) {
const protocol = parsed?.protocol;
if (protocol && protocol !== 'file:' && protocol !== 'data:' && (!experimentalNetworkImports || protocol !== 'https:' && protocol !== 'http:')) {
throw new ERR_UNSUPPORTED_ESM_URL_SCHEME(parsed, ['file', 'data'].concat(experimentalNetworkImports ? ['https', 'http'] : []));
}
}
function defaultResolve(specifier, context = {}) {

@@ -933,3 +956,3 @@ const {

const protocol = parsed.protocol;
if (protocol === 'data:' || experimentalNetworkImports && (protocol === 'https:' || protocol === 'http:')) {
if (protocol === 'data:') {
return {

@@ -946,6 +969,4 @@ url: parsed.href,

};
throwIfUnsupportedURLScheme(parsed, experimentalNetworkImports);
const conditions = getConditionsSet(context.conditions);
const url = moduleResolve(specifier, new URL(parentURL), conditions, false);
throwIfUnsupportedURLProtocol(url);
return {

@@ -968,3 +989,3 @@ url: url.href,

const exception = error;
if (exception.code === 'ERR_UNSUPPORTED_DIR_IMPORT' && typeof exception.url === 'string') {
if ((exception.code === 'ERR_UNSUPPORTED_DIR_IMPORT' || exception.code === 'ERR_MODULE_NOT_FOUND') && typeof exception.url === 'string') {
return exception.url;

@@ -971,0 +992,0 @@ }

{
"name": "@babel/core",
"version": "8.0.0-alpha.4",
"version": "8.0.0-alpha.5",
"description": "Babel compiler core.",

@@ -50,11 +50,11 @@ "main": "./lib/index.js",

"@ampproject/remapping": "^2.2.0",
"@babel/code-frame": "^8.0.0-alpha.4",
"@babel/generator": "^8.0.0-alpha.4",
"@babel/helper-compilation-targets": "^8.0.0-alpha.4",
"@babel/helper-module-transforms": "^8.0.0-alpha.4",
"@babel/helpers": "^8.0.0-alpha.4",
"@babel/parser": "^8.0.0-alpha.4",
"@babel/template": "^8.0.0-alpha.4",
"@babel/traverse": "^8.0.0-alpha.4",
"@babel/types": "^8.0.0-alpha.4",
"@babel/code-frame": "^8.0.0-alpha.5",
"@babel/generator": "^8.0.0-alpha.5",
"@babel/helper-compilation-targets": "^8.0.0-alpha.5",
"@babel/helper-module-transforms": "^8.0.0-alpha.5",
"@babel/helpers": "^8.0.0-alpha.5",
"@babel/parser": "^8.0.0-alpha.5",
"@babel/template": "^8.0.0-alpha.5",
"@babel/traverse": "^8.0.0-alpha.5",
"@babel/types": "^8.0.0-alpha.5",
"convert-source-map": "^2.0.0",

@@ -67,8 +67,8 @@ "debug": "^4.1.0",

"devDependencies": {
"@babel/helper-transform-fixture-test-runner": "^8.0.0-alpha.4",
"@babel/plugin-syntax-flow": "^8.0.0-alpha.4",
"@babel/plugin-transform-flow-strip-types": "^8.0.0-alpha.4",
"@babel/plugin-transform-modules-commonjs": "^8.0.0-alpha.4",
"@babel/preset-env": "^8.0.0-alpha.4",
"@babel/preset-typescript": "^8.0.0-alpha.4",
"@babel/helper-transform-fixture-test-runner": "^8.0.0-alpha.5",
"@babel/plugin-syntax-flow": "^8.0.0-alpha.5",
"@babel/plugin-transform-flow-strip-types": "^8.0.0-alpha.5",
"@babel/plugin-transform-modules-commonjs": "^8.0.0-alpha.5",
"@babel/preset-env": "^8.0.0-alpha.5",
"@babel/preset-typescript": "^8.0.0-alpha.5",
"@jridgewell/trace-mapping": "^0.3.17",

@@ -75,0 +75,0 @@ "@types/convert-source-map": "^2.0.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

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