Skip to content

Commit

Permalink
fix: allow Node 18 again to make Stackblitz work (#1544)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcusschiesser authored Dec 4, 2024
1 parent cf9a935 commit b504303
Show file tree
Hide file tree
Showing 9 changed files with 53 additions and 89 deletions.
6 changes: 6 additions & 0 deletions .changeset/good-ants-fix.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
"llamaindex": patch
"@llamaindex/env": patch
---

Allow Node 18 again (throw run-time error if not possible) to make Stackblitz work
4 changes: 2 additions & 2 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [20.x, 22.x, 23.x]
node-version: [18.x, 20.x, 22.x, 23.x]
name: E2E on Node.js ${{ matrix.node-version }}
runs-on: ubuntu-latest
steps:
Expand Down Expand Up @@ -53,7 +53,7 @@ jobs:
strategy:
fail-fast: false
matrix:
node-version: [20.x, 22.x, 23.x]
node-version: [18.x, 20.x, 22.x, 23.x]
name: Test on Node.js ${{ matrix.node-version }}
runs-on: ubuntu-latest
steps:
Expand Down
5 changes: 5 additions & 0 deletions e2e/node/embedding/clip.e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,11 @@ test.beforeEach(() => {
});

await test("clip embedding", async (t) => {
const major = parseInt(process.versions.node.split(".")[0] ?? "0", 10);
if (major < 20) {
t.skip("Skip CLIP tests on Node.js < 20");
return;
}
await t.test("should trigger load transformer event", async () => {
const nodes = [
new ImageNode({
Expand Down
7 changes: 7 additions & 0 deletions packages/env/src/internal/multi-model/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,13 @@ export {
} from "./shared.js";

export async function loadTransformers(onLoad: OnLoad) {
const nodeVersions = process.versions.node.split(".");
if (nodeVersions[0] && parseInt(nodeVersions[0], 10) < 20) {
throw new Error(
"@huggingface/transformers is not supported on Node.js versions below 20",
);
}

if (getTransformers() === null) {
setTransformers(await import("@huggingface/transformers"));
} else {
Expand Down
3 changes: 1 addition & 2 deletions packages/llamaindex/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,6 @@
}
},
"devDependencies": {
"@huggingface/transformers": "^3.0.2",
"@swc/cli": "^0.5.0",
"@swc/core": "^1.9.2",
"@vercel/postgres": "^0.10.0",
Expand All @@ -98,7 +97,7 @@
"typescript": "^5.6.3"
},
"engines": {
"node": ">=20.0.0"
"node": ">=18.0.0"
},
"types": "./dist/type/index.d.ts",
"main": "./dist/cjs/index.js",
Expand Down
4 changes: 4 additions & 0 deletions packages/workflow/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,11 @@
"build": "bunchee"
},
"devDependencies": {
"@llamaindex/env": "workspace:*",
"@types/node": "^22.9.0",
"bunchee": "5.6.1"
},
"peerDependencies": {
"@llamaindex/env": "workspace:*"
}
}
3 changes: 2 additions & 1 deletion packages/workflow/src/workflow-context.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { CustomEvent, randomUUID } from "@llamaindex/env";
import {
type AnyWorkflowEventConstructor,
StartEvent,
Expand Down Expand Up @@ -231,7 +232,7 @@ export class WorkflowContext<Start = string, Stop = string, Data = unknown>
#requireEvent = async <T extends AnyWorkflowEventConstructor>(
event: T,
): Promise<InstanceType<T>> => {
const requestId = crypto.randomUUID();
const requestId = randomUUID();
this.#queue.push({
type: "requestEvent",
id: requestId,
Expand Down
1 change: 1 addition & 0 deletions packages/workflow/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"emitDeclarationOnly": true,
"module": "ESNext",
"moduleResolution": "bundler",
"skipLibCheck": true,
"types": ["node"],
"resolveJsonModule": true
},
Expand Down
Loading

0 comments on commit b504303

Please sign in to comment.