Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
ef9af41
Fix drizzle-zod
L-Mario564 Oct 21, 2025
885ebec
Rework build step for validator packages
L-Mario564 Oct 23, 2025
0932f0c
Rework drizzle-orm build
L-Mario564 Oct 24, 2025
790bd71
Merge remote-tracking branch 'upstream/alternation-engine' into rolldown
L-Mario564 Oct 24, 2025
1907471
Simplify builds
L-Mario564 Oct 24, 2025
87f4183
Revamp drizzle-seed build
L-Mario564 Oct 24, 2025
408b0b8
Fix drizzle-orm build
L-Mario564 Oct 24, 2025
68536b9
Rewrite build steps for drizzle-kit
L-Mario564 Oct 27, 2025
8cbacec
Merge remote-tracking branch 'upstream/alternation-engine' into rolldown
L-Mario564 Oct 27, 2025
30f0f8d
Update GH workflows
L-Mario564 Oct 28, 2025
b2f22db
Update Rolldown
L-Mario564 Oct 28, 2025
8776a83
Fixes
L-Mario564 Oct 28, 2025
e0cfed4
drizzle-seed fix
OleksiiKH0240 Oct 28, 2025
5913fca
Merge remote-tracking branch 'upstream/alternation-engine' into rolldown
L-Mario564 Oct 28, 2025
0851d5d
updated release-feature-branch.yaml to start singlestore docker for d…
OleksiiKH0240 Oct 28, 2025
eae475a
added all dbs required for drizzle-seed
OleksiiKH0240 Oct 28, 2025
38c3fd1
Fix exports
L-Mario564 Oct 29, 2025
9d2c11e
Merge branch 'rolldown' of https://github.com/L-Mario564/drizzle-orm …
L-Mario564 Oct 29, 2025
b686efa
Merge remote-tracking branch 'upstream/alternation-engine' into rolldown
L-Mario564 Oct 29, 2025
34b8a80
Strip internal types
L-Mario564 Oct 30, 2025
d474c90
Remove redundant ESM files in builds
L-Mario564 Oct 30, 2025
10d16fa
Update Rolldown config for ORM and Kit
L-Mario564 Oct 30, 2025
a8bc7b4
Merge branch 'alternation-engine' into rolldown
AlexBlokh Nov 4, 2025
c8830f7
Fix import in test file
L-Mario564 Nov 4, 2025
5c77ec9
Merge branch 'rolldown' of https://github.com/L-Mario564/drizzle-orm …
L-Mario564 Nov 4, 2025
b0d3207
Add entrypath
L-Mario564 Nov 4, 2025
c9040df
Remove ESLint files
L-Mario564 Nov 10, 2025
759af70
Merge branch 'alternation-engine' into rolldown
L-Mario564 Nov 11, 2025
071bd31
Merge remote-tracking branch 'upstream/alternation-engine' into rolldown
L-Mario564 Nov 11, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/release-feature-branch.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ jobs:
with: { run_install: false }
- uses: actions/setup-node@v6
with: { node-version: '24', registry-url: 'https://registry.npmjs.org', cache: 'pnpm', cache-dependency-path: pnpm-lock.yaml }
- uses: oven-sh/setup-bun@v2
with:
bun-version: 1.3.1
- run: pnpm install --frozen-lockfile --prefer-offline
- name: Compute version suffix
id: meta
Expand Down
5 changes: 5 additions & 0 deletions .github/workflows/release-latest.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,11 @@ jobs:
restore-keys: |
${{ runner.os }}-pnpm-store-

- uses: oven-sh/setup-bun@v2
name: Install Bun
with:
bun-version: 1.3.1

- name: Install dependencies
run: pnpm install

Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ rollup.config-*.mjs
drizzle-seed/src/dev
drizzle-orm/tmp
drizzle-orm/types-bench.ts
drizzle-orm/src/version.temp.ts
typeperf-test/tmp.tsconfig.json
typeperf-test/trace
typeperf-test/lib/big-schema.ts
Expand Down
Empty file modified .husky/pre-commit
100644 → 100755
Empty file.
94 changes: 94 additions & 0 deletions build/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,94 @@
import { $, Glob } from 'bun';
import { rm } from 'fs/promises';
import { availableParallelism, FixedThreadPool } from 'poolifier-web-worker';

export type WorkerIn = {
name: string;
content: string;
extension: string;
}[];

export type WorkerOut = {
name: string;
code: string;
}[];

