You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Aug 8, 2023. It is now read-only.
`create-react-styleguide@8` introduced breaking changes around the build processes and config files.
4
+
5
+
## Package config
6
+
7
+
You will need to modify output file pointers and dependencies.
8
+
9
+
## Output files
10
+
11
+
The new build process uses Rollup and creates 4 bundles, dev and prod for ESM and CJS. An application, which imports your package, will select a correct bundle, based on node environment and bundler capabilities. In example, ESM for Vite or CJS for Webpack 4.
12
+
13
+
Modify your `package.json` to use the following:
14
+
15
+
```json
16
+
{
17
+
"main": "dist/cjs/index.js",
18
+
"module": "dist/es/index.js",
19
+
"exports": {
20
+
".": {
21
+
"import": "./dist/es/index.js",
22
+
"require": "./dist/cjs/index.js"
23
+
}
24
+
}
25
+
}
26
+
```
27
+
28
+
### Dependencies
29
+
30
+
All `babel`, `eslint`, and `jest` packages are now required by CRS and not needed as dependencies in your project. Also, all peer dependencies became regular dependencies. Rollup build will exclude them from the final bundle, but they will still be available in `node_modules` as transient dependencies. Please be mindful that a project, which uses your library, can overwrite the dependencies, in example `react` or `lodash` version.
31
+
32
+
Your project package dependencies should look like this:
33
+
34
+
```json
35
+
{
36
+
"dependencies": {
37
+
"prop-types": "x.y.z",
38
+
"react": "x.y.z",
39
+
"react-dom": "x.y.z",
40
+
"styled-components": "x.y.z",
41
+
"// other-prod-packages": "x.y.z"
42
+
},
43
+
"devDependencies": {
44
+
"create-react-styleguide": "x.y.z",
45
+
"husky": "x.y.z",
46
+
"react-test-renderer": "x.y.z",
47
+
"// other-dev-packages": "x.y.z"
48
+
}
49
+
}
50
+
```
51
+
52
+
## NEW Rollup config
53
+
54
+
Add `rollup.config.js` to the root of your project with the snippet from `./templates/base/rollup.config.js`.
55
+
56
+
Feel free to customize it to your liking. In example:
Previously, `prop-types` import and object would remain in the output bundle. In 8x we try our best to remove them in production mode. However, in some components, the import and prop types object persist. In those cases you can annotate a component and force a removal. [See here](https://github.com/oliviertassinari/babel-plugin-transform-react-remove-prop-types#with-comment-annotation) for more information.
Copy file name to clipboardExpand all lines: README.md
+86-48Lines changed: 86 additions & 48 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -29,22 +29,22 @@ You can see all options for project generation with the following command:
29
29
npx create-react-styleguide --help
30
30
```
31
31
32
-
####`--stable`
32
+
### `--stable`
33
33
34
34
By default, the project will be built with the latest caret (^) version of all dependencies. If this configuration fails, use the `--stable` flag to generate with a known working configuration.
35
35
36
36
```
37
37
npx create-react-styleguide new my-new-styleguide --stable
38
38
```
39
39
40
-
## npm scripts
40
+
## NPM Scripts
41
41
42
42
Generated projects include the following npm scripts out of the box:
| npm start | Start the styleguide server on http://localhost:6060|
47
-
| npm run build | Build the component library to the `lib` folder|
47
+
| npm run build | Build the component library to the `dist` folder |
48
48
| npm run build:styleguide| Build the styleguide to the `styleguide` folder |
49
49
| npm run build:watch| Watch the `src` folder for changes and run the build script |
50
50
| npm run clean | Clean generated folders |
@@ -55,36 +55,95 @@ Generated projects include the following npm scripts out of the box:
55
55
| npm run test:update| Update unit test snapshots |
56
56
| npm run test:watch| Run unit tests while watching for changes |
57
57
58
-
## Document your styleguide
58
+
## Document Styleguide
59
59
60
60
By default, we expose some meta data from your `package.json` file at the top of your styleguide -- at the very least, make sure you set the `"version"`, `"homepage"`, and `"author"` properties. You can further document your library with markdown files using the [`sections`](https://react-styleguidist.js.org/docs/configuration.html#sections-1) configuration from [React Styleguidist](https://react-styleguidist.js.org/). By convention, additional markdown documentation should go in the `docs` folder so that they get properly packaged when [linking multiple styleguides](#linking-multiple-styleguides).
61
61
62
62

63
63
64
-
## Adding SVG support
64
+
## Modify Rollup Config
65
65
66
-
You can add SVG support with the [inline-react-svg](https://github.com/airbnb/babel-plugin-inline-react-svg) babel plugin. `npm i --save-dev babel-plugin-inline-react-svg` and then update your `babel.config.js`file as follows:
66
+
You can customize Rollup configuration to your requirements. In example, you can update `rollup.config.js`with a sample plugin and a banner for each output file.
You can customize Babel configuration to your requirements. In example, you can add SVG support with the [inline-react-svg](https://github.com/airbnb/babel-plugin-inline-react-svg) babel plugin. `npm i --save-dev babel-plugin-inline-react-svg` and then update `babel.config.js` file as follows:
A useful feature of create-react-styleguide is the ability to link multiple CRS component libraries into a single project. This means that separate teams can manage and own their own individual CRS libraries, and then bring them all together into a master project for broader visibility.
Creates a [React Styleguidist configuration object](https://react-styleguidist.js.org/docs/configuration.html) with some default configuration.
137
+
138
+
-`config [object]` - A configuration object to be shallowly merged with the rest of the configuration
139
+
-`options.styleguides [array]` - An array of CRS npm modules (the module must be installed as a dependency to your project)
140
+
-`options.packageSection [boolean]` - Include `package.json` details as a top level section (default: `true`)
141
+
-`options.packageSectionComponents [boolean]` - Include `components` configuration in the top-level package section (default: `false`)
142
+
-`options.componentsSection [boolean]` - Include `components` configuration as its own separate section (default: `true`)
143
+
144
+
## Linking Styleguides
145
+
146
+
A useful feature of `create-react-styleguide` is the ability to link multiple CRS component libraries into a single project. This means that separate teams can manage and own their own individual CRS libraries, and then bring them all together into a master project for broader visibility.
88
147
89
148
For a styleguide to be linked, it must first be published to npm. Running `npm publish` will build and publish your component library so that it can be consumed by the master project.
90
149
@@ -107,7 +166,7 @@ That's it! Running `npm start` will now show components from all linked librarie
107
166
108
167

109
168
110
-
## Deploying your styleguide to GitHub Pages
169
+
## Deploying Styleguide to GitHub Pages
111
170
112
171
Install the `gh-pages` module:
113
172
@@ -126,36 +185,11 @@ Add the following scripts to your `package.json`:
126
185
127
186
Running `npm run deploy` will now deploy your styleguide to Github Pages!
Creates a [React Styleguidist configuration object](https://react-styleguidist.js.org/docs/configuration.html) with some default configuration.
140
-
141
-
-`config [object]` - A configuration object to be shallowly merged with the rest of the configuration
142
-
-`options.styleguides [array]` - An array of CRS npm modules (the module must be installed as a dependency to your project)
143
-
-`options.packageSection [boolean]` - Include `package.json` details as a top level section (default: `true`)
144
-
-`options.packageSectionComponents [boolean]` - Include `components` configuration in the top-level package section (default: `false`)
145
-
-`options.componentsSection [boolean]` - Include `components` configuration as its own separate section (default: `true`)
146
-
-`options.ie11Transforms [array]` - An array of additional modules that need babel transforms for IE11 compatibility ([#1327](https://github.com/styleguidist/react-styleguidist/pull/1327))
147
-
148
-
### `createJestConfig(config)`
149
-
150
-
Creates a [Jest configuration object](https://jestjs.io/docs/en/configuration) with some default configuration.
151
-
152
-
-`config [object]` - A configuration object to be shallowly merged with the rest of the configuration
153
-
154
188
## Environment Variables
155
189
156
190
### `DEBUG`
157
191
158
-
Both `createStyleguideConfig` and `createJestConfig` will log their results to the console when the `DEBUG` environment variable is set to any non-empty value (such as `true` or `1`). A quick way to see the configuration these functions are creating is to run the following:
192
+
All config files will log their results to the console when the `DEBUG` environment variable is set to any non-empty value (such as `true` or `1`). A quick way to see the configuration these functions are creating is to run the following:
159
193
160
194
```
161
195
DEBUG=true node styleguide.config.js
@@ -179,4 +213,8 @@ PORT=12345 npm start
179
213
180
214
`create-react-styleguide` leverages [react-styleguidist](https://react-styleguidist.js.org/) under the covers for its living style guide.
181
215
182
-
Builds are created by simple running the `src` directory through [Babel](https://babeljs.io/) using whatever configuration is in your `.babelrc` file. The build will run twice, once with the default configuration which builds ES modules compatible with tree shaking, and once with the `"cjs"` env configuration which builds CommonJS modules.
216
+
Builds are created by running the `src` directory through [Rollup](https://rollupjs.org/) and [Babel](https://babeljs.io/). The build will create 4 bundles, dev and prod for CJS and ESM formats. An application, which imports your package, will select a correct bundle, based on node environment and bundler capabilities. In example, ESM for Vite or CJS for Webpack 4.
217
+
218
+
## Migration Guide from 7x to 8x
219
+
220
+
Please read our [migration guide](./MIGRATE-7-to-8.md) to streamline your update efforts.
0 commit comments