sliftutils 1.7.35 → 1.7.37

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/index.d.ts CHANGED
@@ -3353,6 +3353,10 @@ declare module "sliftutils/storage/remoteStorage/intermediateSources" {
3353
3353
 
3354
3354
  }
3355
3355
 
3356
+ declare module "sliftutils/storage/remoteStorage/productionEnv" {
3357
+
3358
+ }
3359
+
3356
3360
  declare module "sliftutils/storage/remoteStorage/remoteConfig" {
3357
3361
  /// <reference types="node" />
3358
3362
  /// <reference types="node" />
@@ -3553,6 +3557,7 @@ declare module "sliftutils/storage/remoteStorage/storageController" {
3553
3557
  }
3554
3558
 
3555
3559
  declare module "sliftutils/storage/remoteStorage/storageServer" {
3560
+ import "./productionEnv";
3556
3561
  import "./accessPage";
3557
3562
  export type HostStorageServerConfig = {
3558
3563
  url: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "sliftutils",
3
- "version": "1.7.35",
3
+ "version": "1.7.37",
4
4
  "main": "index.js",
5
5
  "license": "MIT",
6
6
  "files": [
File without changes
@@ -0,0 +1,2 @@
1
+ // Packages like mobx pick which build to require at runtime, from process.env.NODE_ENV. The browser require shim runs as production, so a server that loads the development build ships a module graph the client cannot satisfy ("Accessed unexpected module ./mobx.cjs.production.min.js ... Expected imports: ./mobx.cjs.development.js"). Setting this is the only way to make both sides agree, and it MUST happen before anything imports such a package - which is why it lives in its own module, imported first (import statements run in source order, so a plain statement at the top of storageServer.ts would run too late).
2
+ process.env.NODE_ENV = "production";
@@ -1,3 +1,4 @@
1
+ import "./productionEnv";
1
2
  import "./accessPage";
2
3
  export type HostStorageServerConfig = {
3
4
  url: string;
@@ -1,3 +1,5 @@
1
+ // Must stay the FIRST import: it sets NODE_ENV, which decides which build of mobx (and anything else that switches on it) the imports below load
2
+ import "./productionEnv";
1
3
  import os from "os";
2
4
  import path from "path";
3
5
  import fsp from "fs/promises";
@@ -89,8 +91,10 @@ export async function hostStorageServer(config: HostStorageServerConfig): Promis
89
91
  SocketFunction.expose(RequireController);
90
92
  SocketFunction.expose(RemoteStorageController);
91
93
  // Every HTTP path goes through httpEntry: /file/<account>/<bucketName>/... serves public bucket files, everything else serves the access page (the path is the account name, see accessPage.tsx). A full URL, so the page resolves modules from the origin root even when served at /accountName (a relative require would resolve inside the account path).
94
+ // The module path is resolved server-side against its working directory, which is the HOST application's folder - so it is computed from where this file actually is, instead of assuming the storage server runs from inside sliftutils (in a host app it lives under node_modules/sliftutils).
95
+ let accessPagePath = "./" + path.relative(process.cwd(), path.join(__dirname, "accessPage.tsx")).replaceAll("\\", "/");
92
96
  SocketFunction.setDefaultHTTPCall(RemoteStorageController, "httpEntry", {
93
- requireCalls: [`https://${domain}:${port}/./storage/remoteStorage/accessPage.tsx`],
97
+ requireCalls: [`https://${domain}:${port}/${accessPagePath}`],
94
98
  });
95
99
 
96
100
  // Initial check so a server starting under-limit immediately rejects writes; then keep checking every 15 minutes so recovery (freed disk space) is picked up automatically.
@@ -1,4 +1,3 @@
1
- process.env.NODE_ENV = "production";
2
1
  import { hostStorageServer } from "./storageServer";
3
2
  import { getArg } from "./cliArgs";
4
3