Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
fix: tests
  • Loading branch information
ScriptedAlchemy committed Mar 27, 2019
commit 7ce7f197e0dbddddfdf296a495488c44d340bf6a
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
"prepublish": "npm run build",
"release:validate": "commitlint --from=$(git describe --tags --abbrev=0) --to=$(git rev-parse HEAD)",
"security": "npm audit",
"test": "jest",
"test": "jest --updateSnapshot",
"test:watch": "jest --watch",
"test:coverage": "jest --collectCoverageFrom='src/**/*.js' --coverage",
"test:manual": "webpack-dev-server test/manual/src/index.js --open --config test/manual/webpack.config.js",
Expand Down Expand Up @@ -89,6 +89,7 @@
"eslint": "^4.17.0",
"eslint-plugin-import": "^2.8.0",
"eslint-plugin-prettier": "^2.6.0",
"execa": "^1.0.0",
"file-loader": "^1.1.11",
"husky": "^0.14.3",
"jest": "^22.2.2",
Expand Down
1 change: 1 addition & 0 deletions src/hmr/hotModuleReplacement.js
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ function reloadAll() {

module.exports = function(moduleId, options) {
if (noDocument) {
console.log('no window.document found, will not HMR CSS');
return noop;
}

Expand Down
15 changes: 0 additions & 15 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,21 +394,6 @@ class ExtractCssChunksPlugin {
});
}

traverseDepthFirst(root, visit) {
let nodesToVisit = [root];

while (nodesToVisit.length > 0) {
const currentNode = nodesToVisit.shift();

if (currentNode !== null && typeof currentNode === 'object') {
const children = Object.values(currentNode);
nodesToVisit = [...children, ...nodesToVisit];
}

visit(currentNode);
}
}

getCssChunkObject(mainChunk) {
const obj = {};
for (const chunk of mainChunk.getAllAsyncChunks()) {
Expand Down
6 changes: 4 additions & 2 deletions src/loader.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ import LimitChunkCountPlugin from 'webpack/lib/optimize/LimitChunkCountPlugin';
const MODULE_TYPE = 'css/extract-css-chunks';
const pluginName = 'extract-css-chunks-webpack-plugin';

function hotLoader(content, context, modules) {
const accept = modules ? '' : 'module.hot.accept(undefined, cssReload);';
function hotLoader(content, context) {
const accept = context.locals
? ''
: 'module.hot.accept(undefined, cssReload);';
const result = `${content}
if(module.hot) {
// ${Date.now()}
Expand Down
15 changes: 7 additions & 8 deletions test/TestCases.test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import fs from 'fs';
import path from 'path';
import { exec } from 'child_process';

import webpack from 'webpack';
import execa from 'execa';

describe('TestCases', () => {
const casesDirectory = path.resolve(__dirname, 'cases');
Expand Down Expand Up @@ -89,13 +89,12 @@ describe('HMR', () => {
});

it('is es5 only', () => {
exec(
'./node_modules/.bin/es-check es5 src/hmr/hotModuleReplacement.js',
(error, stdout, stderr) => {
expect(
stderr.indexOf('there were no ES version matching errors!') > -1
).toBe(true);
}
const { stderr } = execa.shellSync(
'npx es-check es5 src/hmr/hotModuleReplacement.js'
);

expect(stderr.indexOf('there were no ES version matching errors') > 1).toBe(
true
);
});
});
1 change: 1 addition & 0 deletions test/__snapshots__/TestCases.test.js.snap
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,7 @@ function reloadAll() {

module.exports = function(moduleId, options) {
if (noDocument) {
console.log('no window.document found, will not HMR CSS')
return noop;
}

Expand Down