Skip to content

Commit

Permalink
bump react
Browse files Browse the repository at this point in the history
  • Loading branch information
huozhi committed Aug 26, 2022
1 parent 1c3da4a commit 4736696
Show file tree
Hide file tree
Showing 7 changed files with 129 additions and 73 deletions.
4 changes: 2 additions & 2 deletions package.json
Expand Up @@ -177,8 +177,8 @@
"react-17": "npm:react@17.0.2",
"react-dom": "18.2.0",
"react-dom-17": "npm:react-dom@17.0.2",
"react-dom-exp": "npm:react-dom@0.0.0-experimental-c8b778b7f-20220825",
"react-exp": "npm:react@0.0.0-experimental-c8b778b7f-20220825",
"react-dom-exp": "npm:react-dom@0.0.0-experimental-0de3ddf56-20220825",
"react-exp": "npm:react@0.0.0-experimental-0de3ddf56-20220825",
"react-ssr-prepass": "1.0.8",
"react-virtualized": "9.22.3",
"relay-compiler": "13.0.2",
Expand Down
Expand Up @@ -189,13 +189,24 @@ function processSymbolChunk(request, id, name) {
// eslint-disable-next-line no-unused-vars
var MODULE_TAG = Symbol.for('react.module.reference');
function getModuleKey(reference) {
return reference.filepath + '#' + reference.name;
return reference.filepath + '#' + reference.name + (reference.async ? '#async' : '');
}
function isModuleReference(reference) {
return reference.$$typeof === MODULE_TAG;
}
function resolveModuleMetaData(config, moduleReference) {
return config[moduleReference.filepath][moduleReference.name];
var resolvedModuleData = config[moduleReference.filepath][moduleReference.name];

if (moduleReference.async) {
return {
id: resolvedModuleData.id,
chunks: resolvedModuleData.chunks,
name: resolvedModuleData.name,
async: true
};
} else {
return resolvedModuleData;
}
}

// ATTENTION
Expand Down

Large diffs are not rendered by default.

Expand Up @@ -36,7 +36,18 @@ function parseModel(response, json) {
// eslint-disable-next-line no-unused-vars
function resolveModuleReference(bundlerConfig, moduleData) {
if (bundlerConfig) {
return bundlerConfig[moduleData.id][moduleData.name];
var resolvedModuleData = bundlerConfig[moduleData.id][moduleData.name];

if (moduleData.async) {
return {
id: resolvedModuleData.id,
chunks: resolvedModuleData.chunks,
name: resolvedModuleData.name,
async: true
};
} else {
return resolvedModuleData;
}
}

return moduleData;
Expand All @@ -45,11 +56,13 @@ function resolveModuleReference(bundlerConfig, moduleData) {
// in Webpack but unfortunately it's not exposed so we have to
// replicate it in user space. null means that it has already loaded.

var chunkCache = new Map(); // Start preloading the modules since we might need them soon.
var chunkCache = new Map();
var asyncModuleCache = new Map(); // Start preloading the modules since we might need them soon.
// This function doesn't suspend.

function preloadModule(moduleData) {
var chunks = moduleData.chunks;
var promises = [];

for (var i = 0; i < chunks.length; i++) {
var chunkId = chunks[i];
Expand All @@ -58,31 +71,62 @@ function preloadModule(moduleData) {
if (entry === undefined) {
var thenable = globalThis.__next_chunk_load__(chunkId);

promises.push(thenable);
var resolve = chunkCache.set.bind(chunkCache, chunkId, null);
var reject = chunkCache.set.bind(chunkCache, chunkId);
thenable.then(resolve, reject);
chunkCache.set(chunkId, thenable);
}
}

if (moduleData.async) {
var modulePromise = Promise.all(promises).then(function () {
return globalThis.__next_require__(moduleData.id);
});
modulePromise.then(function (value) {
modulePromise.status = 'fulfilled';
modulePromise.value = value;
}, function (reason) {
modulePromise.status = 'rejected';
modulePromise.reason = reason;
});
asyncModuleCache.set(moduleData.id, modulePromise);
}
} // Actually require the module or suspend if it's not yet ready.
// Increase priority if necessary.

function requireModule(moduleData) {
var chunks = moduleData.chunks;
var moduleExports;

if (moduleData.async) {
// We assume that preloadModule has been called before, which
// should have added something to the module cache.
var promise = asyncModuleCache.get(moduleData.id);

if (promise.status === 'fulfilled') {
moduleExports = promise.value;
} else if (promise.status === 'rejected') {
throw promise.reason;
} else {
throw promise;
}
} else {
var chunks = moduleData.chunks;

for (var i = 0; i < chunks.length; i++) {
var chunkId = chunks[i];
var entry = chunkCache.get(chunkId);
for (var i = 0; i < chunks.length; i++) {
var chunkId = chunks[i];
var entry = chunkCache.get(chunkId);

if (entry !== null) {
// We assume that preloadModule has been called before.
// So we don't expect to see entry being undefined here, that's an error.
// Let's throw either an error or the Promise.
throw entry;
if (entry !== null) {
// We assume that preloadModule has been called before.
// So we don't expect to see entry being undefined here, that's an error.
// Let's throw either an error or the Promise.
throw entry;
}
}
}

var moduleExports = globalThis.__next_require__(moduleData.id);
moduleExports = globalThis.__next_require__(moduleData.id);
}

if (moduleData.name === '*') {
// This is a placeholder value that represents that the caller imported this
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion packages/next/package.json
Expand Up @@ -244,7 +244,7 @@
"raw-body": "2.4.1",
"react-is": "17.0.2",
"react-refresh": "0.12.0",
"react-server-dom-webpack": "0.0.0-experimental-c8b778b7f-20220825",
"react-server-dom-webpack": "0.0.0-experimental-0de3ddf56-20220825",
"regenerator-runtime": "0.13.4",
"sass-loader": "12.4.0",
"schema-utils2": "npm:schema-utils@2.7.1",
Expand Down
34 changes: 17 additions & 17 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 4736696

Please sign in to comment.