Skip to content

Commit

Permalink
Merge pull request #178 from upstash/DX-1250-rollback-cjs-support
Browse files Browse the repository at this point in the history
Add CommonJS support back
  • Loading branch information
CahidArda authored Sep 9, 2024
2 parents cfb5cdc + 76a5caf commit 3435c6c
Show file tree
Hide file tree
Showing 10 changed files with 88 additions and 138 deletions.
21 changes: 11 additions & 10 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,6 @@ jobs:
- name: Set package version
run: echo $(jq --arg v "${{ env.VERSION }}" '(.version) = $v' package.json) > package.json

- name: Setup Bun
uses: oven-sh/setup-bun@v1
with:
bun-version: latest

- name: Install Dependencies
run: bun install

Expand All @@ -38,10 +33,16 @@ jobs:
- name: Set NPM_TOKEN
run: npm set "//registry.npmjs.org/:_authToken" ${{ secrets.NPM_TOKEN }}

- name: Publish release candidate
if: "github.event.release.prerelease"
run: npm publish --access public --tag=canary --no-git-checks

- name: Publish
if: "!github.event.release.prerelease"
run: npm publish --access public --no-git-checks
working-directory: ./dist
run: |
npm pkg delete scripts.prepare
npm publish --access public
- name: Publish release candidate
if: "github.event.release.prerelease"
working-directory: ./dist
run: |
npm pkg delete scripts.prepare
npm publish --access public --tag=next
2 changes: 1 addition & 1 deletion .husky/pre-push
Original file line number Diff line number Diff line change
@@ -1 +1 @@
bun run build
bun run test && bun run build
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -132,29 +132,36 @@ const result = await client.publishJSON({
See [the documentation](https://docs.upstash.com/qstash) for details.

## Contributing

### Setup

This project requires [Bun](https://bun.sh/) to be installed. Please see the [Bun installation documentation](https://bun.sh/docs/installation) for further instructions.

Once you have cloned the project, you will need to install the dependencies and then you can run the project.

```sh
bun install
bun run build
```

### Testing

To begin testing, environment variables will need to be setup. First, create a `.env` file in the root of the project. [`.env.template`](/.env.template) can be used as a template. Your values can be found in the [Qstash Console](https://console.upstash.com/qstash).

```sh
bun run test
```

### Committing
This project uses [commitlint](https://commitlint.js.org/). When committing, please ensure your commit message is formatted to include an appropriate prefix with the message.

#### Examples ####
This project uses [commitlint](https://commitlint.js.org/). When committing, please ensure your commit message is formatted to include an appropriate prefix with the message.

#### Examples

```
fix: typescript bug
feat: use new logger
perf: refactor cache
```
For a full list of options, please see the [`commitlint.config.js`](/commitlint.config.js) file.

For a full list of options, please see the [`commitlint.config.js`](/commitlint.config.js) file.
Binary file modified bun.lockb
Binary file not shown.
4 changes: 2 additions & 2 deletions examples/nodejs/customHeaders.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Client, Receiver } from "@upstash/qstash/base/index.mjs";
import "isomorphic-fetch";
const { Client, Receiver } = require("@upstash/qstash");
require("isomorphic-fetch");

async function main() {
const q = new Client({
Expand Down
4 changes: 2 additions & 2 deletions examples/nodejs/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { Client, Receiver } from "@upstash/qstash/base/index.mjs";
import "isomorphic-fetch";
const { Client, Receiver } = require("@upstash/qstash");
require("isomorphic-fetch");

async function main() {
const q = new Client({
Expand Down
1 change: 0 additions & 1 deletion examples/nodejs/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"name": "nodejs",
"version": "1.0.0",
"description": "",
"type": "module",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
Expand Down
65 changes: 40 additions & 25 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,51 +12,66 @@
"bugs": {
"url": "https://github.com/upstash/sdk-qstash-ts/issues"
},
"main": "./index.js",
"module": "./index.mjs",
"types": "./index.d.ts",
"files": [
"dist"
"./**"
],
"main": "./dist/base/index.mjs",
"module": "./dist/base/index.mjs",
"types": "./dist/base/index.d.mts",
"exports": {
".": {
"types": "./dist/base/index.d.mts",
"import": "./dist/base/index.mjs",
"require": "./dist/base/index.js"
"import": "./index.mjs",
"require": "./index.js"
},
"./nextjs": {
"import": "./dist/nextjs/index.mjs"
"import": "./nextjs.js",
"require": "./nextjs.js"
},
"./dist/nextjs": {
"import": "./dist/nextjs/index.mjs"
"import": "./nextjs.js",
"require": "./nextjs.js"
},
"./h3": {
"types": "./dist/h3/index.d.mts",
"import": "./dist/h3/index.mjs"
"types": "./h3.d.ts",
"import": "./h3.mjs",
"require": "./h3.js"
},
"./nuxt": {
"types": "./dist/h3/index.d.mts",
"import": "./dist/h3/index.mjs"
"types": "./nuxt.d.ts",
"import": "./nuxt.mjs",
"require": "./nuxt.js"
},
"./svelte": {
"types": "./dist/svelte/index.d.mts",
"import": "./dist/svelte/index.mjs"
"types": "./svelte.d.ts",
"import": "./svelte.mjs",
"require": "./svelte.js"
},
"./solidjs": {
"types": "./dist/solidjs/index.d.mts",
"import": "./dist/solidjs/index.mjs"
"types": "./solidjs.d.ts",
"import": "./solidjs.mjs",
"require": "./solidjs.js"
},
"./workflow": {
"types": "./dist/workflow/index.d.mts",
"import": "./dist/workflow/index.mjs"
"types": "./workflow.d.ts",
"import": "./workflow.mjs",
"require": "./workflow.js"
},
"./hono": {
"types": "./dist/hono/index.d.mts",
"import": "./dist/hono/index.mjs"
"types": "./hono.d.ts",
"import": "./hono.mjs",
"require": "./hono.js"
},
"./cloudflare": {
"types": "./dist/cloudflare/index.d.mts",
"import": "./dist/cloudflare/index.mjs"
"types": "./cloudflare.d.ts",
"import": "./cloudflare.mjs",
"require": "./cloudflare.js"
}
},
"typesVersions": {
"*": {
"nextjs": [
"./nextjs.d.ts"
]
}
},
"keywords": [
Expand All @@ -67,7 +82,7 @@
"upstash"
],
"scripts": {
"build": "tsup",
"build": "tsup && cp README.md ./dist/ && cp package.json ./dist/ && cp LICENSE ./dist/",
"test": "bun test src",
"fmt": "prettier --write .",
"lint": "tsc && eslint \"src/**/*.{js,ts,tsx}\" --quiet --fix",
Expand Down Expand Up @@ -99,6 +114,6 @@
},
"dependencies": {
"crypto-js": ">=4.2.0",
"jose": "^ 5.2.3"
"jose": "^5.2.3"
}
}
2 changes: 1 addition & 1 deletion tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,5 @@
"allowJs": true,
"types": ["bun-types"]
},
"exclude": ["examples", "dist"]
"exclude": ["examples"]
}
114 changes: 21 additions & 93 deletions tsup.config.js
Original file line number Diff line number Diff line change
@@ -1,94 +1,22 @@
import { defineConfig } from "tsup";
export default defineConfig([
{
entry: ["src/index.ts"],
outDir: "dist/base",
format: "esm",
sourcemap: false,
clean: true,
dts: true,
minify: true,
},
{
entry: {
index: "src/client/workflow/index.ts",
},
outDir: "dist/workflow",
format: "esm",
sourcemap: false,
clean: true,
dts: true,
minify: true,
},
{
entry: {
index: "platforms/nextjs.ts",
},
outDir: "dist/nextjs",
format: "esm",
sourcemap: false,
clean: true,
dts: true,
minify: true,
external: ["next"],
},
{
entry: {
index: "platforms/h3.ts",
},
outDir: "dist/h3",
format: "esm",
sourcemap: false,
clean: true,
dts: true,
minify: true,
external: ["h3"],
},
{
entry: {
index: "platforms/svelte.ts",
},
outDir: "dist/svelte",
format: "esm",
sourcemap: false,
clean: true,
dts: true,
minify: true,
external: ["@sveltejs/kit"],
},
{
entry: {
index: "platforms/solidjs.ts",
},
outDir: "dist/solidjs",
format: "esm",
sourcemap: false,
clean: true,
dts: true,
minify: true,
external: ["@solidjs/start"],
},
{
entry: {
index: "platforms/hono.ts",
},
outDir: "dist/hono",
format: "esm",
sourcemap: false,
clean: true,
dts: true,
minify: true,
external: ["hono"],
},
{
entry: {
index: "platforms/cloudflare.ts",
},
outDir: "dist/cloudflare",
format: "esm",
sourcemap: false,
clean: true,
dts: true,
minify: true,
},
]);

export default defineConfig({
entry: {
index: "./src/index.ts",
workflow: "./src/client/workflow/index.ts",
nextjs: "./platforms/nextjs.ts",
h3: "./platforms/h3.ts",
nuxt: "./platforms/nuxt.ts",
svelte: "./platforms/svelte.ts",
solidjs: "./platforms/solidjs.ts",
hono: "./platforms/hono.ts",
cloudflare: "./platforms/cloudflare.ts",
},
format: ["cjs", "esm"],
splitting: true,
sourcemap: false,
clean: true,
bundle: true,
dts: true,
external: ["next"],
});

0 comments on commit 3435c6c

Please sign in to comment.