Skip to content

Commit

Permalink
Merge branch 'main' into disco-jsr-bun-compat
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholasgriffintn committed Mar 14, 2024
2 parents b726de2 + 0b0dfb6 commit e795149
Show file tree
Hide file tree
Showing 10 changed files with 80 additions and 22 deletions.
3 changes: 2 additions & 1 deletion .npmignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,5 @@ coverage
examples
test
public
.nyc_output
.nyc_output
scripts
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

23 changes: 15 additions & 8 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,18 +1,25 @@
{
"name": "sqs-consumer",
"version": "9.1.0",
"version": "10.0.0-canary.2",
"description": "Build SQS-based Node applications without the boilerplate",
"type": "module",
"main": "dist/index.js",
"exports": "./dist/index.js",
"types": "dist/index.d.ts",
"exports": {
".": {
"types": "./dist/types/index.d.ts",
"require": "./dist/cjs/index.js",
"import": "./dist/esm/index.js",
"default": "./dist/esm/index.js"
}
},
"engines": {
"node": ">=18.0.0"
},
"scripts": {
"build": "npm run clean && tsc",
"watch": "tsc --watch",
"clean": "rm -fr dist/*",
"compile": "tsc -b ./tsconfig.cjs.json ./tsconfig.esm.json",
"add-package-jsons": "node ./scripts/addPackageJsons.js",
"build": "npm run clean && npm run compile && npm run add-package-jsons",
"watch": "tsc --watch",
"prepublishOnly": "npm run build",
"test:unit": "mocha --recursive --full-trace --exit",
"pretest:integration:init": "npm run build",
Expand Down Expand Up @@ -43,7 +50,7 @@
],
"license": "Apache-2.0",
"publishConfig": {
"provenance": true
"provenance": false
},
"release": {
"branches": [
Expand Down Expand Up @@ -207,4 +214,4 @@
]
}
}
}
}
31 changes: 31 additions & 0 deletions scripts/addPackageJsons.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
import { readdir, existsSync, writeFile } from "fs";
import { join } from "path";

const buildDir = "./dist";
function buildPackageJson() {
readdir(buildDir, (err, dirs) => {
if (err) {
throw err;
}
dirs.forEach((dir) => {
const packageJsonFile = join(buildDir, dir, "/package.json");

if (!existsSync(packageJsonFile)) {
const value =
dir === "esm" ? '{"type": "module"}' : '{"type": "commonjs"}';

writeFile(
packageJsonFile,
new Uint8Array(Buffer.from(value)),
(err) => {
if (err) {
throw err;
}
},
);
}
});
});
}

buildPackageJson();
6 changes: 3 additions & 3 deletions test/features/utils/consumer/gracefulShutdown.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Consumer } from "../../../../dist/consumer.js";
import { Consumer } from '../../../../dist/esm/consumer.js';

import { QUEUE_URL, sqs } from "../sqs.js";
import { QUEUE_URL, sqs } from '../sqs.js';

export const consumer = Consumer.create({
queueUrl: QUEUE_URL,
Expand All @@ -11,5 +11,5 @@ export const consumer = Consumer.create({
handleMessage: async (message) => {
await new Promise((resolve) => setTimeout(resolve, 1500));
return message;
},
}
});
6 changes: 3 additions & 3 deletions test/features/utils/consumer/handleMessage.js
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { Consumer } from "../../../../dist/consumer.js";
import { Consumer } from '../../../../dist/esm/consumer.js';

import { QUEUE_URL, sqs } from "../sqs.js";
import { QUEUE_URL, sqs } from '../sqs.js';

export const consumer = Consumer.create({
queueUrl: QUEUE_URL,
sqs,
pollingWaitTimeMs: 100,
handleMessage: async (message) => {
return message;
},
}
});
6 changes: 3 additions & 3 deletions test/features/utils/consumer/handleMessageBatch.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Consumer } from "../../../../dist/consumer.js";
import { Consumer } from '../../../../dist/esm/consumer.js';

import { QUEUE_URL, sqs } from "../sqs.js";
import { QUEUE_URL, sqs } from '../sqs.js';

export const consumer = Consumer.create({
queueUrl: QUEUE_URL,
Expand All @@ -9,5 +9,5 @@ export const consumer = Consumer.create({
batchSize: 5,
handleMessageBatch: async (messages) => {
return messages;
},
}
});
9 changes: 9 additions & 0 deletions tsconfig.cjs.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./dist/cjs",
"module": "commonjs",
"moduleResolution": "node",
"noEmit": false
}
}
9 changes: 9 additions & 0 deletions tsconfig.esm.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"outDir": "./dist/esm",
"module": "Node16",
"moduleResolution": "Node16",
"noEmit": false
}
}
5 changes: 3 additions & 2 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
"target": "ES2021",
"module": "Node16",
"moduleResolution": "Node16",
"outDir": "dist",
"noEmit": true,
"sourceMap": false,
"allowJs": false,
"noUnusedLocals": true,
"declaration": true
"declaration": true,
"declarationDir": "dist/types"
},
"include": ["src/**/*"],
"exclude": ["node_modules", "dist"]
Expand Down

0 comments on commit e795149

Please sign in to comment.