Skip to content
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
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,8 @@
"test": "pnpm run lint && vitest run --silent",
"test:watch": "vitest",
"coverage": "vitest run --coverage",
"build": "tsup",
"build:watch": "tsup --watch",
"build": "tsdown",
"build:watch": "tsdown --watch",
"ci": "pnpm build && pnpm check-exports && pnpm lint"
},
"publishConfig": {
Expand All @@ -40,7 +40,7 @@
"devDependencies": {
"@arethetypeswrong/cli": "^0.18.2",
"@vitest/coverage-v8": "^4.1.5",
"tsup": "^8.5.1",
"tsdown": "^0.22.4",
"typescript": "^6.0.3",
"vite-tsconfig-paths": "^6.1.1",
"vitest": "^4.1.5"
Expand Down
11 changes: 11 additions & 0 deletions packages/core/tsdown.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import { defineConfig } from "tsdown"

export default defineConfig({
entry: ["src/index.ts"],
format: ["cjs", "esm"],
dts: true,
fixedExtension: false,
outDir: "dist",
clean: true,
treeshake: true,
})
11 changes: 0 additions & 11 deletions packages/core/tsup.config.ts

This file was deleted.

13 changes: 8 additions & 5 deletions packages/hooks/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,10 @@
"test": "pnpm run lint && vitest run --silent",
"test:watch": "vitest",
"coverage": "vitest run --coverage",
"build": "tsup",
"build:watch": "tsup --watch",
"ci": "pnpm build && pnpm check-exports && pnpm lint"
"build": "tsdown && pnpm check-compiler",
"build:watch": "tsdown --watch",
"ci": "pnpm build && pnpm check-exports && pnpm lint",
"check-compiler": "node -e \"for (const f of ['dist/index.js','dist/index.cjs']) if (!require('fs').readFileSync(f,'utf8').includes('react/compiler-runtime')) { console.error('React Compiler output missing in ' + f); process.exit(1) }\""
},
"publishConfig": {
"access": "public"
Expand All @@ -41,14 +42,16 @@
"@arethetypeswrong/cli": "^0.18.2",
"@babel/core": "^7.29.0",
"@commercelayer/sdk": "^7.11.0",
"@rolldown/plugin-babel": "^0.2.3",
"@testing-library/react": "^16.3.2",
"@types/react": "^19.2.14",
"@types/react-dom": "^19.2.3",
"@vitejs/plugin-react": "^6.0.3",
"@vitest/coverage-v8": "^4.1.5",
"babel-plugin-react-compiler": "^1.0.0",
"react": "^19.2.6",
"react-dom": "^19.2.6",
"tsup": "^8.5.1",
"tsdown": "^0.22.4",
"typescript": "^6.0.3",
"vite-tsconfig-paths": "^6.1.1",
"vitest": "^4.1.5"
Expand All @@ -58,6 +61,6 @@
"swr": "^2.4.1"
},
"peerDependencies": {
"react": ">=18"
"react": ">=19.0.0"
}
}
20 changes: 20 additions & 0 deletions packages/hooks/tsdown.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
import pluginBabel from "@rolldown/plugin-babel"
import { reactCompilerPreset } from "@vitejs/plugin-react"
import { defineConfig } from "tsdown"

export default defineConfig({
entry: ["src/index.ts"],
format: ["cjs", "esm"],
dts: true,
fixedExtension: false,
outDir: "dist",
clean: true,
treeshake: true,
plugins: [
pluginBabel({
// target 19: compiled output imports the built-in react/compiler-runtime,
// which requires the react >=19 peer range
presets: [reactCompilerPreset({ target: "19" })],
}),
],
})
13 changes: 0 additions & 13 deletions packages/hooks/tsup.config.ts

This file was deleted.

