Skip to content

Commit 98b861b

Browse files
committed
Change warning to a hard error
1 parent 0f27bdc commit 98b861b

File tree

3 files changed

+15
-16
lines changed

3 files changed

+15
-16
lines changed

packages/react-dev-utils/WarnAboutLoaderDisablingPlugin.js renamed to packages/react-dev-utils/BlockUnsupportedWebpackLoaderSyntax.js

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -7,26 +7,25 @@
77
* of patent rights can be found in the PATENTS file in the same directory.
88
*/
99

10-
// This Webpack plugin warns the user when using special webpack syntax
10+
// This Webpack plugin forbids usage of special webpack syntax
1111
// to disable loaders (https://webpack.github.io/docs/loaders.html#loader-order)
1212
// This makes it very coupled to webpack and might break in the future.
1313
// See https://github.com/facebookincubator/create-react-app/issues/733.
1414

1515
'use strict';
1616

17-
var chalk = require('chalk');
18-
19-
class WarnAboutLoaderDisablingPlugin {
17+
class BlockUnsupportedWebpackLoaderSyntax {
2018
apply(compiler) {
2119
compiler.plugin('normal-module-factory', (normalModuleFactory) => {
2220
normalModuleFactory.plugin('before-resolve', (data, callback) => {
21+
let error = null;
2322
if (data.request.match(/^-?!!?/)) {
24-
chalk.yellow(`Warning: You are requesting '${data.request}'. Special Webpack Loaders syntax is not officially supported and makes you code very coupled to Webpack, which might break in the future, we recommend that you remove it. See `https://github.com/facebookincubator/create-react-app/issues/733`);
23+
error = `You are requesting '${data.request}'. Special Webpack Loaders syntax is not officially supported and makes you code very coupled to Webpack, which might break in the future, we recommend that you remove it. See https://github.com/facebookincubator/create-react-app/issues/733`;
2524
}
26-
callback(null, data);
27-
})
25+
callback(error, data);
26+
});
2827
});
2928
}
3029
}
3130

32-
module.exports = WarnAboutLoaderDisablingPlugin;
31+
module.exports = BlockUnsupportedWebpackLoaderSyntax;

packages/react-dev-utils/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ module.exports = {
8181
}
8282
```
8383

84-
#### `new WarnAboutDisablingPlugin()`
84+
#### `new BlockUnsupportedWebpackLoaderSyntax()`
8585

8686
This Webpack plugin warns the user when using special webpack syntax for
8787
disabling loaders (like `!!file!./stuff`). This makes it very coupled
@@ -90,17 +90,17 @@ See [#733](https://github.com/facebookincubator/create-react-app/issues/733) for
9090

9191
```js
9292
var path = require('path');
93-
var WarnAboutLoaderDisablingPlugin = require('react-dev-utils/WarnAboutLoaderDisablingPlugin);
93+
var BlockUnsupportedWebpackLoaderSyntax = require('react-dev-utils/BlockUnsupportedWebpackLoaderSyntax');
9494

9595
// Webpack config
9696
module.exports = {
9797
// ...
9898
plugins: [
9999
// ...
100-
// This warns about using Webpack Special Loader syntax, which makes it
100+
// This forbids usage of Webpack Special Loader syntax, which makes it
101101
// very coupled to Webpack and might break in the future.
102102
// See https://github.com/facebookincubator/create-react-app/issues/733
103-
new WarnAboutLoaderDisablingPlugin()
103+
new BlockUnsupportedWebpackLoaderSyntax()
104104
],
105105
// ...
106106
}

packages/react-scripts/config/webpack.config.dev.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ var HtmlWebpackPlugin = require('html-webpack-plugin');
1717
var CaseSensitivePathsPlugin = require('case-sensitive-paths-webpack-plugin');
1818
var InterpolateHtmlPlugin = require('react-dev-utils/InterpolateHtmlPlugin');
1919
var WatchMissingNodeModulesPlugin = require('react-dev-utils/WatchMissingNodeModulesPlugin');
20-
var WarnAboutLoaderDisablingPlugin = require('react-dev-utils/WarnAboutLoaderDisablingPlugin');
20+
var BlockUnsupportedWebpackLoaderSyntax = require('react-dev-utils/BlockUnsupportedWebpackLoaderSyntax');
2121
var getClientEnvironment = require('./env');
2222
var paths = require('./paths');
2323

@@ -217,11 +217,11 @@ module.exports = {
217217
// to restart the development server for Webpack to discover it. This plugin
218218
// makes the discovery automatic so you don't have to restart.
219219
// See https://github.com/facebookincubator/create-react-app/issues/186
220-
new WatchMissingNodeModulesPlugin(paths.appNodeModules)
221-
// This warns about using Webpack Special Loader syntax, which makes it
220+
new WatchMissingNodeModulesPlugin(paths.appNodeModules),
221+
// This forbids usage of Webpack Special Loader syntax, which makes it
222222
// very coupled to Webpack and might break in the future.
223223
// See https://github.com/facebookincubator/create-react-app/issues/733
224-
new WarnAboutLoaderDisablingPlugin()
224+
new BlockUnsupportedWebpackLoaderSyntax()
225225
],
226226
// Some libraries import Node modules but don't use them in the browser.
227227
// Tell Webpack to provide empty mocks for them so importing them works.

0 commit comments

Comments
 (0)