Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use esbuild for Dual Package Approach #25

Merged
merged 1 commit into from
Aug 24, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
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