Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const enzyme = require('enzyme');
const Adapter = require('enzyme-adapter-react-16');
const chai = require('chai');
require('@babel/register').default({
plugins: [
'@babel/plugin-transform-modules-commonjs',
'module:babel-plugin-dynamic-import-node',
],
});
require('yaml-hook/register');
enzyme.configure({
adapter: new Adapter(),
});
chai.use(require('chai-enzyme')());
// Mock an asset like Webpack's file-loader.
function mockAsset(modulePath) {
const path = require.resolve(modulePath);
const LodashModuleReplacementPlugin = require('lodash-webpack-plugin');
const ExtractCssPlugin = require('mini-css-extract-plugin');
const HtmlPlugin = require('html-webpack-plugin');
const HtmlSiblingChunksPlugin = require('html-webpack-include-sibling-chunks-plugin');
const CopyPlugin = require('copy-webpack-plugin');
const { Plugin: ShakePlugin } = require('webpack-common-shake');
const merge = require('webpack-merge');
const htmlMinifierOptions = require('./tasks/utils/htmlMinifierOptions');
const nodeEnv = process.env.NODE_ENV || 'development';
const isDemo = process.env.DEMO === '1';
const outputPackage = isDemo ? __dirname : path.join(__dirname, 'packages/u-wave-web-middleware');
// Compile src/ on the fly so we can use components etc. during build time.
require('@babel/register').default({
only: [
new RegExp(escapeStringRegExp(path.join(__dirname, 'src'))),
new RegExp(escapeStringRegExp(path.join(__dirname, 'tasks/webpack'))),
],
plugins: [
['@babel/plugin-transform-modules-commonjs', { lazy: true }],
],
});
// Most webpack configuration is in this file. A few things are split up to make the
// core stuff easier to grasp.
//
// Other parts of the build are in the ./tasks/webpack/ folder:
// - compileDependencies: Compiles dependencies that only ship ES2015+ to code that
// works in all our browser targets.
const compileDependencies = require('./tasks/webpack/compileDependencies').default;