Some checks failed
Test examples / Test Examples (20) (push) Has been cancelled
Test examples / Test Examples (22) (push) Has been cancelled
Lock Threads / action (push) Has been cancelled
Trigger Release / start (push) Has been cancelled
Stale issue handler / stale (push) Has been cancelled
Update Font Data / create-pull-request (push) Has been cancelled
build-and-deploy / deploy-target (push) Has been cancelled
build-and-deploy / build (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-musl - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-unknown-linux-gnu - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-pc-windows-msvc - node@16 (push) Has been cancelled
build-and-deploy / stable - aarch64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / stable - x86_64-apple-darwin - node@16 (push) Has been cancelled
build-and-deploy / build-wasm (nodejs) (push) Has been cancelled
build-and-deploy / build-wasm (web) (push) Has been cancelled
build-and-deploy / Deploy preview tarball (push) Has been cancelled
build-and-deploy / Potentially publish release (push) Has been cancelled
build-and-deploy / publish-turbopack-npm-packages (push) Has been cancelled
build-and-deploy / Deploy examples (push) Has been cancelled
build-and-deploy / thank you, build (push) Has been cancelled
build-and-deploy / Upload Turbopack Bytesize metrics to Datadog (push) Has been cancelled
Rspack Next.js development integration tests / Rspack integration tests (push) Has been cancelled
Rspack Next.js production integration tests / Rspack integration tests (push) Has been cancelled
Turbopack Next.js development integration tests / Next.js integration tests (push) Has been cancelled
Turbopack Next.js production integration tests / Next.js integration tests (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack development test manifest (push) Has been cancelled
Update Rspack test manifest / Update and upload Rspack production test manifest (push) Has been cancelled
Upload bundler test manifests to areweturboyet.com / Upload test results (push) Has been cancelled
Update React / create-pull-request (push) Has been cancelled
test-e2e-project-reset-cron / reset-test-project (push) Has been cancelled
Notify about the top 15 issues/PRs/feature requests (most reacted) in the last 90 days / run (push) Has been cancelled
97 lines
3.2 KiB
TypeScript
97 lines
3.2 KiB
TypeScript
import RefreshHelpers from './helpers'
|
|
|
|
declare const __webpack_require__: {
|
|
c: Record<string | number, { exports: unknown | (() => Promise<unknown>) }>
|
|
}
|
|
|
|
// Extracts exports from a webpack module object.
|
|
function getModuleExports(moduleId: string) {
|
|
if (typeof moduleId === 'undefined') {
|
|
// `moduleId` is unavailable, which indicates that this module is not in the cache,
|
|
// which means we won't be able to capture any exports,
|
|
// and thus they cannot be refreshed safely.
|
|
// These are likely runtime or dynamically generated modules.
|
|
return {}
|
|
}
|
|
|
|
var maybeModule = __webpack_require__.c[moduleId]
|
|
if (typeof maybeModule === 'undefined') {
|
|
// `moduleId` is available but the module in cache is unavailable,
|
|
// which indicates the module is somehow corrupted (e.g. broken Webpack `module` globals).
|
|
// We will warn the user (as this is likely a mistake) and assume they cannot be refreshed.
|
|
console.warn(
|
|
'[React Refresh] Failed to get exports for module: ' + moduleId + '.'
|
|
)
|
|
return {}
|
|
}
|
|
|
|
var exportsOrPromise = maybeModule.exports
|
|
if (typeof Promise !== 'undefined' && exportsOrPromise instanceof Promise) {
|
|
return exportsOrPromise.then(function (exports) {
|
|
return exports
|
|
})
|
|
}
|
|
return exportsOrPromise
|
|
}
|
|
|
|
function executeRuntime(moduleExports, moduleId, webpackHot) {
|
|
RefreshHelpers.registerExportsForReactRefresh(moduleExports, moduleId)
|
|
|
|
if (webpackHot) {
|
|
var isHotUpdate = !!webpackHot.data
|
|
var prevSignature: unknown[] | null = webpackHot.data?.prevSignature ?? null
|
|
|
|
if (RefreshHelpers.isReactRefreshBoundary(moduleExports)) {
|
|
webpackHot.dispose(
|
|
// Save the previous exports signature on update so we can compare the boundary
|
|
// signatures. We avoid saving exports themselves since it causes memory leaks (https://github.com/vercel/next.js/pull/53797)
|
|
function hotDisposeCallback(data) {
|
|
data.prevSignature =
|
|
RefreshHelpers.getRefreshBoundarySignature(moduleExports)
|
|
}
|
|
)
|
|
webpackHot.accept()
|
|
|
|
// This field is set when the previous version of this module was a
|
|
// Refresh Boundary, letting us know we need to check for invalidation or
|
|
// enqueue an update.
|
|
if (prevSignature !== null) {
|
|
if (isHotUpdate) {
|
|
if (
|
|
RefreshHelpers.shouldInvalidateReactRefreshBoundary(
|
|
prevSignature,
|
|
RefreshHelpers.getRefreshBoundarySignature(moduleExports)
|
|
)
|
|
) {
|
|
webpackHot.invalidate()
|
|
} else {
|
|
RefreshHelpers.scheduleUpdate()
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
if (isHotUpdate && prevSignature !== null) {
|
|
webpackHot.invalidate()
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
// Port from https://github.com/pmmmwh/react-refresh-webpack-plugin/blob/main/loader/utils/getRefreshModuleRuntime.js#L29
|
|
export function refresh(moduleId, webpackHot) {
|
|
const currentExports = getModuleExports(moduleId)
|
|
const fn = (exports) => {
|
|
executeRuntime(exports, moduleId, webpackHot)
|
|
}
|
|
if (typeof Promise !== 'undefined' && currentExports instanceof Promise) {
|
|
currentExports.then(fn)
|
|
} else {
|
|
fn(currentExports)
|
|
}
|
|
}
|
|
|
|
export {
|
|
register,
|
|
createSignatureFunctionForTransform,
|
|
} from 'react-refresh/runtime'
|