babel-loader
Advanced tools
Comparing version 8.0.0-beta.4 to 8.0.0-beta.5
@@ -20,3 +20,3 @@ "use strict"; | ||
try { | ||
result = yield transform(source, options); | ||
result = yield transform(source, injectCaller(options)); | ||
} catch (err) { | ||
@@ -58,2 +58,38 @@ throw err.message && err.codeFrame ? new LoaderError(err) : err; | ||
module.exports.version = babel.version; | ||
module.exports.version = babel.version; | ||
function injectCaller(opts) { | ||
if (!supportsCallerOption()) return opts; | ||
return Object.assign({}, opts, { | ||
caller: Object.assign({ | ||
name: "babel-loader", | ||
// Webpack >= 2 supports ESM and dynamic import. | ||
supportsStaticESM: true, | ||
supportsDynamicImport: true | ||
}, opts.caller) | ||
}); | ||
} // 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() { | ||
if (supportsCallerOptionFlag === undefined) { | ||
try { | ||
// Rather than try to match the Babel version, we just see if it throws | ||
// when passed a 'caller' flag, and use that to decide if it is supported. | ||
babel.loadPartialConfig({ | ||
caller: undefined, | ||
babelrc: false, | ||
configFile: false | ||
}); | ||
supportsCallerOptionFlag = true; | ||
} catch (err) { | ||
supportsCallerOptionFlag = false; | ||
} | ||
} | ||
return supportsCallerOptionFlag; | ||
} |
{ | ||
"name": "babel-loader", | ||
"version": "8.0.0-beta.4", | ||
"version": "8.0.0-beta.5", | ||
"description": "babel module loader for webpack", | ||
@@ -5,0 +5,0 @@ "files": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33051
414