Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const path = require('path')
const babelLoader = require('babel-loader')
const { log } = require('saber-log')
const logUpdate = require('log-update')
// increment '0' to invalidate cache
const CACHE_KEY = `babel-cache-0`
module.exports = babelLoader.custom(babel => {
const configs = new Set()
return {
customOptions(opts) {
const custom = opts.customLoaderOptions
const filename = path.join(custom.cwd, 'noop.js')
const loader = Object.assign(
custom.shouldCache
? {
cacheCompression: false,
cacheDirectory: path.join(
custom.distDir,
'cache',
'saber-babel-loader'
),
cacheIdentifier: JSON.stringify({
"use strict";
const npath = require("path");
// Provides `configPath` option to `@babel/preset-env` so it can find
// a browserslist's config file based on source file's location.
module.exports = require("babel-loader").custom(babel => {
return {
config(cfg) {
let options = cfg.options;
const presets = options.presets;
for (let idx = 0; presets && idx < presets.length; idx++) {
const item = presets[idx];
if (item.name === "@babel/preset-env") {
options = Object.assign({}, options, {
presets: [].concat(
presets.slice(0, idx),
babel.createConfigItem(
[
require.resolve("@babel/preset-env"),
Object.assign({}, item.options, {
// Blacklist accidental inclusions
'transform-regenerator',
'transform-async-to-generator',
]
return {
...babelOptions,
'preset-env': presetEnvOptions,
'transform-runtime': transformRuntimeOptions,
}
}
const nextBabelPresetModern = presetOptions => context =>
nextBabelPreset(context, getModernOptions(presetOptions))
module.exports = babelLoader.custom(babel => {
const presetItem = babel.createConfigItem(nextBabelPreset, {
type: 'preset',
})
const applyCommonJs = babel.createConfigItem(
require('../../babel/plugins/commonjs'),
{ type: 'plugin' }
)
const commonJsItem = babel.createConfigItem(
require('@babel/plugin-transform-modules-commonjs'),
{ type: 'plugin' }
)
const configs = new Set()
return {
customOptions(opts) {
const babelLoader = require('babel-loader')
const logger = require('@poi/logger')
const spinner = require('../utils/spinner')
const macroCheck = new RegExp('[./]macro')
module.exports = babelLoader.custom(babel => {
const configs = new Set()
const presetItem = babel.createConfigItem(require('../babel/preset'), {
type: 'preset'
})
return {
customOptions(opts) {
const custom = opts.customLoaderOptions
delete opts.customLoaderOptions
return { loader: opts, custom }
},
config(cfg, { source }) {
const options = Object.assign({}, cfg.options, {
caller: Object.assign({}, cfg.options.caller, {
// for babel-plugin-macros it should never be cached
module.exports = require('babel-loader').custom(() => ({
config(cfg) {
return {
...cfg.options,
presets: [
...(cfg.options.presets || []),
// eslint-disable-next-line global-require
require('babel-preset-webpack-nexus'),
],
};
},
}));
/* eslint-disable prefer-object-spread */
/* eslint-disable no-restricted-syntax */
import babelLoader from 'babel-loader'
import preset from '../../babel/preset'
module.exports = babelLoader.custom(babel => {
const presetItem = babel.createConfigItem(preset, {
type: 'preset',
})
const configs = new Set()
return {
customOptions(opts) {
const custom = {
isServer: opts.isServer,
dev: opts.dev,
}
const loader = Object.assign(
{
cacheCompression: false,
const transformFixDefaultExport = require('./transform-fix-default-export');
module.exports = require('babel-loader').custom(babel => {
// function myPlugin() {
// return {
// visitor: {},
// };
// }
const customOptions = {};
return {
// Passed the loader options.
customOptions({ __createDll, __react, __typescript, ...loader }) {
Object.assign(customOptions, {
__createDll,
__react,
__typescript
});
// Pull out any custom options that the loader might have.
const babelLoader = require('babel-loader')
const logger = require('@poi/cli-utils/logger')
const macroCheck = new RegExp('[./]macro')
module.exports = babelLoader.custom(babel => {
const presetItem = babel.createConfigItem(require('../../babel/preset'), {
type: 'preset'
})
const configs = new Set()
return {
customOptions(opts) {
const custom = opts.customLoaderOptions
delete opts.customLoaderOptions
return { loader: opts, custom }
},
config(cfg, { source }) {
const options = Object.assign({}, cfg.options, {
caller: Object.assign({}, cfg.options.caller, {
// for babel-plugin-macros it should never be cached
import babelLoader from 'babel-loader'
module.exports = babelLoader.custom(babel => {
const presetItem = babel.createConfigItem(require('../../babel/preset'), { type: 'preset' })
const configs = new Set()
return {
customOptions (opts) {
const custom = {
isServer: opts.isServer,
dev: opts.dev
}
const loader = Object.assign({
cacheDirectory: true
}, opts)
delete loader.isServer
delete loader.dev