export async function build(config: {
readme: string;
skip?: {
distDelete?: boolean;
resolveTsPaths?: boolean;
};
customPackageJsonExports?: Record<string, any>;
}) {
if (!config.skip?.distDelete) await rm('dist', { recursive: true, force: true });
await $`rolldown --config rolldown.config.ts`;
if (!config.skip?.resolveTsPaths) await $`resolve-tspaths`;

await Promise.all([
Bun.write('dist/README.md', Bun.file(config.readme)),
Bun.write('dist/package.json', Bun.file('package.json')),
]);
if (config.customPackageJsonExports) {
const pkg = await Bun.file('dist/package.json').json();
pkg.exports = config.customPackageJsonExports;
await Bun.write('dist/package.json', JSON.stringify(pkg, null, 2));
}

const declarationFilesGlob = new Glob('**/*.d.ts');
for await (const file of declarationFilesGlob.scan('./dist')) {
const ctsFileName = file.replace(/\.d\.ts$/, '.d.cts');
await Bun.write(`dist/${ctsFileName}`, Bun.file(`dist/${file}`));
}

const [cjsFiles, jsFiles, mjsFiles] = await Promise.all([
getFilesFromGlob('**/*.{cjs,d.cts}'),
getFilesFromGlob('**/*.{js,d.ts}'),
getFilesFromGlob('**/*.{mjs,d.mts}'),
]);
const parallelism = availableParallelism();
const allFiles = splitArray([
...cjsFiles.map(({ content, name }) => ({ content, name, extension: '.cjs' })),
...jsFiles.map(({ content, name }) => ({ content, name, extension: '.js' })),
...mjsFiles.map(({ content, name }) => ({ content, name, extension: '.mjs' })),
], parallelism);

const pool = new FixedThreadPool<WorkerIn, WorkerOut>(
parallelism,
new URL('./worker.ts', import.meta.url),
{
errorEventHandler: (err) => {
console.error('Worker error:', err);
process.exit(1);
},
},
);
const writeFiles = await pool.mapExecute(allFiles);
await pool.destroy();
await Promise.all(writeFiles.flat(1).map(async ({ code, name }) => await Bun.write(name, code)));
}

async function getFilesFromGlob(pattern: string) {
const files = await Array.fromAsync(new Glob(pattern).scan('./dist'));
return await Promise.all(files.map(async (file) => ({
content: await Bun.file(`dist/${file}`).text(),
name: `dist/${file}`,
})));
}

function splitArray<T>(array: T[], parts: number): T[][] {
const result: T[][] = [];
const len = array.length;
const baseSize = Math.floor(len / parts);
const remainder = len % parts;

let start = 0;
for (let i = 0; i < parts; i++) {
const extra = i < remainder ? 1 : 0;
const end = start + baseSize + extra;
result.push(array.slice(start, end));
start = end;
}

return result;
}
99 changes: 99 additions & 0 deletions build/worker.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
import MagicString from 'magic-string';
import path from 'node:path';
import { parseSync, Visitor } from 'oxc-parser';
import { ThreadWorker } from 'poolifier-web-worker';
import type { WorkerIn, WorkerOut } from '.';

export default new ThreadWorker<WorkerIn, WorkerOut>(async (data) => {
if (!data) return [];
const files: WorkerOut = [];

for (const { content, name, extension } of data) {
const code = parseSync(name, content);
const magic = new MagicString(content);

const visitor = new Visitor({
ImportDeclaration(node) {
magic.overwrite(
node.source.start + 1,
node.source.end - 1,
fixImportPath(magic.slice(node.source.start + 1, node.source.end - 1), name, extension),
);
},
// visitExportAllDeclaration(path) {
// path.value.source.value = fixImportPath(path.value.source.value, name, extension);
// this.traverse(path);
// },
// visitExportNamedDeclaration(path) {
// if (path.value.source) {
// path.value.source.value = fixImportPath(path.value.source.value, name, extension);
// }
// this.traverse(path);
// },
CallExpression(node) {
if (node.callee.type === 'Identifier' && node.callee.name === 'require' && (node.arguments[0] as any)?.value) {
magic.overwrite(
node.arguments[0]!.start + 1,
node.arguments[0]!.end - 1,
fixImportPath(magic.slice(node.arguments[0]!.start + 1, node.arguments[0]!.end - 1), name, extension),
);
}
},
// visitTSImportType(path) {
// path.value.argument.value = resolvePathAlias(path.value.argument.value, name);
// this.traverse(path);
// },
AwaitExpression(node) {
const nodeStr = magic.slice(node.start, node.end);
if (nodeStr.startsWith(`await import(`)) {
const fullImportPath = magic.slice(node.start, node.end);
let importPath = magic.slice(node.start + 'await import('.length + 1, node.end - 2);

if (nodeStr.includes('./')) {
importPath = fixImportPath(
importPath,
name,
extension,
);
}

const statement = fullImportPath.includes('await import(') && extension === '.cjs'
? 'require('
: 'await import(';
magic.overwrite(
node.start,
node.end,
`${statement}"${importPath}")`,
);
}
},
});

visitor.visit(code.program);
files.push({
code: magic.toString(),
name,
});
}

return files;
});

