Track HiveGrid Cloud planning reference
This commit is contained in:
1 parent
b3d5ea6764
commit
e341c5938a
5784 files changed
+1104929
-3
No files matched your search
@@ -0,0 +1,72 @@
|
||||
import { mkdir } from "node:fs/promises";
|
||||
import { builtinModules } from "node:module";
|
||||
import path from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
import { build } from "esbuild";
|
||||
|
||||
const appDir = path.resolve(path.dirname(fileURLToPath(import.meta.url)), "..");
|
||||
const entryPoint = path.join(appDir, "src/index.ts");
|
||||
const outputFile = path.join(appDir, "dist/index.js");
|
||||
const nodeBuiltins = new Set([...builtinModules, ...builtinModules.map((moduleName) => `node:${moduleName}`)]);
|
||||
|
||||
const externalizeRuntimeDependencies = {
|
||||
name: "externalize-runtime-dependencies",
|
||||
setup(buildContext) {
|
||||
buildContext.onResolve({ filter: /.*/ }, (args) => {
|
||||
if (nodeBuiltins.has(args.path)) {
|
||||
return { path: args.path, external: true };
|
||||
}
|
||||
if (isExternalRuntimePackage(args.path)) {
|
||||
return { path: args.path, external: true };
|
||||
}
|
||||
return undefined;
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
await mkdir(path.dirname(outputFile), { recursive: true });
|
||||
|
||||
await build({
|
||||
entryPoints: [entryPoint],
|
||||
outfile: outputFile,
|
||||
bundle: true,
|
||||
platform: "node",
|
||||
format: "esm",
|
||||
target: "node20",
|
||||
sourcemap: true,
|
||||
banner: {
|
||||
js: 'import { createRequire as __toolctrlCreateRequire } from "node:module"; const require = __toolctrlCreateRequire(import.meta.url);',
|
||||
},
|
||||
plugins: [externalizeRuntimeDependencies],
|
||||
logLevel: "warning",
|
||||
});
|
||||
|
||||
function isBarePackageSpecifier(specifier) {
|
||||
return !specifier.startsWith(".") && !specifier.startsWith("/") && !specifier.startsWith("#");
|
||||
}
|
||||
|
||||
function isExternalRuntimePackage(specifier) {
|
||||
if (!isBarePackageSpecifier(specifier)) {
|
||||
return false;
|
||||
}
|
||||
// Hocuspocus + Y.js + Prisma + native pino are required at runtime
|
||||
// and never bundled — they ship as part of node_modules.
|
||||
return (
|
||||
specifier.startsWith("@hocuspocus/") ||
|
||||
specifier === "yjs" ||
|
||||
specifier.startsWith("yjs/") ||
|
||||
specifier === "y-protocols" ||
|
||||
specifier.startsWith("y-protocols/") ||
|
||||
specifier === "jsonwebtoken" ||
|
||||
specifier.startsWith("jsonwebtoken/") ||
|
||||
specifier === "@prisma/client" ||
|
||||
specifier.startsWith("@prisma/client/") ||
|
||||
specifier === "@prisma/adapter-pg" ||
|
||||
specifier.startsWith("@prisma/adapter-pg/") ||
|
||||
specifier === "pino" ||
|
||||
specifier.startsWith("pino/") ||
|
||||
specifier === "ws" ||
|
||||
specifier === "lib0" ||
|
||||
specifier.startsWith("lib0/")
|
||||
);
|
||||
}
|
||||
Reference in new issue
Block a user