Skip to content

Commit

Permalink
feat(client): isomorphic pinorama client
Browse files Browse the repository at this point in the history
  • Loading branch information
cesconix committed Jun 11, 2024
1 parent 2703f50 commit 3d00a87
Show file tree
Hide file tree
Showing 25 changed files with 978 additions and 516 deletions.
10 changes: 7 additions & 3 deletions examples/create-server-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
"type": "module",
"private": true,
"scripts": {
"start": "node index.mjs"
"start": "node index.mjs",
"clean": "rimraf node_modules"
},
"dependencies": {
"@fastify/one-line-logger": "^1.3.0",
"fastify": "^4.26.2",
"pinorama-transport": "workspace:*",
"pinorama-server": "workspace:*"
"pinorama-server": "workspace:*",
"pinorama-transport": "workspace:*"
},
"devDependencies": {
"rimraf": "^5.0.7"
}
}
10 changes: 7 additions & 3 deletions examples/fastify-example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,16 @@
"type": "module",
"private": true,
"scripts": {
"start": "node index.mjs"
"start": "node index.mjs",
"clean": "rimraf node_modules"
},
"dependencies": {
"@fastify/one-line-logger": "^1.3.0",
"fastify": "^4.26.2",
"pinorama-transport": "workspace:*",
"pinorama-server": "workspace:*"
"pinorama-server": "workspace:*",
"pinorama-transport": "workspace:*"
},
"devDependencies": {
"rimraf": "^5.0.7"
}
}
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
},
"scripts": {
"test": "turbo test",
"clean": "turbo clean",
"clean": "turbo clean && rimraf node_modules .turbo",
"build": "turbo build",
"dev": "turbo dev",
"biome": "biome check --write --no-errors-on-unmatched",
Expand All @@ -26,6 +26,7 @@
"@commitlint/cli": "^19.3.0",
"@commitlint/config-conventional": "^19.2.2",
"husky": "^9.0.11",
"rimraf": "^5.0.7",
"turbo": "^2.0.3"
},
"packageManager": "pnpm@9.2.0",
Expand Down
45 changes: 33 additions & 12 deletions packages/pinorama-client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,26 +2,47 @@
"name": "pinorama-client",
"version": "0.1.0",
"license": "MIT",
"type": "module",
"types": "./dist/index.d.mts",
"exports": "./dist/index.mjs",
"files": ["dist"],
"scripts": {
"clean": "rimraf ./dist",
"build": "pnpm clean && tsc"
"main": "./dist/node/pinorama-client.cjs",
"module": "./dist/node/pinorama-client.mjs",
"exports": {
".": {
"types": "./dist/types/pinorama-client.d.ts",
"require": "./dist/node/pinorama-client.cjs",
"import": "./dist/node/pinorama-client.mjs"
},
"./node": {
"types": "./dist/types/pinorama-client.d.ts",
"require": "./dist/node/pinorama-client.cjs",
"import": "./dist/node/pinorama-client.mjs"
},
"./browser": {
"types": "./dist/types/pinorama-client.d.ts",
"import": "./dist/browser/pinorama-client.esm.js"
}
},
"author": {
"email": "cesconix@me.com",
"name": "Francesco Pasqua",
"url": "https://github.com/cesconix"
"types": "./dist/types/pinorama-client.d.ts",
"files": [
"dist"
],
"scripts": {
"clean": "rimraf dist node_modules",
"build": "rollup --config"
},
"author": "Francesco Pasqua <cesconix@me.com>",
"devDependencies": {
"@rollup/plugin-alias": "^5.1.0",
"@rollup/plugin-commonjs": "^26.0.1",
"@rollup/plugin-node-resolve": "^15.2.3",
"@rollup/plugin-terser": "^0.4.4",
"@rollup/plugin-typescript": "^11.1.6",
"@types/node": "^20.14.2",
"rimraf": "^5.0.7",
"rollup": "^4.18.0",
"rollup-plugin-dts": "^6.1.1",
"tslib": "^2.6.3",
"typescript": "^5.4.5"
},
"dependencies": {
"undici": "^6.18.2",
"zod": "^3.23.8"
},
"publishConfig": {
Expand Down
115 changes: 115 additions & 0 deletions packages/pinorama-client/rollup.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
import alias from "@rollup/plugin-alias";
import commonjs from "@rollup/plugin-commonjs";
import resolve from "@rollup/plugin-node-resolve";
import terser from "@rollup/plugin-terser";
import typescript from "@rollup/plugin-typescript";
import { dts } from "rollup-plugin-dts";

const inputFile = "src/index.ts";
const outputFileName = "pinorama-client";

export default [
// Declaration file
{
input: inputFile,
output: [{ file: "dist/types/pinorama-client.d.ts", format: "es" }],
plugins: [dts()],
},

// Browser ESM build
{
input: inputFile,
output: [
{
file: `dist/browser/${outputFileName}.esm.js`,
format: "es",
sourcemap: true,
},
],
plugins: [
alias({
entries: [
{ find: "./platform/node.js", replacement: "./platform/browser.js" },
],
}),
resolve({ browser: true }),
commonjs(),
typescript(),
terser(),
],
external: ["zod"],
},

// // Browser UMD build
// {
// input: inputFile,
// output: [
// {
// file: `dist/browser/${outputFileName}.umd.js`,
// format: "umd",
// name: "pinorama-client",
// },
// ],
// plugins: [
// alias({
// entries: [
// { find: "./platform/node.js", replacement: "./platform/browser.js" },
// ],
// }),
// resolve({ browser: true }),
// commonjs(),
// typescript(),
// ],
// external: ["zod"],
// },

// // Browser CJS build
// {
// input: inputFile,
// output: [
// {
// file: `dist/browser/${outputFileName}.cjs.js`,
// format: "cjs",
// },
// ],
// plugins: [
// alias({
// entries: [
// { find: "./platform/node.js", replacement: "./platform/browser.js" },
// ],
// }),
// resolve({ browser: true }),
// commonjs(),
// typescript(),
// ],
// external: ["zod"],
// },

// Node.js ESM bundle
{
input: inputFile,
output: [
{
file: `dist/node/${outputFileName}.mjs`,
format: "es",
sourcemap: true,
},
],
plugins: [resolve(), commonjs(), typescript()],
external: ["zod"],
},

// Node.js CJS build
{
input: inputFile,
output: [
{
file: `dist/node/${outputFileName}.cjs`,
format: "cjs",
sourcemap: true,
},
],
plugins: [resolve(), commonjs(), typescript()],
external: ["zod"],
},
];
Loading

0 comments on commit 3d00a87

Please sign in to comment.