diff --git a/packages/next/compiled/use-subscription/LICENSE b/packages/next/compiled/use-subscription/LICENSE new file mode 100644 index 000000000000..b96dcb0480a0 --- /dev/null +++ b/packages/next/compiled/use-subscription/LICENSE @@ -0,0 +1,21 @@ +MIT License + +Copyright (c) Facebook, Inc. and its affiliates. + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. diff --git a/packages/next/compiled/use-subscription/index.js b/packages/next/compiled/use-subscription/index.js new file mode 100644 index 000000000000..367ff0d5c148 --- /dev/null +++ b/packages/next/compiled/use-subscription/index.js @@ -0,0 +1,25 @@ +(()=>{"use strict";var e={800:e=>{ +/* +object-assign +(c) Sindre Sorhus +@license MIT +*/ +var r=Object.getOwnPropertySymbols;var t=Object.prototype.hasOwnProperty;var u=Object.prototype.propertyIsEnumerable;function toObject(e){if(e===null||e===undefined){throw new TypeError("Object.assign cannot be called with null or undefined")}return Object(e)}function shouldUseNative(){try{if(!Object.assign){return false}var e=new String("abc");e[5]="de";if(Object.getOwnPropertyNames(e)[0]==="5"){return false}var r={};for(var t=0;t<10;t++){r["_"+String.fromCharCode(t)]=t}var u=Object.getOwnPropertyNames(r).map((function(e){return r[e]}));if(u.join("")!=="0123456789"){return false}var n={};"abcdefghijklmnopqrst".split("").forEach((function(e){n[e]=e}));if(Object.keys(Object.assign({},n)).join("")!=="abcdefghijklmnopqrst"){return false}return true}catch(e){return false}}e.exports=shouldUseNative()?Object.assign:function(e,n){var a;var i=toObject(e);var s;for(var c=1;c{ +/** @license React vundefined + * use-subscription.development.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +if(process.env.NODE_ENV!=="production"){(function(){"use strict";var e=t(800);var u=t(522);function useSubscription(r){var t=r.getCurrentValue,n=r.subscribe;var a=u.useState((function(){return{getCurrentValue:t,subscribe:n,value:t()}})),i=a[0],s=a[1];var c=i.value;if(i.getCurrentValue!==t||i.subscribe!==n){c=t();s({getCurrentValue:t,subscribe:n,value:c})}u.useDebugValue(c);u.useEffect((function(){var r=false;var checkForUpdates=function(){if(r){return}var u=t();s((function(r){if(r.getCurrentValue!==t||r.subscribe!==n){return r}if(r.value===u){return r}return e({},r,{value:u})}))};var u=n(checkForUpdates);checkForUpdates();return function(){r=true;u()}}),[t,n]);return c}r.useSubscription=useSubscription})()}},403:(e,r,t)=>{ +/** @license React vundefined + * use-subscription.production.min.js + * + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + */ +var u=t(800),n=t(522);r.useSubscription=function(e){var r=e.getCurrentValue,t=e.subscribe,a=n.useState((function(){return{getCurrentValue:r,subscribe:t,value:r()}}));e=a[0];var i=a[1];a=e.value;if(e.getCurrentValue!==r||e.subscribe!==t)a=r(),i({getCurrentValue:r,subscribe:t,value:a});n.useDebugValue(a);n.useEffect((function(){function b(){if(!e){var n=r();i((function(e){return e.getCurrentValue!==r||e.subscribe!==t||e.value===n?e:u({},e,{value:n})}))}}var e=!1,n=t(b);b();return function(){e=!0;n()}}),[r,t]);return a}},138:(e,r,t)=>{if(process.env.NODE_ENV==="production"){e.exports=t(403)}else{e.exports=t(569)}},522:e=>{e.exports=require("react")}};var r={};function __nccwpck_require__(t){var u=r[t];if(u!==undefined){return u.exports}var n=r[t]={exports:{}};var a=true;try{e[t](n,n.exports,__nccwpck_require__);a=false}finally{if(a)delete r[t]}return n.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var t=__nccwpck_require__(138);module.exports=t})(); \ No newline at end of file diff --git a/packages/next/compiled/use-subscription/package.json b/packages/next/compiled/use-subscription/package.json new file mode 100644 index 000000000000..de0860953b7a --- /dev/null +++ b/packages/next/compiled/use-subscription/package.json @@ -0,0 +1 @@ +{"name":"use-subscription","main":"index.js","license":"MIT"} diff --git a/packages/next/package.json b/packages/next/package.json index e5be21726127..97adf7a19c05 100644 --- a/packages/next/package.json +++ b/packages/next/package.json @@ -72,8 +72,7 @@ "@next/env": "12.1.3-canary.3", "caniuse-lite": "^1.0.30001283", "postcss": "8.4.5", - "styled-jsx": "5.0.1", - "use-subscription": "1.5.1" + "styled-jsx": "5.0.1" }, "peerDependencies": { "fibers": ">= 3.1.0", @@ -261,6 +260,7 @@ "tty-browserify": "0.0.1", "ua-parser-js": "0.7.28", "unistore": "3.4.1", + "use-subscription": "1.5.1", "util": "0.12.4", "uuid": "8.3.2", "vm-browserify": "1.1.2", diff --git a/packages/next/shared/lib/loadable.js b/packages/next/shared/lib/loadable.js index 629bab95c7c2..e4591e4af14a 100644 --- a/packages/next/shared/lib/loadable.js +++ b/packages/next/shared/lib/loadable.js @@ -22,7 +22,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE // Modified to be compatible with webpack 4 / Next.js import React from 'react' -import { useSubscription } from 'use-subscription' +import { useSubscription } from 'next/dist/compiled/use-subscription' import { LoadableContext } from './loadable-context' const ALL_INITIALIZERS = [] diff --git a/packages/next/taskfile.js b/packages/next/taskfile.js index f90ee195447f..f96ebd779289 100644 --- a/packages/next/taskfile.js +++ b/packages/next/taskfile.js @@ -300,6 +300,23 @@ export async function ncc_react_refresh_utils(task, opts) { } } +// eslint-disable-next-line camelcase +export async function ncc_use_subscription(task, opts) { + await task + .source( + opts.src || relative(__dirname, require.resolve('use-subscription')) + ) + .ncc({ + packageName: 'use-subscription', + externals: { + ...externals, + react: 'react', + 'react-dom': 'react-dom', + }, + }) + .target('compiled/use-subscription') +} + // eslint-disable-next-line camelcase externals['chalk'] = 'next/dist/compiled/chalk' export async function ncc_chalk(task, opts) { @@ -1618,6 +1635,7 @@ export async function ncc(task, opts) { 'ncc_node_html_parser', 'ncc_watchpack', 'ncc_chalk', + 'ncc_use_subscription', 'ncc_napirs_triples', 'ncc_etag', 'ncc_p_limit',