Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
} else {
return !!filepath.match(dep)
}
})) {
return false
}
// Don't transpile node_modules
return /node_modules/.test(filepath)
})
.end()
.use('cache-loader')
.loader('cache-loader')
.options(api.genCacheConfig('babel-loader', {
'@babel/core': require('@babel/core/package.json').version,
'@nodepack/babel-preset-nodepack': require('@nodepack/babel-preset-nodepack/package.json').version,
'babel-loader': require('babel-loader/package.json').version,
}, [
'babel.config.js',
]))
.end()
if (useThreads) {
jsRule
.use('thread-loader')
.loader('thread-loader')
}
jsRule
.use('babel-loader')
.loader('babel-loader')
.options(babelOptions)
})
}
// check if this is something the user explicitly wants to transpile
if (transpileDepRegex && transpileDepRegex.test(filepath)) {
return false
}
// Don't transpile node_modules
return /node_modules/.test(filepath)
})
.end()
.use('cache-loader')
.loader(require.resolve('cache-loader'))
.options(api.genCacheConfig('babel-loader', {
'@babel/core': require('@babel/core/package.json').version,
'@vue/babel-preset-app': require('@vue/babel-preset-app/package.json').version,
'babel-loader': require('babel-loader/package.json').version,
modern: !!process.env.VUE_CLI_MODERN_BUILD,
browserslist: api.service.pkg.browserslist
}, [
'babel.config.js',
'.browserslistrc'
]))
.end()
if (useThreads) {
const threadLoaderConfig = jsRule
.use('thread-loader')
.loader(require.resolve('thread-loader'))
if (typeof options.parallel === 'number') {
threadLoaderConfig.options({ workers: options.parallel })
}
})
if (shouldTranspile) {
return true
}
}
// Don't include node_modules
return !/node_modules/.test(filepath)
})
.end()
.use('babel-loader')
.loader(require.resolve('../loaders/babel-loader'))
.options({
root: baseDir,
cacheDirectory: true,
cacheIdentifier: composeCacheIdentifiers(
require('babel-loader/package').version,
require('@babel/core/package').version,
process.env.POI_JSX,
process.env.POI_JSX_INFER,
process.env.POI_COMMAND
)
})
config.module
.rule('coffee')
.test(/\.coffee$/)
.pre()
.use('coffee-loader')
.loader('coffee-loader')
}
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.