Skip to content

Commit 4c7d1ca

Browse files
committed
feat($chunkNames): ability to pass an array of chunkNames instead of moduleIds + tests
1 parent e590571 commit 4c7d1ca

File tree

10 files changed

+532
-157
lines changed

10 files changed

+532
-157
lines changed

.npmignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,4 @@ webpack.config.js
1212
__tests__
1313
coverage
1414
src
15+
*.png

README.md

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,4 +647,13 @@ If what you want is full-on compilation `chunk` objects (and any information it
647647
648648
649649
## Contributing
650-
We use [commitizen](https://github.com/commitizen/cz-cli), so run `npm run commit` to make commits. A command-line form will appear, requiring you answer a few questions to automatically produce a nicely formatted commit. Releases, semantic version numbers, tags and changelogs will automatically be generated based on these commits thanks to [semantic-release](https://github.com/semantic-release/semantic-release). Be good.
650+
We use [commitizen](https://github.com/commitizen/cz-cli), so run `npm run cm` to make commits. A command-line form will appear, requiring you answer a few questions to automatically produce a nicely formatted commit. Releases, semantic version numbers, tags and changelogs will automatically be generated based on these commits thanks to [semantic-release](https://github.com/semantic-release/semantic-release). Be good.
651+
652+
653+
## Tests
654+
655+
Reviewing a module's tests are a great way to get familiar with it. It's direct insight into the capabilities of the given module (if the tests are thorough). What's even better is a screenshot of the tests neatly organized and grouped (you know the whole "a picture says a thousand words" thing).
656+
657+
Below is a screenshot of this module's tests running in [Wallaby](https://wallabyjs.com) *("An Integrated Continuous Testing Tool for JavaScript")* which everyone in the React community should be using. It's fantastic and has taken my entire workflow to the next level. It re-runs your tests on every change along with comprehensive logging, bi-directional linking to your IDE, in-line code coverage indicators, **and even snapshot comparisons + updates for Jest!** I requestsed that feature by the way :). It's basically a substitute for live-coding that inspires you to test along your journey.
658+
659+
![require-universal-module wallaby tests screenshot](./tests-screenshot.png)

__fixtures__/stats.js

Lines changed: 45 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,50 @@
1+
const chunk1Files = [
2+
'0.js',
3+
'0.no_css.js',
4+
'0.css',
5+
'0.js.map',
6+
'0.no_css.js.map',
7+
'0.css.map'
8+
]
9+
const chunk2Files = [
10+
'1.js',
11+
'1.no_css.js',
12+
'1.css',
13+
'1.js.map',
14+
'1.no_css.js.map',
15+
'1.css.map'
16+
]
17+
const chunk3Files = [
18+
'2.js',
19+
'2.no_css.js',
20+
'2.css',
21+
'2.js.map',
22+
'2.no_css.js.map',
23+
'2.css.map'
24+
]
25+
126
export const stats = {
227
assetsByChunkName: {
328
bootstrap: ['bootstrap.js', 'bootstrap.no_css.js'],
429
vendor: ['vendor.js', 'vendor.no_css.js'],
5-
main: ['main.js', 'main.no_css.js', 'main.css']
30+
main: ['main.js', 'main.no_css.js', 'main.css'],
31+
chunk1: chunk1Files,
32+
chunk2: chunk2Files
633
},
734
chunks: [
835
{
936
id: 0,
10-
files: ['0.js', '0.no_css.js', '0.css']
37+
files: chunk1Files
1138
},
1239
{
1340
id: 1,
14-
files: ['1.js', '1.no_css.js', '1.css']
41+
files: chunk2Files
42+
},
43+
{
44+
id: 2,
45+
files: chunk3Files
1546
}
16-
// chunk with id: 2 intentionally missing to test against invalid stats
47+
// chunk with id: 3 intentionally missing to test against invalid stats
1748
],
1849
modules: [
1950
{
@@ -30,6 +61,11 @@ export const stats = {
3061
id: 'zxcv',
3162
name: './src/Components/Bar.js',
3263
chunks: [2]
64+
},
65+
{
66+
id: 'fgij',
67+
name: './src/Components/Baz.js',
68+
chunks: [3]
3369
}
3470
],
3571
publicPath: '/static/'
@@ -38,9 +74,12 @@ export const stats = {
3874
export const babelFilePaths = [
3975
'./src/Components/Example.js',
4076
'./src/Components/Foo.js',
41-
'./src/Components/Bar.js'
77+
'./src/Components/Bar.js',
78+
'./src/Components/Baz.js'
4279
]
4380

44-
export const webpackModuleIds = ['qwer', 'asdf', 'zxcv']
81+
export const webpackModuleIds = ['qwer', 'asdf', 'zxcv', 'fgij']
4582

4683
export const rootDir = '/Users/jamesgillmore/App'
84+
85+
export const chunkNames = ['chunk1', 'chunk2']

__tests__/__snapshots__/createApiWithCss.test.js.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ Array [
116116
]
117117
`;
118118

119-
exports[`stylesAsString() 1`] = `
119+
exports[`unit tests stylesAsString() 1`] = `
120120
"/Users/jamesgillmore/App/build/main.css- the css!
121121
122122
/Users/jamesgillmore/App/build/0.css- the css!

0 commit comments

Comments
 (0)