socket-function 0.12.5 → 0.12.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json
CHANGED
|
@@ -36,6 +36,7 @@ declare global {
|
|
|
36
36
|
interface Window {
|
|
37
37
|
clientsideBootTime: number;
|
|
38
38
|
}
|
|
39
|
+
var suppressUnexpectedModuleWarning: boolean;
|
|
39
40
|
}
|
|
40
41
|
|
|
41
42
|
export interface SerializedModule {
|
|
@@ -108,6 +109,9 @@ class RequireControllerBase {
|
|
|
108
109
|
}
|
|
109
110
|
if (requireCalls) {
|
|
110
111
|
async function requireAll(calls: string[]) {
|
|
112
|
+
// NOTE: awaiting isn't just for better and consistent load order, it also greatly improves load efficiency,
|
|
113
|
+
// as parallel calls can't know what files will be loaded, so there is a lot of duplicate loading. Loading
|
|
114
|
+
// 1 at a time allows require to efficiently require only files that previous imports haven't loaded.
|
|
111
115
|
for (let call of calls) {
|
|
112
116
|
try {
|
|
113
117
|
await require(call);
|
package/require/require.js
CHANGED
|
@@ -233,6 +233,7 @@
|
|
|
233
233
|
// TODO: Maybe do a request, making this async, if it isn't found?
|
|
234
234
|
return serializedModule.requests[request];
|
|
235
235
|
};
|
|
236
|
+
let moduleFolder = module.filename.replace(/\\/g, "/").split("/").slice(0, -1).join("/") + "/";
|
|
236
237
|
return require;
|
|
237
238
|
function require(request, asyncIsFine) {
|
|
238
239
|
if (asyncIsFineOuter) {
|
|
@@ -250,12 +251,18 @@
|
|
|
250
251
|
resolvedPath = request;
|
|
251
252
|
} else {
|
|
252
253
|
if (!(request in serializedModule.requests)) {
|
|
253
|
-
if (!asyncIsFine) {
|
|
254
|
+
if (!asyncIsFine && !globalThis.suppressUnexpectedModuleWarning) {
|
|
254
255
|
console.warn(`Accessed unexpected module %c${request}%c in %c${module.id}%c\n\tTreating it as an async require.\n\tAll modules require synchronously clientside must be required serverside at a module level.`,
|
|
255
256
|
"color: red", "color: unset",
|
|
256
257
|
"color: red", "color: unset",
|
|
257
258
|
);
|
|
258
259
|
}
|
|
260
|
+
// NOTE: We should still namespace it to the current folder (if it is a relative path),
|
|
261
|
+
// otherwise relative async imports won't work!
|
|
262
|
+
// (This path isn't hit often, as we usually preload, but... sometimes we won't).
|
|
263
|
+
if (request.startsWith(".")) {
|
|
264
|
+
request = moduleFolder + request;
|
|
265
|
+
}
|
|
259
266
|
return rootRequire(request);
|
|
260
267
|
}
|
|
261
268
|
|