nav tabs on admin dashboard
This commit is contained in:
372
node_modules/babel-loader/lib/index.js
generated
vendored
372
node_modules/babel-loader/lib/index.js
generated
vendored
@@ -1,183 +1,221 @@
|
||||
"use strict";
|
||||
|
||||
var babel = require("babel-core");
|
||||
var loaderUtils = require("loader-utils");
|
||||
var path = require("path");
|
||||
var cache = require("./fs-cache.js");
|
||||
var exists = require("./utils/exists");
|
||||
var relative = require("./utils/relative");
|
||||
var read = require("./utils/read");
|
||||
var resolveRc = require("./resolve-rc.js");
|
||||
var pkg = require("../package.json");
|
||||
var fs = require("fs");
|
||||
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); } }
|
||||
|
||||
/**
|
||||
* Error thrown by Babel formatted to conform to Webpack reporting.
|
||||
*/
|
||||
function BabelLoaderError(name, message, codeFrame, hideStack, error) {
|
||||
Error.call(this);
|
||||
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); }); }; }
|
||||
|
||||
this.name = "BabelLoaderError";
|
||||
this.message = formatMessage(name, message, codeFrame);
|
||||
this.hideStack = hideStack;
|
||||
this.error = error;
|
||||
let babel;
|
||||
|
||||
Error.captureStackTrace(this, BabelLoaderError);
|
||||
}
|
||||
|
||||
BabelLoaderError.prototype = Object.create(Error.prototype);
|
||||
BabelLoaderError.prototype.constructor = BabelLoaderError;
|
||||
|
||||
var STRIP_FILENAME_RE = /^[^:]+: /;
|
||||
|
||||
var formatMessage = function formatMessage(name, message, codeFrame) {
|
||||
return (name ? name + ": " : "") + message + "\n\n" + codeFrame + "\n";
|
||||
};
|
||||
|
||||
var transpile = function transpile(source, options) {
|
||||
var forceEnv = options.forceEnv;
|
||||
var tmpEnv = void 0;
|
||||
|
||||
delete options.forceEnv;
|
||||
|
||||
if (forceEnv) {
|
||||
tmpEnv = process.env.BABEL_ENV;
|
||||
process.env.BABEL_ENV = forceEnv;
|
||||
try {
|
||||
babel = require("@babel/core");
|
||||
} catch (err) {
|
||||
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'.";
|
||||
}
|
||||
|
||||
var result = void 0;
|
||||
try {
|
||||
result = babel.transform(source, options);
|
||||
} catch (error) {
|
||||
if (forceEnv) restoreBabelEnv(tmpEnv);
|
||||
if (error.message && error.codeFrame) {
|
||||
var message = error.message;
|
||||
var name = void 0;
|
||||
var hideStack = void 0;
|
||||
if (error instanceof SyntaxError) {
|
||||
message = message.replace(STRIP_FILENAME_RE, "");
|
||||
name = "SyntaxError";
|
||||
hideStack = true;
|
||||
} else if (error instanceof TypeError) {
|
||||
message = message.replace(STRIP_FILENAME_RE, "");
|
||||
hideStack = true;
|
||||
throw err;
|
||||
} // 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'.");
|
||||
}
|
||||
|
||||
const pkg = require("../package.json");
|
||||
|
||||
const cache = require("./cache");
|
||||
|
||||
const transform = require("./transform");
|
||||
|
||||
const injectCaller = require("./injectCaller");
|
||||
|
||||
const path = require("path");
|
||||
|
||||
const loaderUtils = require("loader-utils");
|
||||
|
||||
function subscribe(subscriber, metadata, context) {
|
||||
if (context[subscriber]) {
|
||||
context[subscriber](metadata);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = makeLoader();
|
||||
module.exports.custom = makeLoader;
|
||||
|
||||
function makeLoader(callback) {
|
||||
const overrides = callback ? callback(babel) : undefined;
|
||||
return function (source, inputSourceMap) {
|
||||
// Make the loader async
|
||||
const callback = this.async();
|
||||
loader.call(this, source, inputSourceMap, overrides).then(args => callback(null, ...args), err => callback(err));
|
||||
};
|
||||
}
|
||||
|
||||
function loader(_x, _x2, _x3) {
|
||||
return _loader.apply(this, arguments);
|
||||
}
|
||||
|
||||
function _loader() {
|
||||
_loader = _asyncToGenerator(function* (source, inputSourceMap, overrides) {
|
||||
const filename = this.resourcePath;
|
||||
let loaderOptions = loaderUtils.getOptions(this) || {};
|
||||
|
||||
if (loaderOptions.customize != null) {
|
||||
if (typeof loaderOptions.customize !== "string") {
|
||||
throw new Error("Customized loaders must be implemented as standalone modules.");
|
||||
}
|
||||
throw new BabelLoaderError(name, message, error.codeFrame, hideStack, error);
|
||||
} else {
|
||||
throw error;
|
||||
|
||||
if (!path.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);
|
||||
}
|
||||
}
|
||||
var code = result.code;
|
||||
var map = result.map;
|
||||
var metadata = result.metadata;
|
||||
|
||||
if (map && (!map.sourcesContent || !map.sourcesContent.length)) {
|
||||
map.sourcesContent = [source];
|
||||
}
|
||||
let customOptions;
|
||||
|
||||
if (forceEnv) restoreBabelEnv(tmpEnv);
|
||||
|
||||
return {
|
||||
code: code,
|
||||
map: map,
|
||||
metadata: metadata
|
||||
};
|
||||
};
|
||||
|
||||
function restoreBabelEnv(prevValue) {
|
||||
if (prevValue === undefined) {
|
||||
delete process.env.BABEL_ENV;
|
||||
} else {
|
||||
process.env.BABEL_ENV = prevValue;
|
||||
}
|
||||
}
|
||||
|
||||
function passMetadata(s, context, metadata) {
|
||||
if (context[s]) {
|
||||
context[s](metadata);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = function (source, inputSourceMap) {
|
||||
var _this = this;
|
||||
|
||||
var filename = this.resourcePath;
|
||||
|
||||
// Handle options
|
||||
var loaderOptions = loaderUtils.getOptions(this) || {};
|
||||
var fileSystem = this.fs ? this.fs : fs;
|
||||
var babelrcPath = null;
|
||||
if (loaderOptions.babelrc !== false) {
|
||||
babelrcPath = typeof loaderOptions.babelrc === "string" && exists(fileSystem, loaderOptions.babelrc) ? loaderOptions.babelrc : resolveRc(fileSystem, path.dirname(filename));
|
||||
}
|
||||
|
||||
if (babelrcPath) {
|
||||
this.addDependency(babelrcPath);
|
||||
}
|
||||
|
||||
var defaultOptions = {
|
||||
metadataSubscribers: [],
|
||||
inputSourceMap: inputSourceMap,
|
||||
sourceRoot: process.cwd(),
|
||||
filename: filename,
|
||||
cacheIdentifier: JSON.stringify({
|
||||
"babel-loader": pkg.version,
|
||||
"babel-core": babel.version,
|
||||
babelrc: babelrcPath ? read(fileSystem, babelrcPath) : null,
|
||||
env: loaderOptions.forceEnv || process.env.BABEL_ENV || process.env.NODE_ENV || "development"
|
||||
})
|
||||
};
|
||||
|
||||
var options = Object.assign({}, defaultOptions, loaderOptions);
|
||||
|
||||
if (loaderOptions.sourceMap === undefined) {
|
||||
options.sourceMap = this.sourceMap;
|
||||
}
|
||||
|
||||
if (options.sourceFileName === undefined) {
|
||||
options.sourceFileName = relative(options.sourceRoot, options.filename);
|
||||
}
|
||||
|
||||
var cacheDirectory = options.cacheDirectory;
|
||||
var cacheIdentifier = options.cacheIdentifier;
|
||||
var metadataSubscribers = options.metadataSubscribers;
|
||||
|
||||
delete options.cacheDirectory;
|
||||
delete options.cacheIdentifier;
|
||||
delete options.metadataSubscribers;
|
||||
|
||||
if (cacheDirectory) {
|
||||
var callback = this.async();
|
||||
return cache({
|
||||
directory: cacheDirectory,
|
||||
identifier: cacheIdentifier,
|
||||
source: source,
|
||||
options: options,
|
||||
transform: transpile
|
||||
}, function (err) {
|
||||
var _ref = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {},
|
||||
code = _ref.code,
|
||||
map = _ref.map,
|
||||
metadata = _ref.metadata;
|
||||
|
||||
if (err) return callback(err);
|
||||
|
||||
metadataSubscribers.forEach(function (s) {
|
||||
return passMetadata(s, _this, metadata);
|
||||
if (overrides && overrides.customOptions) {
|
||||
const result = yield overrides.customOptions.call(this, loaderOptions, {
|
||||
source,
|
||||
map: inputSourceMap
|
||||
});
|
||||
customOptions = result.custom;
|
||||
loaderOptions = result.loader;
|
||||
} // Deprecation handling
|
||||
|
||||
return callback(null, code, map);
|
||||
});
|
||||
}
|
||||
|
||||
var _transpile = transpile(source, options),
|
||||
code = _transpile.code,
|
||||
map = _transpile.map,
|
||||
metadata = _transpile.metadata;
|
||||
if ("forceEnv" in loaderOptions) {
|
||||
console.warn("The option `forceEnv` has been removed in favor of `envName` in Babel 7.");
|
||||
}
|
||||
|
||||
metadataSubscribers.forEach(function (s) {
|
||||
return passMetadata(s, _this, metadata);
|
||||
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
|
||||
});
|
||||
delete loaderOptions.sourceMap;
|
||||
}
|
||||
|
||||
const programmaticOptions = Object.assign({}, loaderOptions, {
|
||||
filename,
|
||||
inputSourceMap: inputSourceMap || undefined,
|
||||
// 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`);
|
||||
}
|
||||
|
||||
const config = babel.loadPartialConfig(injectCaller(programmaticOptions));
|
||||
|
||||
if (config) {
|
||||
let options = config.options;
|
||||
|
||||
if (overrides && overrides.config) {
|
||||
options = yield overrides.config.call(this, config, {
|
||||
source,
|
||||
map: inputSourceMap,
|
||||
customOptions
|
||||
});
|
||||
}
|
||||
|
||||
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": pkg.version
|
||||
}),
|
||||
cacheCompression = true,
|
||||
metadataSubscribers = []
|
||||
} = loaderOptions;
|
||||
let result;
|
||||
|
||||
if (cacheDirectory) {
|
||||
result = yield cache({
|
||||
source,
|
||||
options,
|
||||
transform,
|
||||
cacheDirectory,
|
||||
cacheIdentifier,
|
||||
cacheCompression
|
||||
});
|
||||
} else {
|
||||
result = yield transform(source, options);
|
||||
} // TODO: Babel should really provide the full list of config files that
|
||||
// were used so that this can also handle files loaded with 'extends'.
|
||||
|
||||
|
||||
if (typeof config.babelrc === "string") {
|
||||
this.addDependency(config.babelrc);
|
||||
}
|
||||
|
||||
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];
|
||||
});
|
||||
|
||||
this.callback(null, code, map);
|
||||
};
|
||||
return _loader.apply(this, arguments);
|
||||
}
|
||||
Reference in New Issue
Block a user