source: frontend/node_modules/babel-loader/lib/injectCaller.js

Last change on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago

Fix frontend appearance

  • Property mode set to 100644
File size: 1.5 KB
RevLine 
[9af201e]1"use strict";
2
3const babel = require("@babel/core");
4module.exports = function injectCaller(opts, target) {
5 if (!supportsCallerOption()) return opts;
6 return Object.assign({}, opts, {
7 caller: Object.assign({
8 name: "babel-loader",
9 // Provide plugins with insight into webpack target.
10 // https://github.com/babel/babel-loader/issues/787
11 target,
12 // Webpack >= 2 supports ESM and dynamic import.
13 supportsStaticESM: true,
14 supportsDynamicImport: true,
15 // Webpack 5 supports TLA behind a flag. We enable it by default
16 // for Babel, and then webpack will throw an error if the experimental
17 // flag isn't enabled.
18 supportsTopLevelAwait: true
19 }, opts.caller)
20 });
21};
22
23// TODO: We can remove this eventually, I'm just adding it so that people have
24// a little time to migrate to the newer RCs of @babel/core without getting
25// hard-to-diagnose errors about unknown 'caller' options.
26let supportsCallerOptionFlag = undefined;
27function supportsCallerOption() {
28 if (supportsCallerOptionFlag === undefined) {
29 try {
30 // Rather than try to match the Babel version, we just see if it throws
31 // when passed a 'caller' flag, and use that to decide if it is supported.
32 babel.loadPartialConfig({
33 caller: undefined,
34 babelrc: false,
35 configFile: false
36 });
37 supportsCallerOptionFlag = true;
38 } catch (err) {
39 supportsCallerOptionFlag = false;
40 }
41 }
42 return supportsCallerOptionFlag;
43}
Note: See TracBrowser for help on using the repository browser.