Skip to content

Commit

Permalink
Merge pull request #25 from metaskills/DualPublish
Browse files Browse the repository at this point in the history
Use esbuild for Dual Package Approach
  • Loading branch information
metaskills authored Aug 24, 2024
2 parents 15b6a39 + df9b841 commit 924eb55
Show file tree
Hide file tree
Showing 23 changed files with 505 additions and 27 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@ jobs:
uses: actions/setup-node@v4
with:
node-version: 18
- name: Install dependencies
run: npm ci
- name: Build
run: ./bin/build
- name: Publish
uses: JS-DevTools/npm-publish@v3
with:
Expand Down
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

See this http://keepachangelog.com link for information on how we want this document formatted.

## v1.5.0

### Removed

Subpath imports. Please import or require only "experts".

### Added/Changed

Use dual package approach. Now supports both ES6 import syntax and CommonJS require statements.

## v1.4.3

### Added
Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ Install via npm. Usage is very simple, there are only three objects to import.
npm install experts
```

Experts.js supports both ES6 import syntax and CommonJS require statements.

```javascript
import { Assistant, Tool, Thread } from "experts";
```
Expand Down
4 changes: 4 additions & 0 deletions bin/build
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
set -e

node build.js
7 changes: 6 additions & 1 deletion bin/setup
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
#!/bin/sh
set -e

npm install
if [ "$CI" = "true" ]; then
npm ci
else
npm install
fi

node test/products/create.js
node test/products/index.js
27 changes: 27 additions & 0 deletions build.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import * as esbuild from "esbuild";

async function build() {
// Build ESM version
await esbuild.build({
entryPoints: ["src/index.js"],
outfile: "dist/index.js",
format: "esm",
platform: "node",
target: "node14",
bundle: true,
});

// Build CommonJS version
await esbuild.build({
entryPoints: ["src/index.js"],
outfile: "dist/index.cjs",
format: "cjs",
platform: "node",
target: "node14",
bundle: true,
});

console.log("Build complete");
}

build().catch(console.error);
Loading

0 comments on commit 924eb55

Please sign in to comment.