Skip to content

Commit

Permalink
feat($chunkNames): ability to pass an array of chunkNames instead of …
Browse files Browse the repository at this point in the history
…moduleIds + tests
  • Loading branch information
faceyspacey committed Jun 7, 2017
1 parent e590571 commit 4c7d1ca
Show file tree
Hide file tree
Showing 10 changed files with 532 additions and 157 deletions.
1 change: 1 addition & 0 deletions .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ webpack.config.js
__tests__
coverage
src
*.png
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -647,4 +647,13 @@ If what you want is full-on compilation `chunk` objects (and any information it
## Contributing
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.
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.
## Tests
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).
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.
![require-universal-module wallaby tests screenshot](./tests-screenshot.png)
51 changes: 45 additions & 6 deletions __fixtures__/stats.js
Original file line number Diff line number Diff line change
@@ -1,19 +1,50 @@
const chunk1Files = [
'0.js',
'0.no_css.js',
'0.css',
'0.js.map',
'0.no_css.js.map',
'0.css.map'
]
const chunk2Files = [
'1.js',
'1.no_css.js',
'1.css',
'1.js.map',
'1.no_css.js.map',
'1.css.map'
]
const chunk3Files = [
'2.js',
'2.no_css.js',
'2.css',
'2.js.map',
'2.no_css.js.map',
'2.css.map'
]

export const stats = {
assetsByChunkName: {
bootstrap: ['bootstrap.js', 'bootstrap.no_css.js'],
vendor: ['vendor.js', 'vendor.no_css.js'],
main: ['main.js', 'main.no_css.js', 'main.css']
main: ['main.js', 'main.no_css.js', 'main.css'],
chunk1: chunk1Files,
chunk2: chunk2Files
},
chunks: [
{
id: 0,
files: ['0.js', '0.no_css.js', '0.css']
files: chunk1Files
},
{
id: 1,
files: ['1.js', '1.no_css.js', '1.css']
files: chunk2Files
},
{
id: 2,
files: chunk3Files
}
// chunk with id: 2 intentionally missing to test against invalid stats
// chunk with id: 3 intentionally missing to test against invalid stats
],
modules: [
{
Expand All @@ -30,6 +61,11 @@ export const stats = {
id: 'zxcv',
name: './src/Components/Bar.js',
chunks: [2]
},
{
id: 'fgij',
name: './src/Components/Baz.js',
chunks: [3]
}
],
publicPath: '/static/'
Expand All @@ -38,9 +74,12 @@ export const stats = {
export const babelFilePaths = [
'./src/Components/Example.js',
'./src/Components/Foo.js',
'./src/Components/Bar.js'
'./src/Components/Bar.js',
'./src/Components/Baz.js'
]

export const webpackModuleIds = ['qwer', 'asdf', 'zxcv']
export const webpackModuleIds = ['qwer', 'asdf', 'zxcv', 'fgij']

export const rootDir = '/Users/jamesgillmore/App'

export const chunkNames = ['chunk1', 'chunk2']
2 changes: 1 addition & 1 deletion __tests__/__snapshots__/createApiWithCss.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ Array [
]
`;

exports[`stylesAsString() 1`] = `
exports[`unit tests stylesAsString() 1`] = `
"/Users/jamesgillmore/App/build/main.css- the css!
/Users/jamesgillmore/App/build/0.css- the css!
Expand Down
Loading

0 comments on commit 4c7d1ca

Please sign in to comment.