Skip to content

Commit 4993362

Browse files
feat(hotLoading): Addressing some issues in HMR (#136)
* feat(hotLoading): Addressing some issues in HMR CSS modules should have better HMR. Updates and renames were also done that appear to have gotton lost Fixed up CSS reloadAll Dont assume CSS modules be default Also fixing css loading order issues that appear during HMR Pulling in a handful of fixes from webpack * test: adding and fixing broken tests Following webpack here and getting my tests passing again * chore: General updates New linting rules Editor configs prettier config added commitlint configs added some dependency updates * ci: fixing semantic release
1 parent 7198177 commit 4993362

File tree

133 files changed

+3332
-1782
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

133 files changed

+3332
-1782
lines changed

.babelrc

Lines changed: 33 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,36 +1,35 @@
11
{
2-
"presets": [
3-
[
4-
"env",
5-
{
6-
"useBuiltIns": true,
7-
"targets": {
8-
"node": "6.11.5",
9-
"browsers": "cover 99.5%"
10-
},
11-
"exclude": [
12-
"transform-async-to-generator",
13-
"transform-regenerator"
14-
]
15-
}
16-
]
17-
],
18-
"plugins": [
19-
[
20-
"transform-object-rest-spread",
21-
{
22-
"useBuiltIns": true
23-
}
24-
]
25-
],
26-
"env": {
27-
"test": {
28-
"presets": [
29-
"env"
30-
],
31-
"plugins": [
32-
"transform-object-rest-spread"
33-
]
34-
}
35-
}
2+
"presets": [
3+
[
4+
"env",
5+
{
6+
"useBuiltIns": true,
7+
"targets": {
8+
"node": "6.9.0"
9+
},
10+
"exclude": [
11+
"transform-async-to-generator",
12+
"transform-regenerator"
13+
]
14+
}
15+
]
16+
],
17+
"plugins": [
18+
[
19+
"transform-object-rest-spread",
20+
{
21+
"useBuiltIns": true
22+
}
23+
]
24+
],
25+
"env": {
26+
"test": {
27+
"presets": [
28+
"env"
29+
],
30+
"plugins": [
31+
"transform-object-rest-spread"
32+
]
33+
}
34+
}
3635
}

.eslintrc.js

Lines changed: 12 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,16 @@
11
module.exports = {
2-
parser: 'babel-eslint',
3-
parserOptions: {
4-
ecmaFeatures: {
5-
generators: true,
6-
experimentalObjectRestSpread: true
7-
},
8-
sourceType: 'module',
9-
allowImportExportEverywhere: false
10-
},
11-
extends: ['airbnb'],
12-
env: {
13-
'browser': true,
2+
root: true,
3+
plugins: ['prettier'],
4+
extends: ['@webpack-contrib/eslint-config-webpack'],
5+
globals: {
6+
document: true
147
},
158
rules: {
16-
'no-param-reassign': 0,
17-
'func-names': 0,
18-
'no-underscore-dangle': 0,
19-
'no-restricted-syntax': 0,
20-
'prefer-arrow-callback': 0,
21-
'prefer-destructuring': 0,
22-
'array-callback-return': 0,
23-
'prefer-template': 0,
24-
'class-methods-use-this': 0,
25-
'no-plusplus': 0
26-
}
9+
'prettier/prettier': [
10+
'error',
11+
{ singleQuote: true, trailingComma: 'es5', arrowParens: 'always' },
12+
],
13+
'class-methods-use-this': 'off',
14+
'no-undefined': 'off',
15+
},
2716
};

.prettierrc

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"singleQuote": true,
3+
"trailingComma": "es5",
4+
"arrowParens": "always"
5+
}

.travis.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ node_js:
55
script:
66
- echo success
77
after_success:
8-
- npx semantic-release
8+
- npm run semantic-release
99
branches:
1010
except:
1111
- /^v\d+\.\d+\.\d+$/

commitlint.config.js

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
/* eslint-disable */
2+
const Configuration = {
3+
extends: ['@commitlint/config-conventional'],
4+
5+
rules: {
6+
'body-leading-blank': [1, 'always'],
7+
'footer-leading-blank': [1, 'always'],
8+
'header-max-length': [2, 'always', 72],
9+
'scope-case': [2, 'always', 'lower-case'],
10+
'subject-case': [2, 'never', ['sentence-case', 'start-case', 'pascal-case', 'upper-case']],
11+
'subject-empty': [2, 'never'],
12+
'subject-full-stop': [2, 'never', '.'],
13+
'type-case': [2, 'always', 'lower-case'],
14+
'type-empty': [2, 'never'],
15+
'type-enum': [2, 'always', [
16+
'build',
17+
'chore',
18+
'ci',
19+
'docs',
20+
'feat',
21+
'fix',
22+
'perf',
23+
'refactor',
24+
'revert',
25+
'style',
26+
'test',
27+
],
28+
],
29+
},
30+
};
31+
32+
module.exports = Configuration;

