Skip to content

Commit

Permalink
Polyfill node api in rollup + ext. react-spinners
Browse files Browse the repository at this point in the history
  • Loading branch information
nickgros committed Nov 11, 2020
1 parent 47a1f92 commit 5b3d3c2
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 0 deletions.
5 changes: 5 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,11 @@ instead of:

e.g `import ModalHeader from 'react-bootstrap/ModalHeader`

## Caveat
This may not be true/useful in all situations.

Anecdotally, I was able to cut the package size in half by doing `import { Modal } from 'react-bootstrap'` vs `import { Modal } from 'react-bootstrap/Modal`. Further research is needed to figure out what's happening here.

#### Submitting a new component

1. Create a component in `src/lib/containers`, if it's a large component consider creating a folder with the sub components
Expand Down
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ Note there are a number of CDNs required to finish this functionality-
></script>
```

**react-spinners**
```html
<script src="https://unpkg.com/browse/[email protected]/index.js"></script>
```

**react-measure**

```html
Expand Down
5 changes: 5 additions & 0 deletions rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import json from '@rollup/plugin-json'
import postprocess from 'rollup-plugin-postprocess'
import commonjs from '@rollup/plugin-commonjs'
import minify from 'rollup-plugin-babel-minify'
import nodePolyfills from 'rollup-plugin-node-polyfills';

const extensions = ['.js', '.jsx', '.ts', '.tsx']

Expand All @@ -18,6 +19,7 @@ export default {
'react-router-dom',
'react-measure',
'react-bootstrap',
'react-spinners',
'react-plotly.js/factory',
'plotly.js-basic-dist',
'react-jsonschema-form',
Expand Down Expand Up @@ -68,6 +70,8 @@ export default {
}),
// Common js is used to handle the import of older javascript modules not using es6
commonjs(),
// Some dependencies try to use Node APIs, which we'll polyfill in so the package doesn't crash in-browser
nodePolyfills(),
image(),
// until css modules package is updated we can't opt into css modules
// see issue here - https://github.com/egoist/rollup-plugin-postcss/issues/174
Expand Down Expand Up @@ -101,6 +105,7 @@ export default {
'react-router-dom': 'ReactRouterDom',
'react-transition-group': 'ReactTransitionGroup',
'react-bootstrap': 'ReactBootstrap',
'react-spinners': 'ReactSpinners',
'react-plotly.js/factory': 'createPlotlyComponent',
'rss-parser': 'Parser',
'react-mailchimp-subscribe': 'ReactMailchimpSubscribe',
Expand Down

0 comments on commit 5b3d3c2

Please sign in to comment.