Skip to content
This repository was archived by the owner on Sep 27, 2023. It is now read-only.
Open
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
2 changes: 0 additions & 2 deletions packages/zact/client.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
"use client";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Decent chance this won't work without this

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm pretty confident about this.
Here you are in a library.
Library code is built and bundled without knowing anything about RSC boundaries.
This should be at component level in your next app :

'use client'
import { useZact } from 'zact/client';

cf https://github.com/reactjs/rfcs/blob/main/text/0227-server-module-conventions.md

Copy link

@chungweileong94 chungweileong94 May 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well true, we should use this hook in client component anyway, user will have to specify the use client instead, so the directive is not really necessary in here.

However, it doesn't hurt to have the use client directive here tho, to tell React that this is one of the client entry, it's safer than nothing.

https://nextjs.org/docs/getting-started/react-essentials#third-party-packages

Copy link
Author

@ecyrbe ecyrbe May 6, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The issue is, tsup used here to bundle does not honor 'use client' placement at the top of the file.
So that's why i propose to remove it, since it's not packaged correctly


import type z from "zod";
import type { ZactAction } from "./server";
import { useMemo, useRef, useState } from "react";
Expand Down
37 changes: 27 additions & 10 deletions packages/zact/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,25 +2,42 @@
"name": "zact",
"version": "0.0.2",
"license": "MIT",
"type": "module",
"exports": {
"./client": {
"import": "./dist/client.js"
},
"./server": {
"import": "./dist/server.js"
},
"./package.json": "./package.json"
},
"files": [
"lib"
],
"scripts": {
"lint": "eslint *.ts*",
"build": "tsup"
},
"dependencies": {
"react": "^18.2.0",
"zod": "^3.21.4",
"zod-validation-error": "^1.3.0"
"zod-validation-error": "1.3.0"
},
"devDependencies": {
"@types/react": "^18.0.35",
"@types/react-dom": "^18.0.11",
"eslint": "^8.38.0",
"@types/react": "18.2.5",
"@types/react-dom": "18.2.3",
"eslint": "8.39.0",
"eslint-config-custom": "workspace:*",
"react": "^18.2.0",
"next": "13.4.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"zod": "3.21.4",
"tsup": "6.7.0",
"typescript": "^5.0.4"
"typescript": "5.0.4"
},
"peerDependencies": {
"next": "^13.3.0"
"next": ">=13.3.0",
"react": "18.x",
"react-dom": "18.x",
"zod": "3.x"
}
}
}
1 change: 1 addition & 0 deletions packages/zact/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
"$schema": "https://json.schemastore.org/tsconfig",
"display": "Default",
"compilerOptions": {
"target": "ES2015",
"composite": false,
"declaration": true,
"declarationMap": true,
Expand Down
Loading