diff --git a/README.md b/README.md index ff29588..8e6b7fe 100644 --- a/README.md +++ b/README.md @@ -48,7 +48,7 @@ See https://github.com/parcel-bundler/parcel/pull/850 For any other build system, which may not support aliasing - use yarn name resolution. See https://twitter.com/sebmck/status/873958247304232961?lang=en for details. ```text -yarn add @hot-loader/react-dom@npm:react-dom +yarn add react-dom@npm:@hot-loader/react-dom ``` # Using webpack-loader diff --git a/package.json b/package.json index 7c44948..937b9ae 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "private": true, "name": "@hot-loader/react-dom", - "version": "16.7.0-alpha.2.2", + "version": "0.0.0", "description": "The Hot version of React-DOM", "main": "index.js", "scripts": { diff --git a/patch/build.js b/patch/build.js index c04b8d4..d013620 100644 --- a/patch/build.js +++ b/patch/build.js @@ -8,7 +8,7 @@ let patchedFiles = []; const copyFile = (source, dest) => { const data = readFileSync(source).toString(); const patchedData = patch(data); - if (patchedData) { + if (patchedData !== data) { patchedFiles.push(dest); } writeFileSync(dest, patchedData || data) @@ -39,6 +39,6 @@ writeFileSync('../target/package.json', JSON.stringify(Object.assign(pkg, self), console.log(patchedFiles); if (patchedFiles.length !== 2) { - throw new Error('expected to patch 1 file'); + throw new Error('expected to patch 2 file'); } diff --git a/patch/patch.js b/patch/patch.js index d61493d..59e2dc6 100644 --- a/patch/patch.js +++ b/patch/patch.js @@ -1,34 +1,34 @@ const injectionStart = { '16.6': [ 'if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.elementType === element.type)', - 'if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : hotCompareElements(child.elementType, element.type, updateChild(child)))' + 'if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : hotCompareElements(child.elementType, element.type, updateChild(child), child.type))' ], '16.6-compact': [ 'if(child.tag===Fragment?element.type===REACT_FRAGMENT_TYPE:child.elementType===element.type)', - 'if(child.tag===Fragment?element.type===REACT_FRAGMENT_TYPE:hotCompareElements(child.elementType,element.type, updateChild(child)))' + 'if(child.tag===Fragment?element.type===REACT_FRAGMENT_TYPE:hotCompareElements(child.elementType,element.type, updateChild(child), child.type))' ], '16.4': [ 'if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : child.type === element.type) {', - 'if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : hotCompareElements(child.type, element.type, updateChild(child))) {' + 'if (child.tag === Fragment ? element.type === REACT_FRAGMENT_TYPE : hotCompareElements(child.type, element.type, updateChild(child), child.type)) {' ], '16.4-compact': [ 'if(child.tag===Fragment?element.type===REACT_FRAGMENT_TYPE:child.type===element.type)', - 'if(child.tag===Fragment?element.type===REACT_FRAGMENT_TYPE:hotCompareElements(child.type,element.type, updateChild(child)))' + 'if(child.tag===Fragment?element.type===REACT_FRAGMENT_TYPE:hotCompareElements(child.type,element.type, updateChild(child), child.type))' ], }; const additional = { '16.6-update': [ 'if (current$$1 !== null && current$$1.elementType === element.type) {', - 'if (current$$1 !== null && hotCompareElements(current$$1.elementType, element.type, updateChild(current$$1))) {' + 'if (current$$1 !== null && hotCompareElements(current$$1.elementType, element.type, updateChild(current$$1),current$$1.type)) {' ], '16.6-update-compact': [ 'if(current$$1!==null&¤t$$1.elementType===element.type)', - 'if(current$$1!==null&&hotCompareElements(current$$1.elementType,element.type,updateChild(current$$1)))' + 'if(current$$1!==null&&hotCompareElements(current$$1.elementType,element.type,updateChild(current$$1),current$$1.type))' ], '16.4-update': [ 'if (current !== null && current.type === element.type) {', - 'if (current !== null && hotCompareElements(current.type, element.type, updateChild(current))) {' + 'if (current !== null && hotCompareElements(current.type, element.type, updateChild(current),current.type)) {' ], '16.4-update-compact': [ 'if (current!== null&¤t.type===element.type)', @@ -72,7 +72,7 @@ const injectionEnd = { '16.4-compact': defaultEndCompact, }; -const sign = '/** 🔥 this is hot-loader/react-dom 🔥 */'; +const sign = '/* 🔥 this is hot-loader/react-dom 🔥 */'; function additionalTransform(source) { for (const key in additional) { @@ -84,7 +84,7 @@ function additionalTransform(source) { function transform(source) { if (source.indexOf('reconcileSingleElement') < 0) { // early reject - return false; + return source; } for (const key in injectionStart) { if ( @@ -99,7 +99,7 @@ function transform(source) { return `${sign}\n${result}\n${sign}`; } } - return false; + return source; } module.exports = transform; diff --git a/source/README.md b/source/README.md index ff29588..8e6b7fe 100644 --- a/source/README.md +++ b/source/README.md @@ -48,7 +48,7 @@ See https://github.com/parcel-bundler/parcel/pull/850 For any other build system, which may not support aliasing - use yarn name resolution. See https://twitter.com/sebmck/status/873958247304232961?lang=en for details. ```text -yarn add @hot-loader/react-dom@npm:react-dom +yarn add react-dom@npm:@hot-loader/react-dom ``` # Using webpack-loader diff --git a/source/package.base.json b/source/package.base.json index 5490ee9..32fd33a 100644 --- a/source/package.base.json +++ b/source/package.base.json @@ -1,6 +1,6 @@ { "name": "@hot-loader/react-dom", - "version": "16.7.0-alpha.2.3", + "version": "16.7.0-alpha.2.4", "description": "The Hot version of React-DOM", "scripts": { "build": "node build.js"