Skip to content

Commit 6d3b5ed

Browse files
committed
fix($bump): edit readme and start using semantic-release
1 parent fd53365 commit 6d3b5ed

File tree

4 files changed

+63
-28
lines changed

4 files changed

+63
-28
lines changed

.travis.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ notifications:
44
email: false
55
node_js:
66
- stable
7-
#script:
8-
#- node_modules/.bin/travis-github-status lint flow jest
7+
script:
8+
- node_modules/.bin/travis-github-status lint flow jest codeclimate
99
after_success:
1010
- yarn run semantic-release
1111
branches:

README.md

Lines changed: 46 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,37 @@
1+
<p align="center">
2+
<a href="https://www.npmjs.com/package/webpack-flush-chunks">
3+
<img src="https://img.shields.io/npm/v/webpack-flush-chunks.svg" alt="Version" />
4+
</a>
5+
6+
<a href="https://travis-ci.org/faceyspacey/webpack-flush-chunks">
7+
<img src="https://travis-ci.org/faceyspacey/webpack-flush-chunks.svg?branch=master" alt="Build Status" />
8+
</a>
9+
10+
<a href="https://lima.codeclimate.com/github/faceyspacey/webpack-flush-chunks/coverage">
11+
<img src="https://lima.codeclimate.com/github/faceyspacey/webpack-flush-chunks/badges/coverage.svg" alt="Coverage Status"/>
12+
</a>
13+
14+
<a href="https://greenkeeper.io">
15+
<img src="https://badges.greenkeeper.io/faceyspacey/webpack-flush-chunks.svg" alt="Green Keeper" />
16+
</a>
17+
18+
<a href="https://lima.codeclimate.com/github/faceyspacey/webpack-flush-chunks">
19+
<img src="https://lima.codeclimate.com/github/faceyspacey/webpack-flush-chunks/badges/gpa.svg" alt="GPA" />
20+
</a>
21+
22+
<a href="https://www.npmjs.com/package/webpack-flush-chunks">
23+
<img src="https://img.shields.io/npm/dt/webpack-flush-chunks.svg" alt="Downloads" />
24+
</a>
25+
26+
<a href="https://www.npmjs.com/package/webpack-flush-chunks">
27+
<img src="https://img.shields.io/npm/l/webpack-flush-chunks.svg" alt="License" />
28+
</a>
29+
30+
<a href="https://gitter.im/webpack-flush-chunks">
31+
<img src="https://img.shields.io/gitter/room/nwjs/nw.js.svg" alt="Gitter Chat" />
32+
</a>
33+
</p>
34+
135
# webpack-flush-chunks
236
`flushChunks` is the equivalent of `renderToString` or `renderToStaticMarkup` when it comes to code-splitting. It's to be used in
337
server-rendering to extract the minimal amount of chunks to send to the client, thereby solving a missing piece for code-splitting:
@@ -31,14 +65,15 @@ don't want to just send all the chunks down to the client for that initial reque
3165
if your strategy is the former, *checksums* won't match and an additional unnecessary render will happen on the client.
3266

3367
As a result, the goal becomes to get to the client precisely those chunks used in the first render, no more, no less. `flushChunks` does exactly
34-
this, providing strings you can embed in your response:
68+
this, providing strings containing those scripts and stylesheets you can embed in your response:
3569

3670
```javascript
3771
const app = ReactDOM.renderToString(<App />)
38-
const { js, styles } = flushChunks(stats)
72+
const moduleIds = ReactLoadable.flushRequires()
73+
const { js, styles } = flushChunks(moduleIds, stats)
3974
```
4075

41-
If you can provide these chunks to the client, *React Lodable* will perform the first render synchcronously just like the server.
76+
If you can provide these chunks to the client, *React Lodable* (or comparable) will perform the first render synchcronously just like the server.
4277

4378
## How It Works
4479
*React Loadable*, when used on the server, skips the *loading* phase and syncronously renders your contained component, while recording the ID of
@@ -224,8 +259,7 @@ export default function render(stats) {
224259
}
225260
```
226261

227-
Here the React Components `<JS />` and `<Styles />` are returned from `flushChunks` for use in composing the final component tree passed to `renderToStaticMarkup`.
228-
Notice the components are in the `<body>`--this is because until *React 16* container `spans` are needed, and if used in the `<head>` will produce warnings.
262+
> Here the React Components `<JS />` and `<Styles />` are returned from `flushChunks` for use in composing the final component tree passed to `renderToStaticMarkup`. Notice the components are in the `<body>`--this is because until *React 16* container `spans` are needed, and if used in the `<head>` will produce warnings.
229263
230264
This is just one option though. There are several other things **returned** from `flushChunks`, which fulfill most other common needs:
231265

@@ -305,7 +339,7 @@ const html = ReactDOM.renderToStaticMarkup(
305339
```
306340
> **note:** the `publicPath` is also returned, for convenience
307341
308-
Though you will have no need to manually create your stylesheets and scripts, here you can see what data you have available to you in case you need to perform some other logic
342+
Though generally you will have no need to manually create your stylesheets and scripts, here you can see what data you have available to you in case you need to perform some other logic
309343
on the array of scripts/sheets returned to you.
310344

