-
-
Notifications
You must be signed in to change notification settings - Fork 500
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* added the possibility to load the eslint config from the plugin instead of the loader since it changed in react-script 4 * first draft of a strategy pattern to support different eslint-loaders * finish implementing the strategy pattern * removed console log and added comment for context * add plugins.js and cleanup * fix a logic error * rename the plugin file to webpack plugins * Instead of parsing react-script version, we look at both place instead * extract the matcher * fix ci * remove the code that supported the eslint-loader * rename the loaderOptions to pluginOptions * cleanup * Since CRACO now only support the latest CRA version, we delete old code that was backward compatible * Craco is no longer backward compatible * remove migration path from release notes * review fixes * rename function * rename variables and function
- Loading branch information
1 parent
161aee8
commit 1e4f912
Showing
12 changed files
with
19,876 additions
and
6,829 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
const { getReactScriptVersion } = require("../lib/cra"); | ||
|
||
function validateCraVersion(cracoConfig) { | ||
const { isSupported, version } = getReactScriptVersion(cracoConfig); | ||
if (!isSupported) { | ||
throw new Error( | ||
`Your current version of react-scripts(${version}) is not supported by this version of CRACO. Please try updating react-scripts to the latest version:\n\n` + | ||
` $ yarn upgrade react-scripts\n\n` + | ||
"Or:\n\n" + | ||
` $ npm update react-scripts\n\n` + | ||
`If that doesn't work or if you can't, refer to the following table to choose the right version of CRACO.\n` + | ||
"https://github.com/gsoft-inc/craco/blob/master/packages/craco/README.md#backward-compatibility" | ||
); | ||
} | ||
} | ||
|
||
module.exports = { | ||
validateCraVersion | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
function pluginByName(targetPluginName) { | ||
return plugin => { | ||
return plugin.constructor.name === targetPluginName; | ||
}; | ||
} | ||
|
||
function getPlugin(webpackConfig, matcher) { | ||
const matchingPlugin = webpackConfig.plugins.find(matcher); | ||
|
||
return { | ||
isFound: matchingPlugin !== undefined, | ||
match: matchingPlugin | ||
}; | ||
} | ||
|
||
function removePlugins(webpackConfig, matcher) { | ||
const prevCount = webpackConfig.plugins.length; | ||
webpackConfig.plugins = webpackConfig.plugins.filter(x => !matcher(x)); | ||
const removedPluginsCount = prevCount - webpackConfig.plugins.length; | ||
|
||
return { | ||
hasRemovedAny: removedPluginsCount > 0, | ||
removedCount: removedPluginsCount | ||
}; | ||
} | ||
|
||
module.exports = { | ||
getPlugin, | ||
pluginByName, | ||
removePlugins | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.