Skip to content

Commit

Permalink
Update package configuration for ESM compatibility
Browse files Browse the repository at this point in the history
- Update package.json with explicit ESM exports
- Modify tsconfig.json to use NodeNext module resolution
- Update import/export paths in source files to use .js extensions
- Bump version to 0.1.5
  • Loading branch information
lilac committed Feb 17, 2025
1 parent a7f8f38 commit 5a2eb6f
Show file tree
Hide file tree
Showing 10 changed files with 35 additions and 28 deletions.
12 changes: 9 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,16 @@
"name": "mysql-queue",
"description": "A lite job queue for Node.js",
"author": "lilac <[email protected]>",
"version": "0.1.4",
"version": "0.1.5",
"type": "module",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"main": "./dist/index.js",
"types": "./dist/index.d.ts",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
}
},
"files": [
"dist",
"README.md",
Expand Down
2 changes: 1 addition & 1 deletion src/db/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { MySql2Database, type MySqlRawQueryResult, drizzle } from "drizzle-orm/m
import { migrate } from "drizzle-orm/mysql2/migrator";
import mysql from "mysql2/promise";
import path from "node:path";
import * as schema from "./schema";
import * as schema from "./schema.js";

export type Database = MySql2Database<Record<string, unknown>>;

Expand Down
10 changes: 5 additions & 5 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
export { LiteQueue } from "./queue";
export { connect, migrateDB } from "./db";
export type { QueueOptions, RunnerOptions, RunnerFuncs } from "./options";
export { Runner } from "./runner";
export { LiteQueue } from "./queue.js";
export { connect, migrateDB } from "./db/index.js";
export type { QueueOptions, RunnerOptions, RunnerFuncs } from "./options.js";
export { Runner } from "./runner.js";

export type { DequeuedJob, DequeuedJobError } from "./types";
export type { DequeuedJob, DequeuedJobError } from "./types.js";
2 changes: 1 addition & 1 deletion src/options.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ZodType } from "zod";

import { DequeuedJob, DequeuedJobError } from "./types";
import { DequeuedJob, DequeuedJobError } from "./types.js";

export interface QueueOptions {
defaultJobArgs: {
Expand Down
6 changes: 3 additions & 3 deletions src/queue.test.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { describe, expect, test } from "vitest";

import {
LiteQueue
} from "./";
import { db } from "./test";
LiteQueue
} from "./index.js";
import { db } from "./test.js";

interface Work {
increment: number;
Expand Down
6 changes: 3 additions & 3 deletions src/queue.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import assert from "node:assert";
import { and, asc, count, eq, gt, lt, or, sql } from "drizzle-orm";

import { affectedRows, type Database } from "./db";
import { EnqueueOptions, QueueOptions } from "./options";
import { Job, tasksTable } from "./db/schema";
import { affectedRows, type Database } from "./db/index.js";
import { EnqueueOptions, QueueOptions } from "./options.js";
import { Job, tasksTable } from "./db/schema.js";

// generate random id
function generateAllocationId() {
Expand Down
6 changes: 3 additions & 3 deletions src/runner.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ import {
Runner,
RunnerOptions,
LiteQueue,
} from "./";
import { tasksTable } from "./db/schema";
import { db } from "./test";
} from "./index.js";
import { tasksTable } from "./db/schema.js";
import { db } from "./test.js";

class Baton {
semaphore: Semaphore;
Expand Down
8 changes: 4 additions & 4 deletions src/runner.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import assert from "node:assert";
import { Semaphore } from "async-mutex";

import { RunnerFuncs, RunnerOptions } from "./options";
import { LiteQueue } from "./queue";
import { Job } from "./db/schema";
import { DequeuedJob } from "./types";
import { RunnerFuncs, RunnerOptions } from "./options.js";
import { LiteQueue } from "./queue.js";
import { Job } from "./db/schema.js";
import { DequeuedJob } from "./types.js";

export class Runner<T> {
queue: LiteQueue<T>;
Expand Down
2 changes: 1 addition & 1 deletion src/test.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { connect, migrateDB } from "./db";
import { connect, migrateDB } from "./db/index.js";
import { env } from 'node:process';

const defaultUrl = env['DATABASE_URL'] ?? 'mysql://root:root@localhost:3306/queue'
Expand Down
9 changes: 5 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,20 +1,21 @@
{
{
"$schema": "https://json.schemastore.org/tsconfig",
"extends": "@tsconfig/node21/tsconfig.json",
"include": ["src"],
"exclude": ["node_modules", "build", "dist"],
"compilerOptions": {
"module": "ESNext",
"moduleResolution": "node",
"module": "NodeNext",
"moduleResolution": "NodeNext",
"outDir": "./dist",
"incremental": true,
"isolatedModules": true,
"strict": true,
"esModuleInterop": true,
"baseUrl": ".",
"paths": {
"@/*": ["./src/*"]
},
"tsBuildInfoFile": "node_modules/.cache/tsbuildinfo.json"
},
}
}

0 comments on commit 5a2eb6f

Please sign in to comment.