-
-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: Remove webpack from peerDependencies
Check webpack availability and version at run time instead of using peerDependencies to allow usage of build tools that contains webpack as their own dependency, like Create React App. See discussion here: facebook/create-react-app#2044
- Loading branch information
Showing
8 changed files
with
123 additions
and
76 deletions.
There are no files selected for viewing
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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
'use strict'; | ||
|
||
/** | ||
* Check webpack availability and version at run time instead of using peerDependencies to allow | ||
* usage of build tools that contains webpack as their own dependency, like Create React App. | ||
*/ | ||
|
||
const logger = require('glogg')('rsg'); | ||
const getWebpackVersion = require('./getWebpackVersion'); | ||
const StyleguidistError = require('./error'); | ||
const consts = require('../consts'); | ||
|
||
const MIN_WEBPACK_VERSION = 1; | ||
const webpackVersion = getWebpackVersion(); | ||
|
||
if (!webpackVersion) { | ||
throw new StyleguidistError( | ||
'Webpack is required for Styleguidist, please add it to your project:\n\n' + | ||
' npm install --save-dev webpack\n\n' + | ||
'See how to configure it for your style guide:\n' + | ||
consts.DOCS_WEBPACK | ||
); | ||
} else if (webpackVersion < MIN_WEBPACK_VERSION) { | ||
throw new StyleguidistError( | ||
`Webpack ${webpackVersion} is not supported by Styleguidist, the minimum version is ${MIN_WEBPACK_VERSION}` | ||
); | ||
} else if (webpackVersion < 2) { | ||
logger.warn('Support for webpack 1 will be removed in the next major version of Styleguidist'); | ||
} |
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