jest.config.js

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,5 @@
11
module.exports = {
2-
testPathIgnorePatterns: [
3-
'<rootDir>/TO_DELETE_test/',
4-
],
5-
transformIgnorePatterns: [
6-
'/node_modules/',
7-
'<rootDir>/dist/',
8-
],
9-
watchPathIgnorePatterns: [
10-
'<rootDir>/test/js',
11-
],
2+
testURL: 'http://localhost/',
3+
transformIgnorePatterns: ['/node_modules/', '<rootDir>/dist/'],
4+
watchPathIgnorePatterns: ['<rootDir>/test/js'],
125
};
13-

package.json

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -46,52 +46,48 @@
4646
"ci:coverage": "npm run test:coverage -- --runInBand",
4747
"build:example": "npm run build && webpack-dev-server test/manual/src/index.js --open --config test/manual/webpack.config.js",
4848
"cm": "git-cz",
49-
"release": "standard-version",
50-
"semantic-release": "semantic-release pre && npm publish && semantic-release post",
51-
"travis": "npm run ci:coverage"
49+
"semantic-release": "npx semantic-release pre && npm publish && npx semantic-release post",
50+
"travis": "npm run ci:coverage",
51+
"defaults": "webpack-defaults"
5252
},
5353
"peerDependencies": {
54-
"webpack": "^4.8.3"
54+
"webpack": "^4.4.0"
5555
},
5656
"dependencies": {
5757
"loader-utils": "^1.1.0",
58-
"lodash": "^4.17.5",
59-
"normalize-url": "^1.9.1",
58+
"lodash": "^4.17.11",
59+
"normalize-url": "^4.1.0",
60+
"schema-utils": "^1.0.0",
6061
"webpack-sources": "^1.1.0"
6162
},
6263
"devDependencies": {
64+
"@commitlint/cli": "^6.1.3",
65+
"@commitlint/config-conventional": "^6.1.3",
6366
"@webpack-contrib/eslint-config-webpack": "^2.0.4",
6467
"babel-cli": "^6.26.0",
65-
"babel-eslint": "^7.2.3",
6668
"babel-jest": "^22.2.2",
67-
"babel-loader": "^7.1.4",
6869
"babel-plugin-transform-object-rest-spread": "^6.26.0",
6970
"babel-polyfill": "^6.26.0",
7071
"babel-preset-env": "^1.6.1",
71-
"commitizen": "^2.10.1",
7272
"conventional-github-releaser": "^2.0.2",
7373
"cross-env": "^5.1.3",
7474
"css-loader": "^0.28.10",
75-
"cz-conventional-changelog": "^2.1.0",
7675
"del": "^3.0.0",
7776
"del-cli": "^1.1.0",
78-
"eslint": "^3.19.0",
79-
"eslint-config-airbnb": "^15.0.1",
80-
"eslint-plugin-flowtype": "^2.32.1",
77+
"eslint": "^4.17.0",
8178
"eslint-plugin-import": "^2.8.0",
82-
"eslint-plugin-jsx-a11y": "^5.0.3",
8379
"eslint-plugin-prettier": "^2.6.0",
84-
"eslint-plugin-react": "^7.0.1",
80+
"file-loader": "^1.1.11",
8581
"husky": "^0.14.3",
8682
"jest": "^22.2.2",
83+
"lint-staged": "^6.1.0",
8784
"memory-fs": "^0.4.1",
88-
"nsp": "^3.1.0",
8985
"pre-commit": "^1.2.2",
9086
"prettier": "^1.11.1",
91-
"standard-version": "^4.4.0",
9287
"semantic-release": "^6.3.2",
93-
"webpack": "4.8.3",
88+
"webpack": "^4.14.0",
9489
"webpack-cli": "^2.0.13",
90+
"webpack-defaults": "^2.3.0",
9591
"webpack-dev-server": "^3.1.1"
9692
},
9793
"homepage": "http://github.com/faceyspacey/extract-css-chunks-webpack-plugin",

src/hotLoader.js

Lines changed: 14 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,29 @@
11
const path = require('path');
2+
23
const loaderUtils = require('loader-utils');
34

45
const defaultOptions = {
5-
fileMap: '{fileName}',
6-
cssModules: true,
6+
fileMap: '{fileName}',
77
};
88

9-
module.exports = function (content) {
10-
this.cacheable();
11-
const options = Object.assign(
9+
module.exports = function(content) {
10+
this.cacheable();
11+
const options = Object.assign(
1212
{},
1313
defaultOptions,
14-
loaderUtils.getOptions(this),
14+
loaderUtils.getOptions(this)
1515
);
1616

17-
const accept = options.cssModules ? '' : 'module.hot.accept(undefined, cssReload);';
18-
return content + `
17+
const accept = options.cssModules
18+
? ''
19+
: 'module.hot.accept(undefined, cssReload);';
20+
return `${content}
1921
if(module.hot) {
2022
// ${Date.now()}
21-
var cssReload = require(${loaderUtils.stringifyRequest(this, path.join(__dirname, 'hotModuleReplacement.js'))})(module.id, ${JSON.stringify(options)});
23+
var cssReload = require(${loaderUtils.stringifyRequest(
24+
this,
25+
path.join(__dirname, 'hotModuleReplacement.js')
26+
)})(module.id, ${JSON.stringify(options)});
2227
module.hot.dispose(cssReload);
2328
${accept};
2429
}

0 commit comments

Comments
 (0)