Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
[
require.resolve('babel-plugin-module-resolver'),
{
alias: {
// Projects don't need to install react, react-dom and enzyme
react: compatDirname(
'react/package',
cwd,
dirname(require.resolve('react/package.json')),
),
'react-dom': compatDirname(
'react-dom/package',
cwd,
dirname(require.resolve('react-dom/package.json')),
),
enzyme: compatDirname(
'enzyme/package.json',
cwd,
dirname(require.resolve('enzyme/package.json')),
),
'enzyme-adapter-react-16': compatDirname(
'enzyme-adapter-react-16/package.json',
cwd,
dirname(require.resolve('enzyme-adapter-react-16/package.json')),
),
},
},
'umi-test',
],
],
});
require.resolve('@babel/preset-typescript'),
[
require.resolve('babel-preset-umi'),
{
transformRuntime: false,
// ...(process.env.TARGETS === 'node' ? { targets: { node: 8 } } : {}),
},
],
],
plugins: [
[
require.resolve('babel-plugin-module-resolver'),
{
alias: {
// Projects don't need to install react, react-dom and enzyme
react: compatDirname(
'react/package',
cwd,
dirname(require.resolve('react/package.json')),
),
'react-dom': compatDirname(
'react-dom/package',
cwd,
dirname(require.resolve('react-dom/package.json')),
),
enzyme: compatDirname(
'enzyme/package.json',
cwd,
dirname(require.resolve('enzyme/package.json')),
),
'enzyme-adapter-react-16': compatDirname(
'enzyme-adapter-react-16/package.json',
// ...(process.env.TARGETS === 'node' ? { targets: { node: 8 } } : {}),
},
],
],
plugins: [
[
require.resolve('babel-plugin-module-resolver'),
{
alias: {
// Projects don't need to install react, react-dom and enzyme
react: compatDirname(
'react/package',
cwd,
dirname(require.resolve('react/package.json')),
),
'react-dom': compatDirname(
'react-dom/package',
cwd,
dirname(require.resolve('react-dom/package.json')),
),
enzyme: compatDirname(
'enzyme/package.json',
cwd,
dirname(require.resolve('enzyme/package.json')),
),
'enzyme-adapter-react-16': compatDirname(
'enzyme-adapter-react-16/package.json',
cwd,
dirname(require.resolve('enzyme-adapter-react-16/package.json')),
),
},
},
// ...(process.env.TARGETS === 'node' ? { targets: { node: 8 } } : {}),
},
],
],
plugins: [
[
require.resolve('babel-plugin-module-resolver'),
{
alias: {
// Projects don't need to install react, react-dom and enzyme
react: compatDirname(
'react/package',
cwd,
dirname(require.resolve('react/package.json')),
),
'react-dom': compatDirname(
'react-dom/package',
cwd,
dirname(require.resolve('react-dom/package.json')),
),
enzyme: compatDirname(
'enzyme/package.json',
cwd,
dirname(require.resolve('enzyme/package.json')),
),
'enzyme-adapter-react-16': compatDirname(
'enzyme-adapter-react-16/package.json',
cwd,
dirname(require.resolve('enzyme-adapter-react-16/package.json')),
),
},
},
[
require.resolve('babel-plugin-module-resolver'),
{
alias: {
// Projects don't need to install react, react-dom and enzyme
react: compatDirname(
'react/package',
cwd,
dirname(require.resolve('react/package.json')),
),
'react-dom': compatDirname(
'react-dom/package',
cwd,
dirname(require.resolve('react-dom/package.json')),
),
enzyme: compatDirname(
'enzyme/package.json',
cwd,
dirname(require.resolve('enzyme/package.json')),
),
'enzyme-adapter-react-16': compatDirname(
'enzyme-adapter-react-16/package.json',
cwd,
dirname(require.resolve('enzyme-adapter-react-16/package.json')),
),
},
},
'ddn-test',
],
],
});
require.resolve('@babel/preset-typescript'),
[
require.resolve('babel-preset-umi'),
{
transformRuntime: false,
// ...(process.env.TARGETS === 'node' ? { targets: { node: 8 } } : {}),
},
],
],
plugins: [
[
require.resolve('babel-plugin-module-resolver'),
{
alias: {
// Projects don't need to install react, react-dom and enzyme
react: compatDirname(
'react/package',
cwd,
dirname(require.resolve('react/package.json')),
),
'react-dom': compatDirname(
'react-dom/package',
cwd,
dirname(require.resolve('react-dom/package.json')),
),
enzyme: compatDirname(
'enzyme/package.json',
cwd,
dirname(require.resolve('enzyme/package.json')),
),
'enzyme-adapter-react-16': compatDirname(
'enzyme-adapter-react-16/package.json',
onChange(newConfig) {
try {
debug(`Config ${name} changed to ${JSON.stringify(newConfig[name])}`);
} catch (e) {} // eslint-disable-line no-empty
if (name === 'proxy') {
global.g_umi_reloadProxy(newConfig[name]);
} else {
api.service.restart(`${name} changed`);
}
},
...extraOpts,
});
});
});
const reactDir = compatDirname(
'react/package.json',
cwd,
dirname(require.resolve('react/package.json')),
);
const reactDOMDir = compatDirname(
'react-dom/package.json',
cwd,
dirname(require.resolve('react-dom/package.json')),
);
const reactRouterDir = dirname(require.resolve('react-router/package.json'));
const reactRouterDOMDir = dirname(require.resolve('react-router-dom/package.json'));
const reactRouterConfigDir = dirname(require.resolve('react-router-config/package.json'));
api.chainWebpackConfig(webpackConfig => {
webpackConfig.resolve.alias
.set('react', reactDir)
.set('react-dom', reactDOMDir)
react: compatDirname(
'react/package',
cwd,
dirname(require.resolve('react/package.json')),
),
'react-dom': compatDirname(
'react-dom/package',
cwd,
dirname(require.resolve('react-dom/package.json')),
),
enzyme: compatDirname(
'enzyme/package.json',
cwd,
dirname(require.resolve('enzyme/package.json')),
),
'enzyme-adapter-react-16': compatDirname(
'enzyme-adapter-react-16/package.json',
cwd,
dirname(require.resolve('enzyme-adapter-react-16/package.json')),
),
},
},
'ddn-test',
],
],
});
global.g_umi_reloadProxy(newConfig[name]);
} else {
api.service.restart(`${name} changed`);
}
},
...extraOpts,
});
});
});
const reactDir = compatDirname(
'react/package.json',
cwd,
dirname(require.resolve('react/package.json')),
);
const reactDOMDir = compatDirname(
'react-dom/package.json',
cwd,
dirname(require.resolve('react-dom/package.json')),
);
const reactRouterDir = dirname(require.resolve('react-router/package.json'));
const reactRouterDOMDir = dirname(require.resolve('react-router-dom/package.json'));
const reactRouterConfigDir = dirname(require.resolve('react-router-config/package.json'));
api.chainWebpackConfig(webpackConfig => {
webpackConfig.resolve.alias
.set('react', reactDir)
.set('react-dom', reactDOMDir)
.set('react-router', reactRouterDir)
.set('react-router-dom', reactRouterDOMDir)
.set('react-router-config', reactRouterConfigDir)
.set(
'history',
api.chainWebpackConfig(webpackConfig => {
webpackConfig.resolve.alias
.set('react', reactDir)
.set('react-dom', reactDOMDir)
.set('react-router', reactRouterDir)
.set('react-router-dom', reactRouterDOMDir)
.set('react-router-config', reactRouterConfigDir)
.set(
'history',
compatDirname(
'umi-history/package.json',
cwd,
dirname(require.resolve('umi-history/package.json')),
),
)
.set('@', paths.absSrcPath)
.set('@tmp', paths.absTmpDirPath)
.set('@@', paths.absTmpDirPath)
.set('umi', process.env.UMI_DIR);
});