-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
bundle5.ts
38 lines (32 loc) · 1022 Bytes
/
bundle5.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
import { logger, stripIndents } from '@nrwl/devkit';
import chalk = require('chalk');
import { requireShim } from './require-shim';
import packageJson = require('../../package.json');
function validateVersion(path) {
if (
packageJson.dependencies[path] ===
requireShim(`${path}/package.json`).version
) {
logger.warn(`Found an outdated version of ${chalk.bold(path)}\n`);
logger.info(stripIndents`
If you want to use webpack 5, try installing compatible versions of the plugins.
See: https://nx.dev/guides/webpack-5
`);
throw new Error('Incompatible version');
}
}
module.exports = function (onFallback) {
try {
validateVersion('@pmmmwh/react-refresh-webpack-plugin');
} catch {
logger.info(
`NX Falling back to webpack 4 due to incompatible plugin versions`
);
onFallback();
return require('./bundle4')();
}
return {
ReactRefreshPlugin: requireShim('@pmmmwh/react-refresh-webpack-plugin'),
webpack: requireShim('webpack'),
};
};