Skip to content

Commit

Permalink
fix: import issue (#133)
Browse files Browse the repository at this point in the history
* feat: moved to src and renamed main to index

* feat: use tsup to bundle

* chore: changeset

* build: use wildcard for latest version from workspace
  • Loading branch information
field123 authored Nov 21, 2023
1 parent 061bbfe commit 07674b4
Show file tree
Hide file tree
Showing 63 changed files with 508 additions and 373 deletions.
5 changes: 5 additions & 0 deletions .changeset/gorgeous-avocados-sit.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@elasticpath/react-shopper-hooks": patch
---

building with tsup and outputing a non bundled build
4 changes: 2 additions & 2 deletions examples/algolia/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
},
"dependencies": {
"@algolia/react-instantsearch-widget-color-refinement-list": "^1.4.7",
"@elasticpath/react-shopper-hooks": "workspace:^0.6.1",
"@elasticpath/shopper-common": "workspace:^0.2.1",
"@elasticpath/react-shopper-hooks": "workspace:*",
"@elasticpath/shopper-common": "workspace:*",
"@headlessui/react": "^1.7.17",
"@heroicons/react": "^2.0.18",
"@moltin/sdk": "^27.0.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/payments/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"start:e2e": "NODE_ENV=test next start"
},
"dependencies": {
"@elasticpath/react-shopper-hooks": "workspace:^0.6.1",
"@elasticpath/shopper-common": "workspace:^0.2.1",
"@elasticpath/react-shopper-hooks": "workspace:*",
"@elasticpath/shopper-common": "workspace:*",
"@headlessui/react": "^1.7.17",
"@heroicons/react": "^2.0.18",
"@moltin/sdk": "^27.0.0",
Expand Down
4 changes: 2 additions & 2 deletions examples/simple/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
},
"dependencies": {
"@moltin/sdk": "^27.0.0",
"@elasticpath/react-shopper-hooks": "workspace:^0.6.1",
"@elasticpath/shopper-common": "workspace:^0.2.1",
"@elasticpath/react-shopper-hooks": "workspace:*",
"@elasticpath/shopper-common": "workspace:*",
"clsx": "^1.2.1",
"cookies-next": "^4.0.0",
"focus-visible": "^5.2.0",
Expand Down
31 changes: 13 additions & 18 deletions packages/react-shopper-hooks/example/App.tsx
Original file line number Diff line number Diff line change
@@ -1,36 +1,31 @@
import React, { useState } from "react"
import React from "react"
import "./App.css"
import CartExample from "./CartExample"
import { CartProvider } from "@lib/cart"
import { CartProvider } from "../src/cart"
import { gateway as EPCCGateway } from "@moltin/sdk"
import { StoreProvider } from "../src/store"

function App() {
const [count, setCount] = useState(0)

const client = EPCCGateway({
name: "my_store",
client_id: import.meta.env.VITE_APP_EPCC_CLIENT_ID,
client_secret: import.meta.env.VITE_APP_EPCC_CLIENT_SECRET,
host: import.meta.env.VITE_APP_EPCC_HOST
host: import.meta.env.VITE_APP_EPCC_HOST,
})

return (
<div className="App">
<h1>EPCC React</h1>
<h1>React Shopper Hooks</h1>
<div className="card">
<button onClick={() => setCount(count => count + 1)}>
count is {count}
</button>
<p>
Edit <code>src/App.tsx</code> and save to test HMR
</p>
<StoreProvider
client={client}
resolveCartId={() => client.Cart().cartId}
>
<CartProvider resolveCartId={() => client.Cart().cartId}>
<CartExample />
</CartProvider>
</StoreProvider>
</div>
<p className="read-the-docs">
Click on the Vite and React logos to learn more
</p>
<CartProvider client={client} resolveCartId={() => client.Cart().cartId}>
<CartExample />
</CartProvider>
</div>
)
}
Expand Down
4 changes: 2 additions & 2 deletions packages/react-shopper-hooks/example/CartExample.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import React from "react"
import { useCart } from "@lib/cart"
import { useCart } from "../src/cart"

export default function CartExample(): JSX.Element {
const { state, addBundleProductToCart, emptyCart } = useCart()
Expand All @@ -21,7 +21,7 @@ export default function CartExample(): JSX.Element {
"7ffe107d-c5bd-4de4-b8f0-a58d90cb3cd3": 1,
},
},
1
1,
)
}
>
Expand Down
169 changes: 0 additions & 169 deletions packages/react-shopper-hooks/lib/cart/cart-provider.tsx

This file was deleted.

37 changes: 24 additions & 13 deletions packages/react-shopper-hooks/package.json
Original file line number Diff line number Diff line change
@@ -1,32 +1,43 @@
{
"name": "@elasticpath/react-shopper-hooks",
"type": "module",
"version": "0.6.1",
"files": [
"dist"
],
"types": "./dist/react-shopper-hooks.d.ts",
"main": "./dist/react-shopper-hooks.umd.cjs",
"module": "./dist/react-shopper-hooks.js",
"scripts": {
"dev": "vite",
"build": "tsc && vite build",
"preview": "vite preview",
"build": "tsup",
"clean": "rimraf ./dist",
"test": "vitest --run"
},
"type": "module",
"types": "./dist/index.d.ts",
"main": "./dist/index.cjs",
"module": "./dist/index.js",
"exports": {
".": {
"import": "./dist/react-shopper-hooks.js",
"require": "./dist/react-shopper-hooks.umd.cjs"
}
"import": {
"types": "./dist/index.d.ts",
"default": "./dist/index.js"
},
"require": {
"types": "./dist/index.d.cts",
"default": "./dist/index.cjs"
}
},
"./package.json": "./package.json"
},
"sideEffects": false,
"files": [
"dist"
],
"devDependencies": {
"@moltin/sdk": "^27.0.0",
"@types/react": "^18.2.33",
"@types/react-dom": "^18.2.14",
"@moltin/sdk": "^27.0.0",
"@vitejs/plugin-react": "^2.2.0",
"esbuild-plugin-file-path-extensions": "^1.0.0",
"react": "^18.2.0",
"react-dom": "^18.2.0",
"rimraf": "^5.0.5",
"tsup": "^8.0.1",
"typescript": "^4.8.4",
"vite": "^3.2.3",
"vite-plugin-dts": "^1.7.0",
Expand Down
Loading

1 comment on commit 07674b4

@vercel
Copy link

@vercel vercel bot commented on 07674b4 Nov 21, 2023

Choose a reason for hiding this comment

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

Please sign in to comment.