mirror of
https://github.com/zoriya/drizzle-otel.git
synced 2026-05-31 10:13:22 +00:00
clean up build
This commit is contained in:
@@ -1,70 +0,0 @@
|
||||
import { stat } from "node:fs/promises";
|
||||
import type { Plugin } from "esbuild";
|
||||
import { build } from "esbuild";
|
||||
|
||||
const MINIFY = true;
|
||||
const SOURCEMAP = true;
|
||||
|
||||
const MAX_SIZE = 50_000; // 50KB max for instrumentation package
|
||||
|
||||
type ExternalPluginFactory = (external: string[]) => Plugin;
|
||||
const externalCjsToEsmPlugin: ExternalPluginFactory = (external) => ({
|
||||
name: "external",
|
||||
setup(builder): void {
|
||||
const escape = (text: string): string =>
|
||||
`^${text.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")}$`;
|
||||
const filter = new RegExp(external.map(escape).join("|"));
|
||||
builder.onResolve({ filter: /.*/, namespace: "external" }, (args) => ({
|
||||
path: args.path,
|
||||
external: true,
|
||||
}));
|
||||
builder.onResolve({ filter }, (args) => ({
|
||||
path: args.path,
|
||||
namespace: "external",
|
||||
}));
|
||||
builder.onLoad({ filter: /.*/, namespace: "external" }, (args) => ({
|
||||
contents: `export * from ${JSON.stringify(args.path)}`,
|
||||
}));
|
||||
},
|
||||
});
|
||||
|
||||
/** Adds support for require, __filename, and __dirname to ESM / Node. */
|
||||
const esmNodeSupportBanner = {
|
||||
js: `import { fileURLToPath } from 'url';
|
||||
import { createRequire as topLevelCreateRequire } from 'module';
|
||||
import _nPath from 'path'
|
||||
const require = topLevelCreateRequire(import.meta.url);
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = _nPath.dirname(__filename);`,
|
||||
};
|
||||
|
||||
const peerDependencies = ["@opentelemetry/api", "better-auth"];
|
||||
|
||||
async function buildAll(): Promise<void> {
|
||||
await build({
|
||||
platform: "node",
|
||||
format: "esm",
|
||||
splitting: false,
|
||||
entryPoints: ["src/index.ts"],
|
||||
outdir: "dist",
|
||||
bundle: true,
|
||||
minify: MINIFY,
|
||||
sourcemap: SOURCEMAP,
|
||||
banner: esmNodeSupportBanner,
|
||||
external: peerDependencies,
|
||||
plugins: [externalCjsToEsmPlugin(peerDependencies)],
|
||||
});
|
||||
|
||||
// Check max size.
|
||||
const outputFile = "dist/index.js";
|
||||
const s = await stat(outputFile);
|
||||
if (s.size > MAX_SIZE) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(
|
||||
`${outputFile}: the size of ${s.size} is over the maximum allowed size of ${MAX_SIZE}`,
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void buildAll();
|
||||
@@ -29,9 +29,7 @@
|
||||
"node": "^18.19.0 || >=20.6.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "pnpm clean && pnpm build-only && pnpm build-types",
|
||||
"build-only": "pnpm tsx build.ts",
|
||||
"build-types": "tsc --skipLibCheck --noEmit false --declaration --emitDeclarationOnly --stripInternal --declarationDir dist/types src/index.ts",
|
||||
"build": "pnpm clean && tsc",
|
||||
"clean": "rimraf dist",
|
||||
"prepublishOnly": "pnpm build",
|
||||
"type-check": "tsc --noEmit",
|
||||
@@ -45,9 +43,7 @@
|
||||
"@opentelemetry/sdk-trace-node": "^1.28.0",
|
||||
"@types/node": "18.15.11",
|
||||
"better-auth": "^1.0.0",
|
||||
"esbuild": "^0.19.4",
|
||||
"rimraf": "3.0.2",
|
||||
"tsx": "^4.6.2",
|
||||
"typescript": "^5",
|
||||
"vitest": "0.33.0"
|
||||
},
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"resolveJsonModule": true,
|
||||
"incremental": true,
|
||||
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json"
|
||||
"declarationDir": "dist/types",
|
||||
"stripInternal": true
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist", "**/*.test.ts"]
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
import { stat } from "node:fs/promises";
|
||||
import type { Plugin } from "esbuild";
|
||||
import { build } from "esbuild";
|
||||
|
||||
const MINIFY = true;
|
||||
const SOURCEMAP = true;
|
||||
|
||||
const MAX_SIZE = 50_000; // 50KB max for instrumentation package
|
||||
|
||||
type ExternalPluginFactory = (external: string[]) => Plugin;
|
||||
const externalCjsToEsmPlugin: ExternalPluginFactory = (external) => ({
|
||||
name: "external",
|
||||
setup(builder): void {
|
||||
const escape = (text: string): string =>
|
||||
`^${text.replace(/[-/\\^$*+?.()|[\]{}]/g, "\\$&")}$`;
|
||||
const filter = new RegExp(external.map(escape).join("|"));
|
||||
builder.onResolve({ filter: /.*/, namespace: "external" }, (args) => ({
|
||||
path: args.path,
|
||||
external: true,
|
||||
}));
|
||||
builder.onResolve({ filter }, (args) => ({
|
||||
path: args.path,
|
||||
namespace: "external",
|
||||
}));
|
||||
builder.onLoad({ filter: /.*/, namespace: "external" }, (args) => ({
|
||||
contents: `export * from ${JSON.stringify(args.path)}`,
|
||||
}));
|
||||
},
|
||||
});
|
||||
|
||||
/** Adds support for require, __filename, and __dirname to ESM / Node. */
|
||||
const esmNodeSupportBanner = {
|
||||
js: `import { fileURLToPath } from 'url';
|
||||
import { createRequire as topLevelCreateRequire } from 'module';
|
||||
import _nPath from 'path'
|
||||
const require = topLevelCreateRequire(import.meta.url);
|
||||
const __filename = fileURLToPath(import.meta.url);
|
||||
const __dirname = _nPath.dirname(__filename);`,
|
||||
};
|
||||
|
||||
const peerDependencies = ["@opentelemetry/api", "drizzle-orm"];
|
||||
|
||||
async function buildAll(): Promise<void> {
|
||||
await build({
|
||||
platform: "node",
|
||||
format: "esm",
|
||||
splitting: false,
|
||||
entryPoints: ["src/index.ts"],
|
||||
outdir: "dist",
|
||||
bundle: true,
|
||||
minify: MINIFY,
|
||||
sourcemap: SOURCEMAP,
|
||||
banner: esmNodeSupportBanner,
|
||||
external: peerDependencies,
|
||||
plugins: [externalCjsToEsmPlugin(peerDependencies)],
|
||||
});
|
||||
|
||||
// Check max size.
|
||||
const outputFile = "dist/index.js";
|
||||
const s = await stat(outputFile);
|
||||
if (s.size > MAX_SIZE) {
|
||||
// eslint-disable-next-line no-console
|
||||
console.error(
|
||||
`${outputFile}: the size of ${s.size} is over the maximum allowed size of ${MAX_SIZE}`,
|
||||
);
|
||||
process.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
void buildAll();
|
||||
@@ -29,9 +29,7 @@
|
||||
"node": "^18.19.0 || >=20.6.0"
|
||||
},
|
||||
"scripts": {
|
||||
"build": "pnpm clean && pnpm build-only && pnpm build-types",
|
||||
"build-only": "pnpm tsx build.ts",
|
||||
"build-types": "tsc --noEmit false --declaration --emitDeclarationOnly --stripInternal --declarationDir dist/types src/index.ts",
|
||||
"build": "pnpm clean && tsc",
|
||||
"clean": "rimraf dist",
|
||||
"prepublishOnly": "pnpm build",
|
||||
"type-check": "tsc --noEmit",
|
||||
@@ -45,10 +43,8 @@
|
||||
"@types/node": "18.15.11",
|
||||
"@types/pg": "^8.11.10",
|
||||
"drizzle-orm": "^0.36.4",
|
||||
"esbuild": "^0.19.4",
|
||||
"postgres": "^3.4.5",
|
||||
"rimraf": "3.0.2",
|
||||
"tsx": "^4.6.2",
|
||||
"typescript": "^5",
|
||||
"vitest": "0.33.0"
|
||||
},
|
||||
|
||||
@@ -13,8 +13,8 @@
|
||||
"skipLibCheck": true,
|
||||
"forceConsistentCasingInFileNames": true,
|
||||
"resolveJsonModule": true,
|
||||
"incremental": true,
|
||||
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json"
|
||||
"declarationDir": "dist/types",
|
||||
"stripInternal": true
|
||||
},
|
||||
"include": ["src/**/*"],
|
||||
"exclude": ["node_modules", "dist", "**/*.test.ts"]
|
||||
|
||||
Reference in New Issue
Block a user