16 changes: 10 additions & 6 deletions packages/react-components/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,12 @@
"test:e2e": "NODE_ENV=test playwright test",
"test:e2e:coverage": "nyc pnpm test:e2e && pnpm coverage:report",
"coverage:report": "nyc report --reporter=html",
"build": "tsup",
"build:watch": "tsup --watch",
"dev": "NODE_OPTIONS='--inspect' next dev"
"build": "tsdown && pnpm check-compiler",
"build:watch": "tsdown --watch",
"dev": "NODE_OPTIONS='--inspect' next dev",
"check-compiler": "node -e \"for (const f of ['dist/index.js','dist/index.cjs']) if (!require('fs').readFileSync(f,'utf8').includes('react/compiler-runtime')) { console.error('React Compiler output missing in ' + f); process.exit(1) }\"",
"check-exports": "attw --pack .",
"ci": "pnpm build && pnpm check-exports && pnpm lint"
},
"repository": {
"type": "git",
Expand Down Expand Up @@ -72,19 +75,20 @@
"rapid-form": "^4.0.3"
},
"devDependencies": {
"@arethetypeswrong/cli": "^0.18.2",
"@babel/core": "^7.29.0",
"@commercelayer/js-auth": "^7.4.1",
"@faker-js/faker": "^10.4.0",
"@playwright/test": "^1.59.1",
"@rolldown/plugin-babel": "^0.2.3",
"@testing-library/dom": "^10.4.1",
"@testing-library/react": "^16.3.2",
"@types/braintree-web": "^3.96.17",
"@types/node": "^25.6.2",
"@types/prop-types": "^15.7.15",
"@types/react": "^19.2.14",
"@types/react-test-renderer": "^19.1.0",
"@types/react-window": "^2.0.0",
"@vitejs/plugin-react": "^6.0.1",
"@vitejs/plugin-react": "^6.0.3",
"@vitest/coverage-v8": "^4.1.5",
"babel-plugin-react-compiler": "^1.0.0",
"jsdom": "^29.1.1",
Expand All @@ -93,8 +97,8 @@
"react-dom": "^19.2.6",
"react-test-renderer": "^19.2.6",
"swr": "^2.4.1",
"tsdown": "^0.22.4",
"tslib": "^2.8.1",
"tsup": "^8.5.1",
"typescript": "^6.0.3",
"vite": "^8.0.11",
"vite-tsconfig-paths": "^6.1.1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
import { type JSX, useContext, useEffect, useState } from "react"
import OrderContext from "#context/OrderContext"
import type { baseOrderPricePropTypes } from "#typings"
import type { BaseOrderPriceOwnProps } from "#typings"
import getAmount from "#utils/getAmount"
import { isEmpty } from "#utils/isEmpty"
import type { PropsType } from "#utils/PropsType"
import Parent from "./Parent"

export type BaseOrderPriceProps = PropsType<typeof baseOrderPricePropTypes, unknown> &
export type BaseOrderPriceProps = BaseOrderPriceOwnProps &
Omit<JSX.IntrinsicElements["span"], "children" | "ref">

export function BaseOrderPrice(props: BaseOrderPriceProps): JSX.Element {
Expand Down
48 changes: 6 additions & 42 deletions packages/react-components/src/typings/index.ts
Original file line number Diff line number Diff line change
@@ -1,33 +1,6 @@
import PropTypes, { type InferProps } from "prop-types"
import type { Dispatch, ForwardedRef, JSX, Ref } from "react"
import type { BaseError } from "./errors"

export const BC = {
id: PropTypes.string,
className: PropTypes.string,
style: PropTypes.object,
name: PropTypes.string,
}

export const PTLoader = PropTypes.oneOfType([PropTypes.element, PropTypes.string])

export const BaseSelectComponentPropTypes = {
children: PropTypes.func,
options: PropTypes.arrayOf(
PropTypes.shape({
label: PropTypes.string.isRequired,
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
selected: PropTypes.bool,
}).isRequired
).isRequired,
placeholder: PropTypes.shape({
label: PropTypes.string.isRequired,
value: PropTypes.oneOfType([PropTypes.string, PropTypes.number]).isRequired,
}),
value: PropTypes.string,
name: PropTypes.string.isRequired,
}

export type SelectPlaceholder = Option

type BaseSelectChildrenComponentProps = Omit<BaseSelectComponentProps, "children">
Expand Down Expand Up @@ -111,13 +84,10 @@ export type AddressStateSelectName = "billing_address_state_code" | "shipping_ad

export type LoaderType = string | JSX.Element

export const BMObject = PropTypes.objectOf(PropTypes.string)
export type BaseMetadataObject = Record<string, string | undefined | null>

export type TimeFormat = "days" | "hours"

export type BaseComponent = InferProps<typeof BC>

export interface BaseAction<A = string, P = Record<string, any>> {
type: A
payload: P
Expand All @@ -144,18 +114,12 @@ export type BaseMetadata = Record<string, string | undefined | null>

export type BaseFormatPrice = "formatted" | "cents" | "float"

export const baseOrderPricePropTypes = {
base: PropTypes.string.isRequired,
type: PropTypes.string.isRequired,
children: PropTypes.func,
format: PropTypes.oneOf<BaseFormatPrice>(["formatted", "cents", "float"]),
...BC,
}

export const baseOrderComponentPricePropTypes = {
children: baseOrderPricePropTypes.children,
format: baseOrderPricePropTypes.format,
...BC,
export interface BaseOrderPriceOwnProps {
base: string
type: string
children?: ((...args: any[]) => any) | null
format?: BaseFormatPrice | null
name?: string | null
}

export type BasePriceType = "total" | "option" | "unit"
Expand Down
38 changes: 0 additions & 38 deletions packages/react-components/src/utils/PropsType.ts

This file was deleted.

42 changes: 42 additions & 0 deletions packages/react-components/tsdown.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
import pluginBabel from "@rolldown/plugin-babel"
import { reactCompilerPreset } from "@vitejs/plugin-react"
import { defineConfig } from "tsdown"

export default defineConfig({
entry: ["src/index.ts"],
format: ["cjs", "esm"],
// browser library: keeps rolldown's require-interop shim browser-safe
// (platform "node" emits a top-level `import { createRequire } from "node:module"`,
// which breaks consumer browser bundles)
platform: "browser",
dts: {
// tsconfig.json limits "types" to ["vitest/globals"] for tests;
// reset to ["node"] so all @types/* are auto-included for DTS generation.
// "bundler" moduleResolution enables package.json exports subpath imports
// (e.g. @commercelayer/sdk/bundle) which "node" resolution doesn't support.
compilerOptions: { types: ["node"], moduleResolution: "bundler" },
},
fixedExtension: false,
outDir: "dist",
clean: true,
treeshake: true,
deps: {
neverBundle: [
"react",
"react-dom",
"@commercelayer/hooks",
"@commercelayer/core",
"@commercelayer/sdk",
"@commercelayer/sdk/bundle",
],
},
banner: {
js: '"use client";',
},
plugins: [
pluginBabel({
// target 19: compiled output imports the built-in react/compiler-runtime
presets: [reactCompilerPreset({ target: "19" })],
}),
],
})
31 changes: 0 additions & 31 deletions packages/react-components/tsup.config.ts

This file was deleted.

Loading
Loading