mirror of
https://github.com/quine-global/hyper.git
synced 2026-01-13 04:28:41 -09:00
Fix module hijacking (#3067)
Regression was introduced by #2866. Release version of Hyper failed to start.
This commit is contained in:
parent
88f5804ad4
commit
bc6101e98f
5 changed files with 606 additions and 1075 deletions
|
|
@ -27,6 +27,8 @@
|
||||||
"os-locale": "2.1.0",
|
"os-locale": "2.1.0",
|
||||||
"parse-url": "3.0.2",
|
"parse-url": "3.0.2",
|
||||||
"queue": "4.4.2",
|
"queue": "4.4.2",
|
||||||
|
"react": "16.2.0",
|
||||||
|
"react-dom": "16.2.0",
|
||||||
"semver": "5.5.0",
|
"semver": "5.5.0",
|
||||||
"shell-env": "0.3.0",
|
"shell-env": "0.3.0",
|
||||||
"uuid": "3.2.1",
|
"uuid": "3.2.1",
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,9 @@ const {writeFileSync} = require('fs');
|
||||||
const Config = require('electron-config');
|
const Config = require('electron-config');
|
||||||
const ms = require('ms');
|
const ms = require('ms');
|
||||||
|
|
||||||
|
const React = require('react');
|
||||||
|
const ReactDom = require('react-dom');
|
||||||
|
|
||||||
const config = require('./config');
|
const config = require('./config');
|
||||||
const notify = require('./notify');
|
const notify = require('./notify');
|
||||||
const {availableExtensions} = require('./plugins/extensions');
|
const {availableExtensions} = require('./plugins/extensions');
|
||||||
|
|
@ -49,10 +52,6 @@ config.subscribe(() => {
|
||||||
// so plugins can `require` them without needing their own version
|
// so plugins can `require` them without needing their own version
|
||||||
// https://github.com/zeit/hyper/issues/619
|
// https://github.com/zeit/hyper/issues/619
|
||||||
function patchModuleLoad() {
|
function patchModuleLoad() {
|
||||||
const React = require('react');
|
|
||||||
const PureComponent = React.PureComponent;
|
|
||||||
const ReactDOM = require('react-dom');
|
|
||||||
|
|
||||||
const Module = require('module');
|
const Module = require('module');
|
||||||
const originalLoad = Module._load;
|
const originalLoad = Module._load;
|
||||||
Module._load = function _load(modulePath) {
|
Module._load = function _load(modulePath) {
|
||||||
|
|
@ -60,11 +59,14 @@ function patchModuleLoad() {
|
||||||
// lib/utils/plugins.js
|
// lib/utils/plugins.js
|
||||||
switch (modulePath) {
|
switch (modulePath) {
|
||||||
case 'react':
|
case 'react':
|
||||||
|
// DEPRECATED
|
||||||
return React;
|
return React;
|
||||||
case 'react-dom':
|
case 'react-dom':
|
||||||
return ReactDOM;
|
// DEPRECATED
|
||||||
|
return ReactDom;
|
||||||
case 'hyper/component':
|
case 'hyper/component':
|
||||||
return PureComponent;
|
// DEPRECATED
|
||||||
|
return React.PureComponent;
|
||||||
// These return Object, since they work differently on the backend, than on the frontend.
|
// These return Object, since they work differently on the backend, than on the frontend.
|
||||||
// Still needs to be here, to prevent errors, while loading plugins.
|
// Still needs to be here, to prevent errors, while loading plugins.
|
||||||
case 'hyper/Notification':
|
case 'hyper/Notification':
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,10 @@ ansi-regex@^2.0.0:
|
||||||
version "2.1.1"
|
version "2.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df"
|
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-2.1.1.tgz#c3b33ab5ee360d86e0e628f0468ae7ef27d654df"
|
||||||
|
|
||||||
|
asap@~2.0.3:
|
||||||
|
version "2.0.6"
|
||||||
|
resolved "https://registry.yarnpkg.com/asap/-/asap-2.0.6.tgz#e50347611d7e690943208bbdafebcbc2fb866d46"
|
||||||
|
|
||||||
async-retry@1.1.4:
|
async-retry@1.1.4:
|
||||||
version "1.1.4"
|
version "1.1.4"
|
||||||
resolved "https://registry.yarnpkg.com/async-retry/-/async-retry-1.1.4.tgz#e0edb546600f19bf90f892e9494faa9e19baf190"
|
resolved "https://registry.yarnpkg.com/async-retry/-/async-retry-1.1.4.tgz#e0edb546600f19bf90f892e9494faa9e19baf190"
|
||||||
|
|
@ -53,6 +57,10 @@ convert-css-color-name-to-hex@0.1.1:
|
||||||
css-color-names "0.0.3"
|
css-color-names "0.0.3"
|
||||||
is-css-color-name "^0.1.1"
|
is-css-color-name "^0.1.1"
|
||||||
|
|
||||||
|
core-js@^1.0.0:
|
||||||
|
version "1.2.7"
|
||||||
|
resolved "https://registry.yarnpkg.com/core-js/-/core-js-1.2.7.tgz#652294c14651db28fa93bd2d5ff2983a4f08c636"
|
||||||
|
|
||||||
cross-spawn@^4.0.0:
|
cross-spawn@^4.0.0:
|
||||||
version "4.0.2"
|
version "4.0.2"
|
||||||
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-4.0.2.tgz#7b9247621c23adfdd3856004a823cbe397424d41"
|
resolved "https://registry.yarnpkg.com/cross-spawn/-/cross-spawn-4.0.2.tgz#7b9247621c23adfdd3856004a823cbe397424d41"
|
||||||
|
|
@ -142,6 +150,18 @@ execa@^0.7.0:
|
||||||
signal-exit "^3.0.0"
|
signal-exit "^3.0.0"
|
||||||
strip-eof "^1.0.0"
|
strip-eof "^1.0.0"
|
||||||
|
|
||||||
|
fbjs@^0.8.16:
|
||||||
|
version "0.8.16"
|
||||||
|
resolved "https://registry.yarnpkg.com/fbjs/-/fbjs-0.8.16.tgz#5e67432f550dc41b572bf55847b8aca64e5337db"
|
||||||
|
dependencies:
|
||||||
|
core-js "^1.0.0"
|
||||||
|
isomorphic-fetch "^2.1.1"
|
||||||
|
loose-envify "^1.0.0"
|
||||||
|
object-assign "^4.1.0"
|
||||||
|
promise "^7.1.1"
|
||||||
|
setimmediate "^1.0.5"
|
||||||
|
ua-parser-js "^0.7.9"
|
||||||
|
|
||||||
file-uri-to-path@1.0.0:
|
file-uri-to-path@1.0.0:
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd"
|
resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd"
|
||||||
|
|
@ -223,6 +243,17 @@ isexe@^2.0.0:
|
||||||
version "2.0.0"
|
version "2.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
|
resolved "https://registry.yarnpkg.com/isexe/-/isexe-2.0.0.tgz#e8fbf374dc556ff8947a10dcb0572d633f2cfa10"
|
||||||
|
|
||||||
|
isomorphic-fetch@^2.1.1:
|
||||||
|
version "2.2.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/isomorphic-fetch/-/isomorphic-fetch-2.2.1.tgz#611ae1acf14f5e81f729507472819fe9733558a9"
|
||||||
|
dependencies:
|
||||||
|
node-fetch "^1.0.1"
|
||||||
|
whatwg-fetch ">=0.10.0"
|
||||||
|
|
||||||
|
js-tokens@^3.0.0:
|
||||||
|
version "3.0.2"
|
||||||
|
resolved "https://registry.yarnpkg.com/js-tokens/-/js-tokens-3.0.2.tgz#9866df395102130e38f7f996bceb65443209c25b"
|
||||||
|
|
||||||
lcid@^1.0.0:
|
lcid@^1.0.0:
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/lcid/-/lcid-1.0.0.tgz#308accafa0bc483a3867b4b6f2b9506251d1b835"
|
resolved "https://registry.yarnpkg.com/lcid/-/lcid-1.0.0.tgz#308accafa0bc483a3867b4b6f2b9506251d1b835"
|
||||||
|
|
@ -244,6 +275,12 @@ lodash@^4.16.6:
|
||||||
version "4.17.4"
|
version "4.17.4"
|
||||||
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
|
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.4.tgz#78203a4d1c328ae1d86dca6460e369b57f4055ae"
|
||||||
|
|
||||||
|
loose-envify@^1.0.0, loose-envify@^1.1.0, loose-envify@^1.3.1:
|
||||||
|
version "1.3.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/loose-envify/-/loose-envify-1.3.1.tgz#d1a8ad33fa9ce0e713d65fdd0ac8b748d478c848"
|
||||||
|
dependencies:
|
||||||
|
js-tokens "^3.0.0"
|
||||||
|
|
||||||
lru-cache@^4.0.1:
|
lru-cache@^4.0.1:
|
||||||
version "4.1.1"
|
version "4.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.1.tgz#622e32e82488b49279114a4f9ecf45e7cd6bba55"
|
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-4.1.1.tgz#622e32e82488b49279114a4f9ecf45e7cd6bba55"
|
||||||
|
|
@ -289,7 +326,7 @@ nan@^2.6.2:
|
||||||
version "2.7.0"
|
version "2.7.0"
|
||||||
resolved "https://registry.yarnpkg.com/nan/-/nan-2.7.0.tgz#d95bf721ec877e08db276ed3fc6eb78f9083ad46"
|
resolved "https://registry.yarnpkg.com/nan/-/nan-2.7.0.tgz#d95bf721ec877e08db276ed3fc6eb78f9083ad46"
|
||||||
|
|
||||||
node-fetch@1.7.3:
|
node-fetch@1.7.3, node-fetch@^1.0.1:
|
||||||
version "1.7.3"
|
version "1.7.3"
|
||||||
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef"
|
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-1.7.3.tgz#980f6f72d85211a5347c6b2bc18c5b84c3eb47ef"
|
||||||
dependencies:
|
dependencies:
|
||||||
|
|
@ -317,7 +354,7 @@ npm-run-path@^2.0.0:
|
||||||
dependencies:
|
dependencies:
|
||||||
path-key "^2.0.0"
|
path-key "^2.0.0"
|
||||||
|
|
||||||
object-assign@^4.0.1, object-assign@^4.1.0:
|
object-assign@^4.0.1, object-assign@^4.1.0, object-assign@^4.1.1:
|
||||||
version "4.1.1"
|
version "4.1.1"
|
||||||
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
|
resolved "https://registry.yarnpkg.com/object-assign/-/object-assign-4.1.1.tgz#2109adc7965887cfc05cbbd442cac8bfbb360863"
|
||||||
|
|
||||||
|
|
@ -391,6 +428,20 @@ prepend-http@^1.0.0:
|
||||||
version "1.0.4"
|
version "1.0.4"
|
||||||
resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc"
|
resolved "https://registry.yarnpkg.com/prepend-http/-/prepend-http-1.0.4.tgz#d4f4562b0ce3696e41ac52d0e002e57a635dc6dc"
|
||||||
|
|
||||||
|
promise@^7.1.1:
|
||||||
|
version "7.3.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/promise/-/promise-7.3.1.tgz#064b72602b18f90f29192b8b1bc418ffd1ebd3bf"
|
||||||
|
dependencies:
|
||||||
|
asap "~2.0.3"
|
||||||
|
|
||||||
|
prop-types@^15.6.0:
|
||||||
|
version "15.6.1"
|
||||||
|
resolved "https://registry.yarnpkg.com/prop-types/-/prop-types-15.6.1.tgz#36644453564255ddda391191fb3a125cbdf654ca"
|
||||||
|
dependencies:
|
||||||
|
fbjs "^0.8.16"
|
||||||
|
loose-envify "^1.3.1"
|
||||||
|
object-assign "^4.1.1"
|
||||||
|
|
||||||
protocols@^1.1.0, protocols@^1.4.0:
|
protocols@^1.1.0, protocols@^1.4.0:
|
||||||
version "1.4.6"
|
version "1.4.6"
|
||||||
resolved "https://registry.yarnpkg.com/protocols/-/protocols-1.4.6.tgz#f8bb263ea1b5fd7a7604d26b8be39bd77678bf8a"
|
resolved "https://registry.yarnpkg.com/protocols/-/protocols-1.4.6.tgz#f8bb263ea1b5fd7a7604d26b8be39bd77678bf8a"
|
||||||
|
|
@ -412,6 +463,24 @@ queue@4.4.2:
|
||||||
dependencies:
|
dependencies:
|
||||||
inherits "~2.0.0"
|
inherits "~2.0.0"
|
||||||
|
|
||||||
|
react-dom@16.2.0:
|
||||||
|
version "16.2.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/react-dom/-/react-dom-16.2.0.tgz#69003178601c0ca19b709b33a83369fe6124c044"
|
||||||
|
dependencies:
|
||||||
|
fbjs "^0.8.16"
|
||||||
|
loose-envify "^1.1.0"
|
||||||
|
object-assign "^4.1.1"
|
||||||
|
prop-types "^15.6.0"
|
||||||
|
|
||||||
|
react@16.2.0:
|
||||||
|
version "16.2.0"
|
||||||
|
resolved "https://registry.yarnpkg.com/react/-/react-16.2.0.tgz#a31bd2dab89bff65d42134fa187f24d054c273ba"
|
||||||
|
dependencies:
|
||||||
|
fbjs "^0.8.16"
|
||||||
|
loose-envify "^1.1.0"
|
||||||
|
object-assign "^4.1.1"
|
||||||
|
prop-types "^15.6.0"
|
||||||
|
|
||||||
retry@0.10.1:
|
retry@0.10.1:
|
||||||
version "0.10.1"
|
version "0.10.1"
|
||||||
resolved "https://registry.yarnpkg.com/retry/-/retry-0.10.1.tgz#e76388d217992c252750241d3d3956fed98d8ff4"
|
resolved "https://registry.yarnpkg.com/retry/-/retry-0.10.1.tgz#e76388d217992c252750241d3d3956fed98d8ff4"
|
||||||
|
|
@ -424,6 +493,10 @@ semver@^5.3.0:
|
||||||
version "5.4.1"
|
version "5.4.1"
|
||||||
resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e"
|
resolved "https://registry.yarnpkg.com/semver/-/semver-5.4.1.tgz#e059c09d8571f0540823733433505d3a2f00b18e"
|
||||||
|
|
||||||
|
setimmediate@^1.0.5:
|
||||||
|
version "1.0.5"
|
||||||
|
resolved "https://registry.yarnpkg.com/setimmediate/-/setimmediate-1.0.5.tgz#290cbb232e306942d7d7ea9b83732ab7856f8285"
|
||||||
|
|
||||||
shebang-command@^1.2.0:
|
shebang-command@^1.2.0:
|
||||||
version "1.2.0"
|
version "1.2.0"
|
||||||
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea"
|
resolved "https://registry.yarnpkg.com/shebang-command/-/shebang-command-1.2.0.tgz#44aac65b695b03398968c39f363fee5deafdf1ea"
|
||||||
|
|
@ -472,10 +545,18 @@ strip-eof@^1.0.0:
|
||||||
version "1.0.0"
|
version "1.0.0"
|
||||||
resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf"
|
resolved "https://registry.yarnpkg.com/strip-eof/-/strip-eof-1.0.0.tgz#bb43ff5598a6eb05d89b59fcd129c983313606bf"
|
||||||
|
|
||||||
|
ua-parser-js@^0.7.9:
|
||||||
|
version "0.7.18"
|
||||||
|
resolved "https://registry.yarnpkg.com/ua-parser-js/-/ua-parser-js-0.7.18.tgz#a7bfd92f56edfb117083b69e31d2aa8882d4b1ed"
|
||||||
|
|
||||||
uuid@3.2.1:
|
uuid@3.2.1:
|
||||||
version "3.2.1"
|
version "3.2.1"
|
||||||
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.2.1.tgz#12c528bb9d58d0b9265d9a2f6f0fe8be17ff1f14"
|
resolved "https://registry.yarnpkg.com/uuid/-/uuid-3.2.1.tgz#12c528bb9d58d0b9265d9a2f6f0fe8be17ff1f14"
|
||||||
|
|
||||||
|
whatwg-fetch@>=0.10.0:
|
||||||
|
version "2.0.4"
|
||||||
|
resolved "https://registry.yarnpkg.com/whatwg-fetch/-/whatwg-fetch-2.0.4.tgz#dde6a5df315f9d39991aa17621853d720b85566f"
|
||||||
|
|
||||||
which@^1.2.9:
|
which@^1.2.9:
|
||||||
version "1.3.0"
|
version "1.3.0"
|
||||||
resolved "https://registry.yarnpkg.com/which/-/which-1.3.0.tgz#ff04bdfc010ee547d780bec38e1ac1c2777d253a"
|
resolved "https://registry.yarnpkg.com/which/-/which-1.3.0.tgz#ff04bdfc010ee547d780bec38e1ac1c2777d253a"
|
||||||
|
|
|
||||||
|
|
@ -18,10 +18,18 @@ Module._load = function _load(path) {
|
||||||
// app/plugins.js
|
// app/plugins.js
|
||||||
switch (path) {
|
switch (path) {
|
||||||
case 'react':
|
case 'react':
|
||||||
|
//eslint-disable-next-line no-console
|
||||||
|
console.warn('DEPRECATED: If your plugin requires `react`, it must bundle it as a dependency');
|
||||||
return React;
|
return React;
|
||||||
case 'react-dom':
|
case 'react-dom':
|
||||||
|
//eslint-disable-next-line no-console
|
||||||
|
console.warn('DEPRECATED: If your plugin requires `react-dom`, it must bundle it as a dependency');
|
||||||
return ReactDOM;
|
return ReactDOM;
|
||||||
case 'hyper/component':
|
case 'hyper/component':
|
||||||
|
//eslint-disable-next-line no-console
|
||||||
|
console.warn(
|
||||||
|
'DEPRECATED: If your plugin requires `hyper/component`, it must requires `react.PureComponent` instead and bundle `react` as a dependcy'
|
||||||
|
);
|
||||||
return PureComponent;
|
return PureComponent;
|
||||||
case 'hyper/notify':
|
case 'hyper/notify':
|
||||||
return notify;
|
return notify;
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue