WIP - add extractor, generate snippet_data
This commit is contained in:
96
node_modules/gatsby/dist/utils/babel-loader.js
generated
vendored
Normal file
96
node_modules/gatsby/dist/utils/babel-loader.js
generated
vendored
Normal file
@ -0,0 +1,96 @@
|
||||
"use strict";
|
||||
|
||||
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
||||
|
||||
var _objectWithoutPropertiesLoose2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutPropertiesLoose"));
|
||||
|
||||
const babelLoader = require(`babel-loader`);
|
||||
|
||||
const {
|
||||
prepareOptions,
|
||||
getCustomOptions,
|
||||
mergeConfigItemOptions
|
||||
} = require(`./babel-loader-helpers`);
|
||||
/**
|
||||
* Gatsby's custom loader for webpack & babel
|
||||
*
|
||||
* Gatsby allows sites to either use our Babel setup (the default)
|
||||
* or to add a .babelrc to take control.
|
||||
*
|
||||
* Our default setup is defined in the fallbackPlugins/fallbackPresets arrays
|
||||
* below.
|
||||
*
|
||||
* After using either the fallback or user supplied setup, we add on a handful
|
||||
* of required plugins and finally merge in any presets/plugins supplied
|
||||
* by Gatsby plugins.
|
||||
*
|
||||
* You can find documentation for the custom loader here: https://babeljs.io/docs/en/next/babel-core.html#loadpartialconfig
|
||||
*/
|
||||
|
||||
|
||||
module.exports = babelLoader.custom(babel => {
|
||||
const toReturn = {
|
||||
// Passed the loader options.
|
||||
customOptions(_ref) {
|
||||
let {
|
||||
stage = `test`
|
||||
} = _ref,
|
||||
options = (0, _objectWithoutPropertiesLoose2.default)(_ref, ["stage"]);
|
||||
return {
|
||||
custom: {
|
||||
stage
|
||||
},
|
||||
loader: Object.assign({
|
||||
cacheDirectory: true,
|
||||
sourceType: `unambiguous`
|
||||
}, getCustomOptions(stage), options)
|
||||
};
|
||||
},
|
||||
|
||||
// Passed Babel's 'PartialConfig' object.
|
||||
config(partialConfig, {
|
||||
customOptions
|
||||
}) {
|
||||
let {
|
||||
options
|
||||
} = partialConfig;
|
||||
const [reduxPresets, reduxPlugins, requiredPresets, requiredPlugins, fallbackPresets] = prepareOptions(babel, customOptions); // If there is no filesystem babel config present, add our fallback
|
||||
// presets/plugins.
|
||||
|
||||
if (!partialConfig.hasFilesystemConfig()) {
|
||||
options = Object.assign({}, options, {
|
||||
plugins: requiredPlugins,
|
||||
presets: [...fallbackPresets, ...requiredPresets]
|
||||
});
|
||||
} else {
|
||||
// With a babelrc present, only add our required plugins/presets
|
||||
options = Object.assign({}, options, {
|
||||
plugins: [...options.plugins, ...requiredPlugins],
|
||||
presets: [...options.presets, ...requiredPresets]
|
||||
});
|
||||
} // Merge in presets/plugins added from gatsby plugins.
|
||||
|
||||
|
||||
reduxPresets.forEach(preset => {
|
||||
options.presets = mergeConfigItemOptions({
|
||||
items: options.presets,
|
||||
itemToMerge: preset,
|
||||
type: `preset`,
|
||||
babel
|
||||
});
|
||||
});
|
||||
reduxPlugins.forEach(plugin => {
|
||||
options.plugins = mergeConfigItemOptions({
|
||||
items: options.plugins,
|
||||
itemToMerge: plugin,
|
||||
type: `plugin`,
|
||||
babel
|
||||
});
|
||||
});
|
||||
return options;
|
||||
}
|
||||
|
||||
};
|
||||
return toReturn;
|
||||
});
|
||||
//# sourceMappingURL=babel-loader.js.map
|
||||
Reference in New Issue
Block a user