311345

@@ -353,15 +387,16 @@ plugins: [
353387

354388
The key elements above are first the `namedModulesPlugin` which insures the module IDs generated for your
355389
client bundle are the same for your server bundle (aka "deterministic"). Secondly, the `CommonsChunkPlugin` with
356-
`"bootstrap"` entry which doesn't exist insures that a separate chunk is created just for webpack bootstrap code.
390+
`"bootstrap"` entry *which doesn't exist* insures that a separate chunk is created just for webpack bootstrap code.
357391
This moves the webpack bootstrap code out of your `main` entry chunk so that it can also run before your dynamic
358392
chunks. Lastly, the `ExtractCssChunks` plugin in combination with its loader insures CSS also gets multiple
359393
CSS files created. If you're familiar with how `extract-text-webpack-plugin` works, you will be right at home.
360394

361395

362396
Check out [faceyspacey/extract-css-chunks-webpack-plugin](https://github.com/faceyspacey/extract-css-chunks-webpack-plugin)
363397
to learn more--it has some advanced features including HMR, and the ability to generate javascript chunks that don't
364-
contain CSS injection plus simultaneously chunks that do for future asynchronous loading of chunks.
398+
contain CSS injection plus simultaneously chunks that do for future asynchronous loading of chunks. I.e. 2 versions
399+
of each javascript chunk.
365400

366401
### Server Development
367402
```javascript
@@ -538,7 +573,7 @@ compiler.plugin('done', stats => {
538573
})
539574
```
540575
> **note:** a callback can be passed to `webpack(config, stats => ...)`, but it does not provide the complete set
541-
of stats as the `done` plugin callback does. Do NOT use it!*
576+
of stats as the `done` plugin callback does. Do NOT use it!
542577

543578
In this case `serverRender` is a function you call once with the stats that returns a function that
544579
can be used by express on every request:
@@ -581,8 +616,8 @@ its forked from (`extract-text-webpack-plugin`) does not provide, not even for a
581616
582617
In terms of server-rendering, it achieves a lot of the same things that solutions like *Aphrodite*
583618
and *StyleTron* achieve where you extract the rendered CSS, *except its JS bundles are a lot smaller since CSS is completely moved to CSS files;* **and it
584-
doesn't add to your runtime/render-overhead by performing work during render;** ***and it doesn't require cluttering your code with HoCs or specialized components.***
619+
doesn't add to your runtime/render-overhead by performing work during render;** ***and it doesn't require cluttering your code with HoCs or specialized components; you can import a styles object just like you can with React Native (therefore you can use the same components for React as RN)***
585620
*The list goes on...* We
586-
think we may have stumbled upon a solution that completes the intent of CSS Modules and value you can derive from it similar to how *Webpack Flush Chunks* completes the thought of code-splitting for *React Loadable*. It certainly produces the most minimal set of bytes corresponding to CSS
621+
think we may have stumbled upon a solution that completes the intent of CSS Modules and the value you can derive from it, similar to how *Webpack Flush Chunks* completes the thought of code-splitting for *React Loadable*. It certainly produces the most minimal set of bytes corresponding to CSS
587622
you'll send over the wire in initial requests. You be the judge of that. We look forward to hearing your
588623
opinion.

package.json

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "webpack-flush-chunks",
3+
"version": "0.0.0-placeholder",
34
"description": "flush webpack chunks for SSR from React Loadable or similar packages",
45
"main": "dist/flushChunks.js",
56
"author": "James Gillmore <[email protected]>",
@@ -11,7 +12,7 @@
1112
"prepublish": "yarn build",
1213
"format": "prettier --single-quote --parser=flow --semi=false --write '{src,__tests__}/**/*.js'",
1314
"test": "jest",
14-
"lint": "eslint src __tests__ __fixtures__",
15+
"lint": "eslint --fix src __tests__ __fixtures__",
1516
"build": "babel src -d dist"
1617
},
1718
"dependencies": {},
@@ -34,11 +35,11 @@
3435
"flow-bin": "^0.44.2",
3536
"husky": "^0.13.2",
3637
"jest": "^19.0.2",
37-
"lint-staged": "^3.3.1",
38+
"lint-staged": "^3.4.0",
3839
"prettier": "^1.2.2",
3940
"react": "^15.5.4",
4041
"semantic-release": "^6.3.2",
41-
"travis-github-status": "^1.3.0"
42+
"travis-github-status": "^1.4.0"
4243
},
4344
"peerDependencies": {
4445
"react": "*"

yarn.lock

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2248,7 +2248,7 @@ github@^0.2.4:
22482248
dependencies:
22492249
mime "^1.2.11"
22502250

2251-
github@^9.1.0:
2251+
github@^9.2.0:
22522252
version "9.2.0"
22532253
resolved "https://registry.yarnpkg.com/github/-/github-9.2.0.tgz#8a886dc40dd63636707dcaf99df3df26c59f16fc"
22542254
dependencies:
@@ -3205,9 +3205,9 @@ levn@^0.3.0, levn@~0.3.0:
32053205
prelude-ls "~1.1.2"
32063206
type-check "~0.3.2"
32073207

3208-
lint-staged@^3.3.1:
3209-
version "3.3.1"
3210-
resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-3.3.1.tgz#b725d98a2be1f82cb228069fab682f503c95234d"
3208+
lint-staged@^3.4.0:
3209+
version "3.4.0"
3210+
resolved "https://registry.yarnpkg.com/lint-staged/-/lint-staged-3.4.0.tgz#52fa85dfc92bb1c6fe8ad0d0d98ca13924e03e4b"
32113211
dependencies:
32123212
app-root-path "^2.0.0"
32133213
cosmiconfig "^1.1.0"
@@ -3216,7 +3216,6 @@ lint-staged@^3.3.1:
32163216
minimatch "^3.0.0"
32173217
npm-which "^3.0.1"
32183218
staged-git-files "0.0.4"
3219-
which "^1.2.11"
32203219

32213220
listr-silent-renderer@^1.1.1:
32223221
version "1.1.1"
@@ -4636,7 +4635,7 @@ snyk-try-require@^1.1.1, snyk-try-require@^1.2.0:
46364635
lru-cache "^4.0.0"
46374636
then-fs "^2.0.0"
46384637

4639-
snyk@^1.25.2:
4638+
snyk@^1.29.0:
46404639
version "1.29.0"
46414640
resolved "https://registry.yarnpkg.com/snyk/-/snyk-1.29.0.tgz#20be4eaddc9641ca004fb24368dc33d6f82d17dc"
46424641
dependencies:
@@ -4956,14 +4955,14 @@ [email protected]:
49564955
request-promise "^4.1.1"
49574956
travis-ci "^2.1.1"
49584957

4959-
travis-github-status@^1.3.0:
4960-
version "1.3.0"
4961-
resolved "https://registry.yarnpkg.com/travis-github-status/-/travis-github-status-1.3.0.tgz#b903034c1ac2f35d4b229ae66a41e5d7765ff46f"
4958+
travis-github-status@^1.4.0:
4959+
version "1.4.0"
4960+
resolved "https://registry.yarnpkg.com/travis-github-status/-/travis-github-status-1.4.0.tgz#4282e9edfc3eec81eee6c285568f30e23b89e12e"
49624961
dependencies:
49634962
codeclimate-test-reporter "^0.4.1"
49644963
colors "^1.1.2"
4965-
github "^9.1.0"
4966-
snyk "^1.25.2"
4964+
github "^9.2.0"
4965+
snyk "^1.29.0"
49674966

49684967
trim-newlines@^1.0.0:
49694968
version "1.0.0"
@@ -5159,7 +5158,7 @@ which-module@^1.0.0:
51595158
version "1.0.0"
51605159
resolved "https://registry.yarnpkg.com/which-module/-/which-module-1.0.0.tgz#bba63ca861948994ff307736089e3b96026c2a4f"
51615160

5162-
which@^1.1.1, which@^1.2.10, which@^1.2.11, which@^1.2.12, which@^1.2.9:
5161+
which@^1.1.1, which@^1.2.10, which@^1.2.12, which@^1.2.9:
51635162
version "1.2.12"
51645163
resolved "https://registry.yarnpkg.com/which/-/which-1.2.12.tgz#de67b5e450269f194909ef23ece4ebe416fa1192"
51655164
dependencies:

0 commit comments

Comments
 (0)