function resolvePathAlias(importPath: string, file: string) {
if (importPath.startsWith('~/')) {
const relativePath = path.relative(path.dirname(file), path.resolve('dist', importPath.slice(2)));
importPath = relativePath.startsWith('.') ? relativePath : './' + relativePath;
}

return importPath;
}

function fixImportPath(importPath: string, file: string, ext: string) {
importPath = resolvePathAlias(importPath, file);

if (!/\..*\.(js|ts|cjs|cts|mjs|mts)$/.test(importPath)) {
return importPath;
}

return importPath.replace(/\.(js|ts|cjs|cts|mjs|mts)$/, ext);
}
24 changes: 8 additions & 16 deletions drizzle-arktype/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,32 +4,30 @@
"description": "Generate arktype schemas from Drizzle ORM schemas",
"type": "module",
"scripts": {
"build": "tsx scripts/build.ts",
"build": "bun scripts/build.ts",
"build:artifact": "pnpm run build",
"b": "pnpm build",
"test:types": "cd tests && tsc",
"pack": "(cd dist && npm pack --pack-destination ..) && rm -f package.tgz && mv *.tgz package.tgz",
"pack:artifact": "pnpm run pack",
"publish": "npm publish package.tgz",
"test": "vitest run",
"bench:types": "tsx ./benchmarks/types.ts"
"bench:types": "bun ./benchmarks/types.ts"
},
"exports": {
".": {
"import": {
"types": "./index.d.mts",
"default": "./index.mjs"
"types": "./index.d.ts",
"default": "./index.js"
},
"require": {
"types": "./index.d.cjs",
"types": "./index.d.cts",
"default": "./index.cjs"
},
"types": "./index.d.ts",
"default": "./index.mjs"
}
}
},
"main": "./index.cjs",
"module": "./index.mjs",
"module": "./index.js",
"types": "./index.d.ts",
"publishConfig": {
"provenance": true
Expand Down Expand Up @@ -63,15 +61,9 @@
},
"devDependencies": {
"@ark/attest": "^0.45.8",
"@rollup/plugin-typescript": "^11.1.0",
"@types/node": "^18.15.10",
"arktype": "^2.1.10",
"cpy": "^10.1.0",
"drizzle-orm": "link:../drizzle-orm/dist",
"json-rules-engine": "7.3.1",
"rimraf": "^5.0.0",
"rollup": "^3.29.5",
"tsx": "^4.19.3",
"zx": "^7.2.2"
"json-rules-engine": "7.3.1"
}
}
41 changes: 41 additions & 0 deletions drizzle-arktype/rolldown.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { defineConfig, type RolldownOptions } from 'rolldown';
import { dts } from 'rolldown-plugin-dts';

const common: RolldownOptions = {
input: 'src/index.ts',
external: [
/^drizzle-orm\/?/,
'arktype',
],
tsconfig: 'tsconfig.build.json',
};

export default defineConfig([
{
...common,
output: [
{
format: 'esm',
dir: 'dist',
entryFileNames: '[name].js',
chunkFileNames: '[name]-[hash].js',
sourcemap: true,
},
],
plugins: [dts({
tsconfig: 'tsconfig.build.json',
})],
},
{
...common,
output: [
{
format: 'cjs',
dir: 'dist',
entryFileNames: '[name].cjs',
chunkFileNames: '[name]-[hash].cjs',
sourcemap: true,
},
],
},
]);
33 changes: 0 additions & 33 deletions drizzle-arktype/rollup.config.ts

This file was deleted.

17 changes: 3 additions & 14 deletions drizzle-arktype/scripts/build.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,5 @@
#!/usr/bin/env -S pnpm tsx
import 'zx/globals';
import cpy from 'cpy';
import { build } from '~build';

await fs.remove('dist');
await $`rollup --config rollup.config.ts --configPlugin typescript`;
await $`resolve-tspaths`;
await fs.copy('README.md', 'dist/README.md');
await cpy('dist/**/*.d.ts', 'dist', {
rename: (basename) => basename.replace(/\.d\.ts$/, '.d.mts'),
await build({
readme: 'README.md',
});
await cpy('dist/**/*.d.ts', 'dist', {
rename: (basename) => basename.replace(/\.d\.ts$/, '.d.cts'),
});
await fs.copy('package.json', 'dist/package.json');
await $`scripts/fix-imports.ts`;
Loading
Loading