babel-loader
Advanced tools
Comparing version 8.2.5 to 9.0.0
192
lib/cache.js
"use strict"; | ||
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); }); }; } | ||
/** | ||
@@ -16,24 +12,20 @@ * Filesystem Cache | ||
*/ | ||
const fs = require("fs"); | ||
const os = require("os"); | ||
const path = require("path"); | ||
const zlib = require("zlib"); | ||
const crypto = require("crypto"); | ||
const findCacheDir = require("find-cache-dir"); | ||
const { | ||
promisify | ||
} = require("util"); | ||
const transform = require("./transform"); // Lazily instantiated when needed | ||
const { | ||
readFile, | ||
writeFile, | ||
mkdir | ||
} = require("node:fs/promises"); | ||
const transform = require("./transform"); | ||
// Lazily instantiated when needed | ||
let defaultCacheDirectory = null; | ||
let hashType = "md4"; // use md5 hashing if md4 is not available | ||
let hashType = "sha256"; | ||
// use md5 hashing if sha256 is not available | ||
try { | ||
@@ -44,9 +36,5 @@ crypto.createHash(hashType); | ||
} | ||
const readFile = promisify(fs.readFile); | ||
const writeFile = promisify(fs.writeFile); | ||
const gunzip = promisify(zlib.gunzip); | ||
const gzip = promisify(zlib.gzip); | ||
const makeDir = require("make-dir"); | ||
/** | ||
@@ -59,15 +47,8 @@ * Read the contents from the compressed file. | ||
*/ | ||
const read = async function (filename, compress) { | ||
const data = await readFile(filename + (compress ? ".gz" : "")); | ||
const content = compress ? await gunzip(data) : data; | ||
return JSON.parse(content.toString()); | ||
}; | ||
const read = /*#__PURE__*/function () { | ||
var _ref = _asyncToGenerator(function* (filename, compress) { | ||
const data = yield readFile(filename + (compress ? ".gz" : "")); | ||
const content = compress ? yield gunzip(data) : data; | ||
return JSON.parse(content.toString()); | ||
}); | ||
return function read(_x, _x2) { | ||
return _ref.apply(this, arguments); | ||
}; | ||
}(); | ||
/** | ||
@@ -81,15 +62,8 @@ * Write contents into a compressed file. | ||
*/ | ||
const write = async function (filename, compress, result) { | ||
const content = JSON.stringify(result); | ||
const data = compress ? await gzip(content) : content; | ||
return await writeFile(filename + (compress ? ".gz" : ""), data); | ||
}; | ||
const write = /*#__PURE__*/function () { | ||
var _ref2 = _asyncToGenerator(function* (filename, compress, result) { | ||
const content = JSON.stringify(result); | ||
const data = compress ? yield gzip(content) : content; | ||
return yield writeFile(filename + (compress ? ".gz" : ""), data); | ||
}); | ||
return function write(_x3, _x4, _x5) { | ||
return _ref2.apply(this, arguments); | ||
}; | ||
}(); | ||
/** | ||
@@ -103,4 +77,2 @@ * Build the filename for the cached file | ||
*/ | ||
const filename = function (source, identifier, options) { | ||
@@ -116,2 +88,3 @@ const hash = crypto.createHash(hashType); | ||
}; | ||
/** | ||
@@ -123,55 +96,46 @@ * Handle the cache | ||
*/ | ||
const handleCache = async function (directory, params) { | ||
const { | ||
source, | ||
options = {}, | ||
cacheIdentifier, | ||
cacheDirectory, | ||
cacheCompression | ||
} = params; | ||
const file = path.join(directory, filename(source, cacheIdentifier, options)); | ||
try { | ||
// No errors mean that the file was previously cached | ||
// we just need to return it | ||
return await read(file, cacheCompression); | ||
} catch (err) {} | ||
const fallback = typeof cacheDirectory !== "string" && directory !== os.tmpdir(); | ||
// Make sure the directory exists. | ||
try { | ||
// overwrite directory if exists | ||
await mkdir(directory, { | ||
recursive: true | ||
}); | ||
} catch (err) { | ||
if (fallback) { | ||
return handleCache(os.tmpdir(), params); | ||
} | ||
throw err; | ||
} | ||
const handleCache = /*#__PURE__*/function () { | ||
var _ref3 = _asyncToGenerator(function* (directory, params) { | ||
const { | ||
source, | ||
options = {}, | ||
cacheIdentifier, | ||
cacheDirectory, | ||
cacheCompression | ||
} = params; | ||
const file = path.join(directory, filename(source, cacheIdentifier, options)); | ||
try { | ||
// No errors mean that the file was previously cached | ||
// we just need to return it | ||
return yield read(file, cacheCompression); | ||
} catch (err) {} | ||
const fallback = typeof cacheDirectory !== "string" && directory !== os.tmpdir(); // Make sure the directory exists. | ||
try { | ||
yield makeDir(directory); | ||
} catch (err) { | ||
if (fallback) { | ||
return handleCache(os.tmpdir(), params); | ||
} | ||
throw err; | ||
} // Otherwise just transform the file | ||
// return it to the user asap and write it in cache | ||
const result = yield transform(source, options); | ||
try { | ||
yield write(file, cacheCompression, result); | ||
} catch (err) { | ||
if (fallback) { | ||
// Fallback to tmpdir if node_modules folder not writable | ||
return handleCache(os.tmpdir(), params); | ||
} | ||
throw err; | ||
// Otherwise just transform the file | ||
// return it to the user asap and write it in cache | ||
const result = await transform(source, options); | ||
try { | ||
await write(file, cacheCompression, result); | ||
} catch (err) { | ||
if (fallback) { | ||
// Fallback to tmpdir if node_modules folder not writable | ||
return handleCache(os.tmpdir(), params); | ||
} | ||
throw err; | ||
} | ||
return result; | ||
}; | ||
return result; | ||
}); | ||
return function handleCache(_x6, _x7) { | ||
return _ref3.apply(this, arguments); | ||
}; | ||
}(); | ||
/** | ||
@@ -202,25 +166,15 @@ * Retrieve file from cache, or create a new one for future reads | ||
module.exports = /*#__PURE__*/function () { | ||
var _ref4 = _asyncToGenerator(function* (params) { | ||
let directory; | ||
if (typeof params.cacheDirectory === "string") { | ||
directory = params.cacheDirectory; | ||
} else { | ||
if (defaultCacheDirectory === null) { | ||
defaultCacheDirectory = findCacheDir({ | ||
name: "babel-loader" | ||
}) || os.tmpdir(); | ||
} | ||
directory = defaultCacheDirectory; | ||
module.exports = async function (params) { | ||
let directory; | ||
if (typeof params.cacheDirectory === "string") { | ||
directory = params.cacheDirectory; | ||
} else { | ||
if (defaultCacheDirectory === null) { | ||
defaultCacheDirectory = findCacheDir({ | ||
name: "babel-loader" | ||
}) || os.tmpdir(); | ||
} | ||
return yield handleCache(directory, params); | ||
}); | ||
return function (_x8) { | ||
return _ref4.apply(this, arguments); | ||
}; | ||
}(); | ||
directory = defaultCacheDirectory; | ||
} | ||
return await handleCache(directory, params); | ||
}; |
"use strict"; | ||
const STRIP_FILENAME_RE = /^[^:]+: /; | ||
const format = err => { | ||
@@ -15,6 +14,4 @@ if (err instanceof SyntaxError) { | ||
} | ||
return err; | ||
}; | ||
class LoaderError extends Error { | ||
@@ -34,5 +31,3 @@ constructor(err) { | ||
} | ||
} | ||
module.exports = LoaderError; |
320
lib/index.js
"use strict"; | ||
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); }); }; } | ||
let babel; | ||
try { | ||
@@ -13,34 +8,23 @@ babel = require("@babel/core"); | ||
if (err.code === "MODULE_NOT_FOUND") { | ||
err.message += "\n babel-loader@8 requires Babel 7.x (the package '@babel/core'). " + "If you'd like to use Babel 6.x ('babel-core'), you should install 'babel-loader@7'."; | ||
err.message += "\n babel-loader@9 requires Babel 7.12+ (the package '@babel/core'). " + "If you'd like to use Babel 6.x ('babel-core'), you should install 'babel-loader@7'."; | ||
} | ||
throw err; | ||
} | ||
throw err; | ||
} // Since we've got the reverse bridge package at @babel/core@6.x, give | ||
// Since we've got the reverse bridge package at @babel/core@6.x, give | ||
// people useful feedback if they try to use it alongside babel-loader. | ||
if (/^6\./.test(babel.version)) { | ||
throw new Error("\n babel-loader@8 will not work with the '@babel/core@6' bridge package. " + "If you want to use Babel 6.x, install 'babel-loader@7'."); | ||
throw new Error("\n babel-loader@9 will not work with the '@babel/core@6' bridge package. " + "If you want to use Babel 6.x, install 'babel-loader@7'."); | ||
} | ||
const { | ||
version | ||
} = require("../package.json"); | ||
const cache = require("./cache"); | ||
const transform = require("./transform"); | ||
const injectCaller = require("./injectCaller"); | ||
const schema = require("./schema"); | ||
const { | ||
isAbsolute | ||
} = require("path"); | ||
const loaderUtils = require("loader-utils"); | ||
const validateOptions = require("schema-utils"); | ||
const validateOptions = require("schema-utils").validate; | ||
function subscribe(subscriber, metadata, context) { | ||
@@ -51,6 +35,4 @@ if (context[subscriber]) { | ||
} | ||
module.exports = makeLoader(); | ||
module.exports.custom = makeLoader; | ||
function makeLoader(callback) { | ||
@@ -64,186 +46,136 @@ const overrides = callback ? callback(babel) : undefined; | ||
} | ||
async function loader(source, inputSourceMap, overrides) { | ||
const filename = this.resourcePath; | ||
let loaderOptions = this.getOptions(); | ||
validateOptions(schema, loaderOptions, { | ||
name: "Babel loader" | ||
}); | ||
if (loaderOptions.customize != null) { | ||
if (typeof loaderOptions.customize !== "string") { | ||
throw new Error("Customized loaders must be implemented as standalone modules."); | ||
} | ||
if (!isAbsolute(loaderOptions.customize)) { | ||
throw new Error("Customized loaders must be passed as absolute paths, since " + "babel-loader has no way to know what they would be relative to."); | ||
} | ||
if (overrides) { | ||
throw new Error("babel-loader's 'customize' option is not available when already " + "using a customized babel-loader wrapper."); | ||
} | ||
let override = require(loaderOptions.customize); | ||
if (override.__esModule) override = override.default; | ||
if (typeof override !== "function") { | ||
throw new Error("Custom overrides must be functions."); | ||
} | ||
overrides = override(babel); | ||
} | ||
let customOptions; | ||
if (overrides && overrides.customOptions) { | ||
const result = await overrides.customOptions.call(this, loaderOptions, { | ||
source, | ||
map: inputSourceMap | ||
}); | ||
customOptions = result.custom; | ||
loaderOptions = result.loader; | ||
} | ||
function loader(_x, _x2, _x3) { | ||
return _loader.apply(this, arguments); | ||
} | ||
// Deprecation handling | ||
if ("forceEnv" in loaderOptions) { | ||
console.warn("The option `forceEnv` has been removed in favor of `envName` in Babel 7."); | ||
} | ||
if (typeof loaderOptions.babelrc === "string") { | ||
console.warn("The option `babelrc` should not be set to a string anymore in the babel-loader config. " + "Please update your configuration and set `babelrc` to true or false.\n" + "If you want to specify a specific babel config file to inherit config from " + "please use the `extends` option.\nFor more information about this options see " + "https://babeljs.io/docs/core-packages/#options"); | ||
} | ||
function _loader() { | ||
_loader = _asyncToGenerator(function* (source, inputSourceMap, overrides) { | ||
const filename = this.resourcePath; | ||
let loaderOptions = loaderUtils.getOptions(this); | ||
validateOptions(schema, loaderOptions, { | ||
name: "Babel loader" | ||
// Standardize on 'sourceMaps' as the key passed through to Webpack, so that | ||
// users may safely use either one alongside our default use of | ||
// 'this.sourceMap' below without getting error about conflicting aliases. | ||
if (Object.prototype.hasOwnProperty.call(loaderOptions, "sourceMap") && !Object.prototype.hasOwnProperty.call(loaderOptions, "sourceMaps")) { | ||
loaderOptions = Object.assign({}, loaderOptions, { | ||
sourceMaps: loaderOptions.sourceMap | ||
}); | ||
if (loaderOptions.customize != null) { | ||
if (typeof loaderOptions.customize !== "string") { | ||
throw new Error("Customized loaders must be implemented as standalone modules."); | ||
} | ||
if (!isAbsolute(loaderOptions.customize)) { | ||
throw new Error("Customized loaders must be passed as absolute paths, since " + "babel-loader has no way to know what they would be relative to."); | ||
} | ||
if (overrides) { | ||
throw new Error("babel-loader's 'customize' option is not available when already " + "using a customized babel-loader wrapper."); | ||
} | ||
let override = require(loaderOptions.customize); | ||
if (override.__esModule) override = override.default; | ||
if (typeof override !== "function") { | ||
throw new Error("Custom overrides must be functions."); | ||
} | ||
overrides = override(babel); | ||
} | ||
let customOptions; | ||
if (overrides && overrides.customOptions) { | ||
const result = yield overrides.customOptions.call(this, loaderOptions, { | ||
delete loaderOptions.sourceMap; | ||
} | ||
const programmaticOptions = Object.assign({}, loaderOptions, { | ||
filename, | ||
inputSourceMap: inputSourceMap || loaderOptions.inputSourceMap, | ||
// Set the default sourcemap behavior based on Webpack's mapping flag, | ||
// but allow users to override if they want. | ||
sourceMaps: loaderOptions.sourceMaps === undefined ? this.sourceMap : loaderOptions.sourceMaps, | ||
// Ensure that Webpack will get a full absolute path in the sourcemap | ||
// so that it can properly map the module back to its internal cached | ||
// modules. | ||
sourceFileName: filename | ||
}); | ||
// Remove loader related options | ||
delete programmaticOptions.customize; | ||
delete programmaticOptions.cacheDirectory; | ||
delete programmaticOptions.cacheIdentifier; | ||
delete programmaticOptions.cacheCompression; | ||
delete programmaticOptions.metadataSubscribers; | ||
const config = await babel.loadPartialConfigAsync(injectCaller(programmaticOptions, this.target)); | ||
if (config) { | ||
let options = config.options; | ||
if (overrides && overrides.config) { | ||
options = await overrides.config.call(this, config, { | ||
source, | ||
map: inputSourceMap | ||
map: inputSourceMap, | ||
customOptions | ||
}); | ||
customOptions = result.custom; | ||
loaderOptions = result.loader; | ||
} // Deprecation handling | ||
if ("forceEnv" in loaderOptions) { | ||
console.warn("The option `forceEnv` has been removed in favor of `envName` in Babel 7."); | ||
} | ||
if (typeof loaderOptions.babelrc === "string") { | ||
console.warn("The option `babelrc` should not be set to a string anymore in the babel-loader config. " + "Please update your configuration and set `babelrc` to true or false.\n" + "If you want to specify a specific babel config file to inherit config from " + "please use the `extends` option.\nFor more information about this options see " + "https://babeljs.io/docs/core-packages/#options"); | ||
} // Standardize on 'sourceMaps' as the key passed through to Webpack, so that | ||
// users may safely use either one alongside our default use of | ||
// 'this.sourceMap' below without getting error about conflicting aliases. | ||
if (Object.prototype.hasOwnProperty.call(loaderOptions, "sourceMap") && !Object.prototype.hasOwnProperty.call(loaderOptions, "sourceMaps")) { | ||
loaderOptions = Object.assign({}, loaderOptions, { | ||
sourceMaps: loaderOptions.sourceMap | ||
if (options.sourceMaps === "inline") { | ||
// Babel has this weird behavior where if you set "inline", we | ||
// inline the sourcemap, and set 'result.map = null'. This results | ||
// in bad behavior from Babel since the maps get put into the code, | ||
// which Webpack does not expect, and because the map we return to | ||
// Webpack is null, which is also bad. To avoid that, we override the | ||
// behavior here so "inline" just behaves like 'true'. | ||
options.sourceMaps = true; | ||
} | ||
const { | ||
cacheDirectory = null, | ||
cacheIdentifier = JSON.stringify({ | ||
options, | ||
"@babel/core": transform.version, | ||
"@babel/loader": version | ||
}), | ||
cacheCompression = true, | ||
metadataSubscribers = [] | ||
} = loaderOptions; | ||
let result; | ||
if (cacheDirectory) { | ||
result = await cache({ | ||
source, | ||
options, | ||
transform, | ||
cacheDirectory, | ||
cacheIdentifier, | ||
cacheCompression | ||
}); | ||
delete loaderOptions.sourceMap; | ||
} else { | ||
result = await transform(source, options); | ||
} | ||
const programmaticOptions = Object.assign({}, loaderOptions, { | ||
filename, | ||
inputSourceMap: inputSourceMap || loaderOptions.inputSourceMap, | ||
// Set the default sourcemap behavior based on Webpack's mapping flag, | ||
// but allow users to override if they want. | ||
sourceMaps: loaderOptions.sourceMaps === undefined ? this.sourceMap : loaderOptions.sourceMaps, | ||
// Ensure that Webpack will get a full absolute path in the sourcemap | ||
// so that it can properly map the module back to its internal cached | ||
// modules. | ||
sourceFileName: filename | ||
}); // Remove loader related options | ||
delete programmaticOptions.customize; | ||
delete programmaticOptions.cacheDirectory; | ||
delete programmaticOptions.cacheIdentifier; | ||
delete programmaticOptions.cacheCompression; | ||
delete programmaticOptions.metadataSubscribers; | ||
if (!babel.loadPartialConfig) { | ||
throw new Error(`babel-loader ^8.0.0-beta.3 requires @babel/core@7.0.0-beta.41, but ` + `you appear to be using "${babel.version}". Either update your ` + `@babel/core version, or pin you babel-loader version to 8.0.0-beta.2`); | ||
} // babel.loadPartialConfigAsync is available in v7.8.0+ | ||
const { | ||
loadPartialConfigAsync = babel.loadPartialConfig | ||
} = babel; | ||
const config = yield loadPartialConfigAsync(injectCaller(programmaticOptions, this.target)); | ||
if (config) { | ||
let options = config.options; | ||
if (overrides && overrides.config) { | ||
options = yield overrides.config.call(this, config, { | ||
config.files.forEach(configFile => this.addDependency(configFile)); | ||
if (result) { | ||
if (overrides && overrides.result) { | ||
result = await overrides.result.call(this, result, { | ||
source, | ||
map: inputSourceMap, | ||
customOptions | ||
customOptions, | ||
config, | ||
options | ||
}); | ||
} | ||
if (options.sourceMaps === "inline") { | ||
// Babel has this weird behavior where if you set "inline", we | ||
// inline the sourcemap, and set 'result.map = null'. This results | ||
// in bad behavior from Babel since the maps get put into the code, | ||
// which Webpack does not expect, and because the map we return to | ||
// Webpack is null, which is also bad. To avoid that, we override the | ||
// behavior here so "inline" just behaves like 'true'. | ||
options.sourceMaps = true; | ||
} | ||
const { | ||
cacheDirectory = null, | ||
cacheIdentifier = JSON.stringify({ | ||
options, | ||
"@babel/core": transform.version, | ||
"@babel/loader": version | ||
}), | ||
cacheCompression = true, | ||
metadataSubscribers = [] | ||
} = loaderOptions; | ||
let result; | ||
code, | ||
map, | ||
metadata | ||
} = result; | ||
metadataSubscribers.forEach(subscriber => { | ||
subscribe(subscriber, metadata, this); | ||
}); | ||
return [code, map]; | ||
} | ||
} | ||
if (cacheDirectory) { | ||
result = yield cache({ | ||
source, | ||
options, | ||
transform, | ||
cacheDirectory, | ||
cacheIdentifier, | ||
cacheCompression | ||
}); | ||
} else { | ||
result = yield transform(source, options); | ||
} // Availabe since Babel 7.12 | ||
// https://github.com/babel/babel/pull/11907 | ||
if (config.files) { | ||
config.files.forEach(configFile => this.addDependency(configFile)); | ||
} else { | ||
// .babelrc.json | ||
if (typeof config.babelrc === "string") { | ||
this.addDependency(config.babelrc); | ||
} // babel.config.js | ||
if (config.config) { | ||
this.addDependency(config.config); | ||
} | ||
} | ||
if (result) { | ||
if (overrides && overrides.result) { | ||
result = yield overrides.result.call(this, result, { | ||
source, | ||
map: inputSourceMap, | ||
customOptions, | ||
config, | ||
options | ||
}); | ||
} | ||
const { | ||
code, | ||
map, | ||
metadata | ||
} = result; | ||
metadataSubscribers.forEach(subscriber => { | ||
subscribe(subscriber, metadata, this); | ||
}); | ||
return [code, map]; | ||
} | ||
} // If the file was ignored, pass through the original content. | ||
return [source, inputSourceMap]; | ||
}); | ||
return _loader.apply(this, arguments); | ||
// If the file was ignored, pass through the original content. | ||
return [source, inputSourceMap]; | ||
} |
"use strict"; | ||
const babel = require("@babel/core"); | ||
module.exports = function injectCaller(opts, target) { | ||
@@ -22,9 +21,8 @@ if (!supportsCallerOption()) return opts; | ||
}); | ||
}; // TODO: We can remove this eventually, I'm just adding it so that people have | ||
}; | ||
// TODO: We can remove this eventually, I'm just adding it so that people have | ||
// a little time to migrate to the newer RCs of @babel/core without getting | ||
// hard-to-diagnose errors about unknown 'caller' options. | ||
let supportsCallerOptionFlag = undefined; | ||
function supportsCallerOption() { | ||
@@ -45,4 +43,3 @@ if (supportsCallerOptionFlag === undefined) { | ||
} | ||
return supportsCallerOptionFlag; | ||
} |
"use strict"; | ||
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); }); }; } | ||
const babel = require("@babel/core"); | ||
const { | ||
promisify | ||
} = require("util"); | ||
const LoaderError = require("./Error"); | ||
const transform = promisify(babel.transform); | ||
module.exports = async function (source, options) { | ||
let result; | ||
try { | ||
result = await transform(source, options); | ||
} catch (err) { | ||
throw err.message && err.codeFrame ? new LoaderError(err) : err; | ||
} | ||
if (!result) return null; | ||
module.exports = /*#__PURE__*/function () { | ||
var _ref = _asyncToGenerator(function* (source, options) { | ||
let result; | ||
try { | ||
result = yield transform(source, options); | ||
} catch (err) { | ||
throw err.message && err.codeFrame ? new LoaderError(err) : err; | ||
} | ||
if (!result) return null; // We don't return the full result here because some entries are not | ||
// really serializable. For a full list of properties see here: | ||
// https://github.com/babel/babel/blob/main/packages/babel-core/src/transformation/index.js | ||
// For discussion on this topic see here: | ||
// https://github.com/babel/babel-loader/pull/629 | ||
const { | ||
ast, | ||
code, | ||
map, | ||
metadata, | ||
sourceType | ||
} = result; | ||
if (map && (!map.sourcesContent || !map.sourcesContent.length)) { | ||
map.sourcesContent = [source]; | ||
} | ||
return { | ||
ast, | ||
code, | ||
map, | ||
metadata, | ||
sourceType | ||
}; | ||
}); | ||
return function (_x, _x2) { | ||
return _ref.apply(this, arguments); | ||
// We don't return the full result here because some entries are not | ||
// really serializable. For a full list of properties see here: | ||
// https://github.com/babel/babel/blob/main/packages/babel-core/src/transformation/index.js | ||
// For discussion on this topic see here: | ||
// https://github.com/babel/babel-loader/pull/629 | ||
const { | ||
ast, | ||
code, | ||
map, | ||
metadata, | ||
sourceType | ||
} = result; | ||
if (map && (!map.sourcesContent || !map.sourcesContent.length)) { | ||
map.sourcesContent = [source]; | ||
} | ||
return { | ||
ast, | ||
code, | ||
map, | ||
metadata, | ||
sourceType | ||
}; | ||
}(); | ||
}; | ||
module.exports.version = babel.version; |
{ | ||
"name": "babel-loader", | ||
"version": "8.2.5", | ||
"version": "9.0.0", | ||
"description": "babel module loader for webpack", | ||
@@ -10,23 +10,21 @@ "files": [ | ||
"engines": { | ||
"node": ">= 8.9" | ||
"node": ">= 14.15.0" | ||
}, | ||
"dependencies": { | ||
"find-cache-dir": "^3.3.1", | ||
"loader-utils": "^2.0.0", | ||
"make-dir": "^3.1.0", | ||
"schema-utils": "^2.6.5" | ||
"find-cache-dir": "^3.3.2", | ||
"schema-utils": "^4.0.0" | ||
}, | ||
"peerDependencies": { | ||
"@babel/core": "^7.0.0", | ||
"webpack": ">=2" | ||
"@babel/core": "^7.12.0", | ||
"webpack": ">=5" | ||
}, | ||
"devDependencies": { | ||
"@ava/babel": "^1.0.1", | ||
"@babel/cli": "^7.12.1", | ||
"@babel/core": "^7.12.3", | ||
"@babel/preset-env": "^7.12.1", | ||
"@babel/cli": "^7.19.3", | ||
"@babel/core": "^7.19.6", | ||
"@babel/preset-env": "^7.19.4", | ||
"ava": "^3.13.0", | ||
"babel-eslint": "^10.0.1", | ||
"babel-plugin-istanbul": "^6.0.0", | ||
"babel-plugin-react-intl": "^8.2.15", | ||
"babel-eslint": "^10.1.0", | ||
"babel-plugin-istanbul": "^6.1.1", | ||
"babel-plugin-react-intl": "^8.2.25", | ||
"cross-env": "^7.0.2", | ||
@@ -124,3 +122,6 @@ "eslint": "^7.13.0", | ||
] | ||
}, | ||
"resolutions": { | ||
"nyc/node-preload": "0.2.0" | ||
} | ||
} |
@@ -1,2 +0,2 @@ | ||
> This README is for babel-loader v8 + Babel v7 | ||
> This README is for babel-loader v8/v9 with Babel v7 | ||
> If you are using legacy Babel v6, see the [7.x branch](https://github.com/babel/babel-loader/tree/7.x) docs | ||
@@ -24,4 +24,8 @@ | ||
> webpack `4.x || 5.x` | babel-loader 8.x | babel 7.x | ||
> | babel-loader | supported webpack versions | supported Babel versions | supported Node.js versions | | ||
> |:-:|:-:|:-:|:-:| | ||
> | 8.x | 4.x or 5.x | 7.x | >= 8.9 | | ||
> | 9.x | 5.x | ^7.12.0 | >= 14.15.0 | | ||
```bash | ||
@@ -28,0 +32,0 @@ npm install -D babel-loader @babel/core @babel/preset-env webpack |
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
4
405
1
37648
470
+ Addedajv@8.12.0(transitive)
+ Addedajv-formats@2.1.1(transitive)
+ Addedajv-keywords@5.1.0(transitive)
+ Addedjson-schema-traverse@1.0.0(transitive)
+ Addedrequire-from-string@2.0.2(transitive)
+ Addedschema-utils@4.2.0(transitive)
- Removedloader-utils@^2.0.0
- Removedmake-dir@^3.1.0
- Removedbig.js@5.2.2(transitive)
- Removedemojis-list@3.0.0(transitive)
- Removedloader-utils@2.0.4(transitive)
- Removedschema-utils@2.7.1(transitive)
Updatedfind-cache-dir@^3.3.2
Updatedschema-utils@^4.0.0