Skip to content

Commit

Permalink
chore: add more test packages
Browse files Browse the repository at this point in the history
  • Loading branch information
hi-ogawa committed Dec 15, 2024
1 parent cec21bc commit 46a5753
Show file tree
Hide file tree
Showing 8 changed files with 69 additions and 0 deletions.
4 changes: 4 additions & 0 deletions packages/react-server/examples/basic/deps/cjs/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
```js
import { TestProvider } from "@hiogawa/test-deps-test1/provider"
import { TestProvider } from "@hiogawa/test-deps-test1"
```
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
exports.test = "[ok]"
8 changes: 8 additions & 0 deletions packages/react-server/examples/basic/deps/cjs/client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
"use client"

import React from "react";
import dep from "./client-dep.cjs";

export function TestClient() {
return React.createElement("span", null, `[TestClient: ${dep.test}]`)
}
14 changes: 14 additions & 0 deletions packages/react-server/examples/basic/deps/cjs/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"name": "@hiogawa/test-deps-cjs",
"private": true,
"type": "module",
"exports": {
".": "./server.js"
},
"dependencies": {
"react": "*"
},
"peerDependencies": {
"react": "*"
}
}
5 changes: 5 additions & 0 deletions packages/react-server/examples/basic/deps/cjs/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import React from "react";

export function TestServer() {
// return
}
15 changes: 15 additions & 0 deletions packages/react-server/examples/basic/deps/context/client.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
"use client"

import React from "react";

const MyContext = React.createContext("not-ok");

export function MyContextProvider(props) {
return React.createElement(MyContext.Provider, { value: "ok" }, props.children)
}

// consume own context in client entry
export function TestClient() {
const value = React.useContext(MyContext);
return React.createElement("span", null, `[context: ${value}]`)
}
15 changes: 15 additions & 0 deletions packages/react-server/examples/basic/deps/context/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
{
"name": "@hiogawa/test-deps-context",
"private": true,
"type": "module",
"exports": {
"./server": "./server.js",
"./client": "./client.js"
},
"dependencies": {
"react": "*"
},
"peerDependencies": {
"react": "*"
}
}
7 changes: 7 additions & 0 deletions packages/react-server/examples/basic/deps/context/server.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import React from "react";
import { MyContextProvider } from "@hiogawa/test-deps-context/client"

// consume own provider in server entr
export function TestServer(props) {
return React.createElement(MyContextProvider, null, props.children)
}

0 comments on commit 46a5753

Please sign in to comment.