diff --git a/examples/express/docs/CHANGELOG.md b/examples/express/docs/CHANGELOG.md index af7bab2..a9d5d2c 100644 --- a/examples/express/docs/CHANGELOG.md +++ b/examples/express/docs/CHANGELOG.md @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.2.6] - 2025-07-15 + +### Changed + +- Updated to named exports version of "features" package ([0.4.0](../../../packages/features/docs/CHANGELOG.md#040---2025-07-15)) + +### Fixed + +- import types explicitly from `@playwright/test` after unexpected pipeline failure + ## [0.2.5] - 2025-05-27 ### Changed diff --git a/examples/express/package.json b/examples/express/package.json index 07a30e8..4894627 100644 --- a/examples/express/package.json +++ b/examples/express/package.json @@ -1,6 +1,6 @@ { "name": "web-toggle-point-express-example", - "version": "0.2.5", + "version": "0.2.6", "type": "module", "engines": { "node": ">=20.6.0" diff --git a/examples/express/playwright.config.ts b/examples/express/playwright.config.ts index 0288d5e..c0e2fbd 100644 --- a/examples/express/playwright.config.ts +++ b/examples/express/playwright.config.ts @@ -1,4 +1,4 @@ -import { defineConfig, PlaywrightTestConfig } from "@playwright/test"; +import { defineConfig, type PlaywrightTestConfig } from "@playwright/test"; import baseConfig from "../../test/automation/base.config"; const config: PlaywrightTestConfig = { diff --git a/examples/express/src/routes/animals/featuresStore.js b/examples/express/src/routes/animals/featuresStore.js index e446d88..a108fc6 100644 --- a/examples/express/src/routes/animals/featuresStore.js +++ b/examples/express/src/routes/animals/featuresStore.js @@ -1,4 +1,5 @@ -import { nodeRequestScopedStoreFactory as featuresStoreFactory } from "@asos/web-toggle-point-features"; +// eslint-disable-next-line import/no-unresolved -- https://github.com/import-js/eslint-plugin-import/issues/1810 +import featuresStoreFactory from "@asos/web-toggle-point-features/storeFactories/nodeRequestScopedFeaturesStoreFactory"; const featuresStore = featuresStoreFactory(); diff --git a/examples/express/src/routes/animals/middleware.js b/examples/express/src/routes/animals/middleware.js index ef8eae2..b0be783 100644 --- a/examples/express/src/routes/animals/middleware.js +++ b/examples/express/src/routes/animals/middleware.js @@ -9,7 +9,7 @@ const contextMiddleware = (request, response, scopeCallBack) => { return; } response.header("Vary", version); - featuresStore.useValue({ value: { version }, scopeCallBack }); + featuresStore.setValue({ value: { version }, scopeCallBack }); }; export default contextMiddleware; diff --git a/examples/express/src/routes/config/featuresStore.js b/examples/express/src/routes/config/featuresStore.js index 89fc5d4..0a36142 100644 --- a/examples/express/src/routes/config/featuresStore.js +++ b/examples/express/src/routes/config/featuresStore.js @@ -1,4 +1,5 @@ -import { ssrBackedReactContextFeaturesStoreFactory as featuresStoreFactory } from "@asos/web-toggle-point-features"; +// eslint-disable-next-line import/no-unresolved -- https://github.com/import-js/eslint-plugin-import/issues/1810 +import featuresStoreFactory from "@asos/web-toggle-point-features/storeFactories/ssrBackedReactContextFeaturesStoreFactory"; const featuresStore = featuresStoreFactory({ name: "config", diff --git a/examples/next/docs/CHANGELOG.md b/examples/next/docs/CHANGELOG.md index 91c3ed8..6429dd7 100644 --- a/examples/next/docs/CHANGELOG.md +++ b/examples/next/docs/CHANGELOG.md @@ -5,6 +5,16 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.2.5] - 2025-07-15 + +### Changed + +- Updated to named exports version of "features" package ([0.4.0](../../../packages/features/docs/CHANGELOG.md#040---2025-07-15)) + +### Fixed + +- import types explicitly from `@playwright/test` & internally, after unexpected pipeline failure + ## [0.2.4] - 2025-05-27 ### Changed diff --git a/examples/next/package.json b/examples/next/package.json index e1d85f0..a7b9aa1 100644 --- a/examples/next/package.json +++ b/examples/next/package.json @@ -1,6 +1,6 @@ { "name": "web-toggle-point-next-example", - "version": "0.2.4", + "version": "0.2.5", "private": true, "type": "module", "scripts": { diff --git a/examples/next/playwright.config.ts b/examples/next/playwright.config.ts index 2f163c0..331c13c 100644 --- a/examples/next/playwright.config.ts +++ b/examples/next/playwright.config.ts @@ -1,4 +1,5 @@ -import { defineConfig, PlaywrightTestConfig } from "@playwright/test"; +import { defineConfig, type PlaywrightTestConfig } from "@playwright/test"; +// eslint-disable-next-line workspaces/no-relative-imports, workspaces/require-dependency import baseConfig from "../../test/automation/base.config"; const THREE_MINUTES = 3 * 60 * 1000; diff --git a/examples/next/src/app/fixtures/experiments/1-varied-component/playwright.spec.ts b/examples/next/src/app/fixtures/experiments/1-varied-component/playwright.spec.ts index 2350b62..e61d32d 100644 --- a/examples/next/src/app/fixtures/experiments/1-varied-component/playwright.spec.ts +++ b/examples/next/src/app/fixtures/experiments/1-varied-component/playwright.spec.ts @@ -1,4 +1,4 @@ -import { test, expect, ConsoleMessage } from "@playwright/test"; +import { test, expect, type ConsoleMessage } from "@playwright/test"; import setExperimentHeaders from "../playwright.setExperimentHeaders"; import locateWithinExample from "../playwright.locateInExample"; import getFixtureURL from "../playwright.getFixtureUrl"; diff --git a/examples/next/src/app/fixtures/experiments/4-varied-variant/playwright.spec.ts b/examples/next/src/app/fixtures/experiments/4-varied-variant/playwright.spec.ts index 7e02386..e4b4fc4 100644 --- a/examples/next/src/app/fixtures/experiments/4-varied-variant/playwright.spec.ts +++ b/examples/next/src/app/fixtures/experiments/4-varied-variant/playwright.spec.ts @@ -1,4 +1,4 @@ -import { test, expect, ConsoleMessage } from "@playwright/test"; +import { test, expect, type ConsoleMessage } from "@playwright/test"; import setExperimentHeaders from "../playwright.setExperimentHeaders"; import locateWithinExample from "../playwright.locateInExample"; import getFixtureURL from "../playwright.getFixtureUrl"; diff --git a/examples/next/src/app/fixtures/experiments/featuresStore.ts b/examples/next/src/app/fixtures/experiments/featuresStore.ts index 622d5fb..9a58eb5 100644 --- a/examples/next/src/app/fixtures/experiments/featuresStore.ts +++ b/examples/next/src/app/fixtures/experiments/featuresStore.ts @@ -1,6 +1,6 @@ "use client"; -import { reactContextFeaturesStoreFactory as featuresStoreFactory } from "@asos/web-toggle-point-features"; +import featuresStoreFactory from "@asos/web-toggle-point-features/storeFactories/reactContextFeaturesStoreFactory"; const reactContextStore = featuresStoreFactory({ name: "Experiments" diff --git a/examples/next/src/app/fixtures/experiments/getExperiments.ts b/examples/next/src/app/fixtures/experiments/getExperiments.ts index fc2f1ab..1ff2086 100644 --- a/examples/next/src/app/fixtures/experiments/getExperiments.ts +++ b/examples/next/src/app/fixtures/experiments/getExperiments.ts @@ -1,5 +1,5 @@ import { headers } from "next/headers"; -import { Experiments } from "./experiments"; +import { type Experiments } from "./experiments"; export default async function getExperiments(): Promise< Experiments | Record diff --git a/examples/next/src/app/fixtures/experiments/layout.tsx b/examples/next/src/app/fixtures/experiments/layout.tsx index 7b23ca7..89e2d6d 100644 --- a/examples/next/src/app/fixtures/experiments/layout.tsx +++ b/examples/next/src/app/fixtures/experiments/layout.tsx @@ -1,4 +1,4 @@ -import { ReactNode } from "react"; +import { type ReactNode } from "react"; import getExperiments from "./getExperiments"; import Example from "./example"; diff --git a/examples/next/src/app/fixtures/experiments/playwright.locateInExample.ts b/examples/next/src/app/fixtures/experiments/playwright.locateInExample.ts index 32224e8..970c9d2 100644 --- a/examples/next/src/app/fixtures/experiments/playwright.locateInExample.ts +++ b/examples/next/src/app/fixtures/experiments/playwright.locateInExample.ts @@ -1,4 +1,4 @@ -import { Page, Locator } from "@playwright/test"; +import type { Page, Locator } from "@playwright/test"; function locateWithinExample(page: Page, testId: string): Locator { return page.locator("#example").getByTestId(testId); diff --git a/examples/next/src/app/fixtures/experiments/playwright.setExperimentHeaders.ts b/examples/next/src/app/fixtures/experiments/playwright.setExperimentHeaders.ts index 20e0c84..4b16956 100644 --- a/examples/next/src/app/fixtures/experiments/playwright.setExperimentHeaders.ts +++ b/examples/next/src/app/fixtures/experiments/playwright.setExperimentHeaders.ts @@ -1,4 +1,4 @@ -import { +import type { TestType, PlaywrightTestArgs, PlaywrightTestOptions, @@ -6,7 +6,7 @@ import { PlaywrightWorkerOptions } from "@playwright/test"; -import { Experiments, Decision } from "./experiments"; +import type { Experiments, Decision } from "./experiments"; const setExperimentHeaders = ( test: TestType< diff --git a/examples/next/src/app/layout.tsx b/examples/next/src/app/layout.tsx index bcc6be7..76a927c 100644 --- a/examples/next/src/app/layout.tsx +++ b/examples/next/src/app/layout.tsx @@ -1,6 +1,6 @@ import { Didact_Gothic } from "next/font/google"; import styles from "./styles.module.css"; -import { ReactNode } from "react"; +import { type ReactNode } from "react"; const didactGothic = Didact_Gothic({ display: "swap", diff --git a/examples/next/src/components/control1.tsx b/examples/next/src/components/control1.tsx index 9e5ade3..3d55048 100644 --- a/examples/next/src/components/control1.tsx +++ b/examples/next/src/components/control1.tsx @@ -1,4 +1,4 @@ -import React, { ReactNode } from "react"; +import React, { type ReactNode } from "react"; import styles from "./styles.module.css"; interface Control1Props { diff --git a/examples/next/src/components/control2.tsx b/examples/next/src/components/control2.tsx index 01d0f02..5606522 100644 --- a/examples/next/src/components/control2.tsx +++ b/examples/next/src/components/control2.tsx @@ -1,4 +1,4 @@ -import React, { ReactNode } from "react"; +import React, { type ReactNode } from "react"; import styles from "./styles.module.css"; interface Control2Props { diff --git a/examples/next/src/components/variant1.tsx b/examples/next/src/components/variant1.tsx index 172c301..934c19f 100644 --- a/examples/next/src/components/variant1.tsx +++ b/examples/next/src/components/variant1.tsx @@ -1,4 +1,4 @@ -import React, { ReactNode } from "react"; +import React, { type ReactNode } from "react"; import styles from "./styles.module.css"; interface Variant1Props { diff --git a/examples/next/src/components/variant2.tsx b/examples/next/src/components/variant2.tsx index aa03206..d6b1c56 100644 --- a/examples/next/src/components/variant2.tsx +++ b/examples/next/src/components/variant2.tsx @@ -1,4 +1,4 @@ -import React, { ReactNode } from "react"; +import React, { type ReactNode } from "react"; import styles from "./styles.module.css"; interface Variant2Props { diff --git a/examples/serve/docs/CHANGELOG.md b/examples/serve/docs/CHANGELOG.md index b3f8ea1..c64642e 100644 --- a/examples/serve/docs/CHANGELOG.md +++ b/examples/serve/docs/CHANGELOG.md @@ -5,11 +5,22 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.2.7] - 2025-07-15 + +### Changed + +- Updated to named exports version of "features" package ([0.4.0](../../../packages/features/docs/CHANGELOG.md#040---2025-07-15)) + +### Fixed + +- import types explicitly from `@playwright/test` after unexpected pipeline failure +- updated pride image after update to windows chromium emojis + ## [0.2.6] - 2025-07-14 ### Changed -- updated to use `variantGlobs` array, with updated webpack plugin [0.8.0][version 0.8.0](../../../packages/webpack/docs/CHANGELOG.md#080---2025-05-27) +- updated to use `variantGlobs` array, with updated webpack plugin [version 0.8.0](../../../packages/webpack/docs/CHANGELOG.md#080---2025-05-27) ## [0.2.5] - 2025-07-14 diff --git a/examples/serve/package.json b/examples/serve/package.json index 0ea90d2..4835f1d 100644 --- a/examples/serve/package.json +++ b/examples/serve/package.json @@ -1,6 +1,6 @@ { "name": "web-toggle-point-serve-example", - "version": "0.2.6", + "version": "0.2.7", "type": "module", "private": true, "scripts": { diff --git a/examples/serve/playwright.config.ts b/examples/serve/playwright.config.ts index c0a196a..828417c 100644 --- a/examples/serve/playwright.config.ts +++ b/examples/serve/playwright.config.ts @@ -1,9 +1,9 @@ -import { defineConfig, PlaywrightTestConfig } from "@playwright/test"; +import { defineConfig, type PlaywrightTestConfig } from "@playwright/test"; import baseConfig from "../../test/automation/base.config"; const config: PlaywrightTestConfig = { ...baseConfig, - expect:{ + expect: { toMatchSnapshot: { maxDiffPixelRatio: 0.05 } diff --git a/examples/serve/src/fixtures/audience/__featuresStore.js b/examples/serve/src/fixtures/audience/__featuresStore.js index 515ddd0..9c89305 100644 --- a/examples/serve/src/fixtures/audience/__featuresStore.js +++ b/examples/serve/src/fixtures/audience/__featuresStore.js @@ -1,9 +1,10 @@ -import { globalFeaturesStoreFactory as featuresStoreFactory } from "@asos/web-toggle-point-features"; +// eslint-disable-next-line import/no-unresolved -- https://github.com/import-js/eslint-plugin-import/issues/1810 +import featuresStoreFactory from "@asos/web-toggle-point-features/storeFactories/globalFeaturesStoreFactory"; const featuresStore = featuresStoreFactory(); const [, audience] = document.cookie.match(/audience=(.+?)(;|$)/) || []; -featuresStore.useValue({ value: audience }); +featuresStore.setValue({ value: audience }); export default featuresStore; diff --git a/examples/serve/src/fixtures/config/__featuresStore.js b/examples/serve/src/fixtures/config/__featuresStore.js index 8654560..2ec0c5b 100644 --- a/examples/serve/src/fixtures/config/__featuresStore.js +++ b/examples/serve/src/fixtures/config/__featuresStore.js @@ -1,7 +1,8 @@ -import { globalFeaturesStoreFactory as featuresStoreFactory } from "@asos/web-toggle-point-features"; +// eslint-disable-next-line import/no-unresolved -- https://github.com/import-js/eslint-plugin-import/issues/1810 +import featuresStoreFactory from "@asos/web-toggle-point-features/storeFactories/globalFeaturesStoreFactory"; const featuresStore = featuresStoreFactory(); -featuresStore.useValue({ value: new URL(document.URL).pathname.slice(1) }); +featuresStore.setValue({ value: new URL(document.URL).pathname.slice(1) }); export default featuresStore; diff --git a/examples/serve/src/fixtures/event/__featuresStore.js b/examples/serve/src/fixtures/event/__featuresStore.js index 0c3bfa6..2cf89f9 100644 --- a/examples/serve/src/fixtures/event/__featuresStore.js +++ b/examples/serve/src/fixtures/event/__featuresStore.js @@ -1,4 +1,5 @@ -import { globalFeaturesStoreFactory as featuresStoreFactory } from "@asos/web-toggle-point-features"; +// eslint-disable-next-line import/no-unresolved -- https://github.com/import-js/eslint-plugin-import/issues/1810 +import featuresStoreFactory from "@asos/web-toggle-point-features/storeFactories/globalFeaturesStoreFactory"; const featuresStore = featuresStoreFactory(); @@ -15,6 +16,6 @@ const getEvent = () => { } }; -featuresStore.useValue({ value: getEvent() }); +featuresStore.setValue({ value: getEvent() }); export default featuresStore; diff --git a/examples/serve/src/fixtures/event/playwright.spec.ts-snapshots/-screenshots-pride-chromium-win32.png b/examples/serve/src/fixtures/event/playwright.spec.ts-snapshots/-screenshots-pride-chromium-win32.png index 758710d..70fb254 100644 Binary files a/examples/serve/src/fixtures/event/playwright.spec.ts-snapshots/-screenshots-pride-chromium-win32.png and b/examples/serve/src/fixtures/event/playwright.spec.ts-snapshots/-screenshots-pride-chromium-win32.png differ diff --git a/examples/serve/src/fixtures/translation/__featuresStore.js b/examples/serve/src/fixtures/translation/__featuresStore.js index d2c00a1..e58d224 100644 --- a/examples/serve/src/fixtures/translation/__featuresStore.js +++ b/examples/serve/src/fixtures/translation/__featuresStore.js @@ -1,8 +1,9 @@ -import { globalFeaturesStoreFactory as featuresStoreFactory } from "@asos/web-toggle-point-features"; +// eslint-disable-next-line import/no-unresolved -- https://github.com/import-js/eslint-plugin-import/issues/1810 +import featuresStoreFactory from "@asos/web-toggle-point-features/storeFactories/globalFeaturesStoreFactory"; const featuresStore = featuresStoreFactory(); -featuresStore.useValue({ +featuresStore.setValue({ value: navigator.language || document.documentElement.lang }); diff --git a/package-lock.json b/package-lock.json index df4b789..48e33c6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -57,7 +57,7 @@ }, "examples/express": { "name": "web-toggle-point-express-example", - "version": "0.2.5", + "version": "0.2.6", "dependencies": { "@asos/web-toggle-point-features": "file:../../packages/features", "@asos/web-toggle-point-react-pointcuts": "file:../../packages/react-pointcuts", @@ -89,7 +89,7 @@ }, "examples/next": { "name": "web-toggle-point-next-example", - "version": "0.2.4", + "version": "0.2.5", "dependencies": { "@asos/web-toggle-point-features": "file:../../packages/features", "@asos/web-toggle-point-react-pointcuts": "file:../../packages/react-pointcuts", @@ -116,7 +116,7 @@ }, "examples/serve": { "name": "web-toggle-point-serve-example", - "version": "0.2.6", + "version": "0.2.7", "dependencies": { "@asos/web-toggle-point-features": "file:../../packages/features", "@asos/web-toggle-point-webpack": "file:../../packages/webpack", @@ -19816,7 +19816,7 @@ }, "packages/features": { "name": "@asos/web-toggle-point-features", - "version": "0.3.4", + "version": "0.4.0", "license": "MIT", "dependencies": { "@babel/runtime": "^7.26.0" @@ -19864,7 +19864,7 @@ }, "packages/react-pointcuts": { "name": "@asos/web-toggle-point-react-pointcuts", - "version": "0.4.5", + "version": "0.4.6", "license": "MIT", "dependencies": { "@babel/runtime": "^7.26.0" @@ -19900,7 +19900,7 @@ }, "packages/ssr": { "name": "@asos/web-toggle-point-ssr", - "version": "0.2.3", + "version": "0.2.4", "license": "MIT", "dependencies": { "@babel/runtime": "^7.26.0", @@ -20035,7 +20035,7 @@ }, "test/automation": { "name": "web-toggle-point-automation-tests", - "version": "0.1.2", + "version": "0.1.3", "devDependencies": { "@playwright/test": "^1.49.0", "@types/node": "^22.9.1", diff --git a/packages/features/build/eslint-import-backfill.rollup.mjs b/packages/features/build/eslint-import-backfill.rollup.mjs new file mode 100644 index 0000000..e15795b --- /dev/null +++ b/packages/features/build/eslint-import-backfill.rollup.mjs @@ -0,0 +1,9 @@ +export default { + input: "./src/global.js", + output: { + file: "lib/global.js", + format: "es", + sourcemap: true + }, + treeshake: false +}; diff --git a/packages/features/build/rollup.mjs b/packages/features/build/rollup.mjs index 5185c31..56822b7 100644 --- a/packages/features/build/rollup.mjs +++ b/packages/features/build/rollup.mjs @@ -1,37 +1,35 @@ -import pkg from "../package.json" with { type: "json" }; import babel from "@rollup/plugin-babel"; import resolve from "@rollup/plugin-node-resolve"; import external from "rollup-plugin-auto-external"; import commonjs from "@rollup/plugin-commonjs"; import terser from "@rollup/plugin-terser"; import keepExternalComments from "./keepExternalComments.js"; +import { readdir } from "node:fs/promises"; + +export default async ({ config_isBrowser }) => { + const isBrowser = JSON.parse(config_isBrowser); + + const browserPrefix = isBrowser ? "browser." : ""; + + const input = (await readdir("./src/storeFactories")) + .filter( + (file) => + !file.endsWith(".test.js") && !(file.startsWith("node") && isBrowser) + ) + .map((factory) => `./src/storeFactories/${factory}`); -export default ({ config_isClient }) => { - const CLIENT = JSON.parse(config_isClient); - const [input, esOutputFile, cjsOutputFile, extraPlugins] = { - false: [ - "./src/node.js", - pkg.exports.node.import, - pkg.exports.node.require, - [] - ], - true: [ - "./src/browser.js", - pkg.exports.default.import, - pkg.exports.default.require, - [terser()] - ] - }[CLIENT]; return { input, output: [ { - file: esOutputFile, + dir: "lib/storeFactories/", + entryFileNames: `[name].${browserPrefix}js`, format: "es", sourcemap: true }, { - file: cjsOutputFile, + dir: "lib/storeFactories/", + entryFileNames: `[name].${browserPrefix}es5.cjs`, format: "cjs", sourcemap: true } @@ -48,7 +46,7 @@ export default ({ config_isClient }) => { }), commonjs(), external(), - ...extraPlugins + isBrowser ? [terser()] : [] ], preserveSymlinks: true }; diff --git a/packages/features/docs/CHANGELOG.md b/packages/features/docs/CHANGELOG.md index bd60f58..1e1d071 100644 --- a/packages/features/docs/CHANGELOG.md +++ b/packages/features/docs/CHANGELOG.md @@ -5,6 +5,19 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.4.0] - 2025-07-15 + +### Fixed + +- Moved to named exports, to ensure that the "ssr" package is not a dependency, unless importing the `ssrBackedReactContextFeaturesStoreFactory` + - This reverts to the intent of version [version 0.3.0](#030---2024-11-28), but not capitulating to ESLint's issues +- Support firefox by not using a `Symbol` as a `WeakMap` key (https://github.com/ASOS/web-toggle-point/issues/57) + +### Changed + +- renamed `useValue` from `SingletonFeaturesStore` interface to `setValue`, to avoid React [rules-of-hooks](https://react.dev/warnings/invalid-hook-call-warning) errors +- added a backfill main entry to `package.json` to support [missing exports / ESM support in `eslint-plugin-import`](https://github.com/import-js/eslint-plugin-import/issues/1810), for users of this + ## [0.3.4] - 2025-07-14 ### Fixed @@ -16,7 +29,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed - added `package.json` [homepage](https://docs.npmjs.com/cli/v11/configuring-npm/package-json#homepage), for clarity once on https://www.npmjs.com/ -- move the React 17 note to the end, in the `README.md`, since only relevant to the last two store factories & added companion note regarding `react-dom/server`. +- move the React 17 note to the end, in the `README.md`, since only relevant to the last two store factories & added companion note regarding `react-dom/server` ### Fixed diff --git a/packages/features/docs/README.md b/packages/features/docs/README.md index 4290324..04de567 100644 --- a/packages/features/docs/README.md +++ b/packages/features/docs/README.md @@ -12,15 +12,21 @@ See: [JSDoc output](https://asos.github.io/web-toggle-point/module-web-toggle-po ## Exports +> [!WARNING] +> This package uses [`package.json` exports](https://docs.npmjs.com/cli/v11/configuring-npm/package-json#exports) to specify individual stores (listed below), to ensure that browser / node specific stores can +> be individually imported and prevent build failures where, prior to tree-shaking, incompatible APIs / globals are referenced. +> Due to [a long-standing bug in `eslint-plugin-import`](https://github.com/import-js/eslint-plugin-import/issues/1810), users of eslint with this plugin may need to ignore an [`import/no-unresolved`](https://github.com/import-js/eslint-plugin-import/blob/main/docs/rules/no-unresolved.md) error, +> or move to a modern alternative for this plugin (e.g. [`eslint-plugin-import-x`](https://github.com/un-ts/eslint-plugin-import-x)), or use [a typescript parser](https://typescript-eslint.io/packages/parser/) (which understands `exports`) + The package contains the following exports: -### `globalFeaturesStoreFactory` +### `storeFactories/globalFeaturesStoreFactory` A "global" features store factory: a thin wrapper around a singleton, this is an extension point for future plugins etc. It exports a store with: -- a `useValue` function, that sets a current value. +- a `setValue` function, that sets a current value. - a `getFeatures` function - designed to be passed as the `getActiveFeatures` input of the `withTogglePointFactory` or `withToggledHookFactory` from the [`react-pointcuts` package](../../react-pointcuts/docs/README.md). @@ -47,12 +53,12 @@ const getActiveFeatures = useSnapshot.bind(undefined, value); // passed to `with ``` ...which will then re-render consuming components based on the parts of the toggle state they are reliant on. -### `nodeRequestScopedStoreFactory` +### `storeFactories/nodeRequestScopedFeaturesStoreFactory` A "request scoped" features store factory, for use in [Node](https://nodejs.org/). It exports a store with: -- a `useValue` function that sets a current value, taking a `scopeCallBack` (along with a `value`), under which the value is scoped. +- a `setValue` function that sets a current value, taking a `scopeCallBack` (along with a `value`), under which the value is scoped. - This is using [`AsyncLocalStorage.run`](https://nodejs.org/api/async_context.html#asynclocalstoragerunstore-callback-args) under the hood, which can be plugged into Express middleware thus: ```js import express from "express"; @@ -62,7 +68,7 @@ It exports a store with: app.use((request, response, next) => { const value = ?? // some value holding toggle state, either based on `request`, or scoped from outside this middleware, etc. - featuresStore.useValue({ value, scopeCallBack: next }); + featuresStore.setValue({ value, scopeCallBack: next }); }); app.use("/", () => { /* routes that require toggled code */ }); ``` @@ -70,9 +76,10 @@ It exports a store with: - designed to be passed as the `getActiveFeatures` input of the `withTogglePointFactory` or `withToggledHookFactory` from the [`react-pointcuts` package](../../react-pointcuts/docs/README.md). > [!WARNING] > This will throw an error if called outside of a request scope, so care should be taken to set up the toggle point config to only toggle modules called within the call stack of the middleware. +> Wrap the `setValue` call in a `try` / `catch`, if prior access is expected. > If this happens unexpectedly, follow the advice [here](https://nodejs.org/api/async_context.html#troubleshooting-context-loss). -### `reactContextFeaturesStoreFactory` +### `storeFactories/reactContextFeaturesStoreFactory` It exports a store with: - a `providerFactory` factory function, creating a [react context provider](https://reactjs.org/docs/context.html#contextprovider). @@ -81,7 +88,7 @@ It exports a store with: - this uses [`useContext`](https://react.dev/reference/react/useContext) internally, so should be used honouring the rules of hooks. It will make consumers reactive to any change of the toggle state. - can be passed to `getActiveFeatures` of `withTogglePointFactory` / `withToggledHookFactory` from the [`react-pointcuts` package](../../react-pointcuts/docs/README.md). -### `ssrBackedReactContextFeaturesStoreFactory` +### `storeFactories/ssrBackedReactContextFeaturesStoreFactory` It exports a store with the same signature as that exported by `reactContextFeaturesStoreFactory`. It utilises `withJsonIsomorphism` from the [`ssr` package](../../ssr/docs/README.md) internally, to create ["isomorphic" or "universal"](https://en.wikipedia.org/wiki/Isomorphic_JavaScript) contexts, for use in framework-less React applications. The value set on the server will be realised as the initial value within the browser. diff --git a/packages/features/package.json b/packages/features/package.json index f5a92a7..530a776 100644 --- a/packages/features/package.json +++ b/packages/features/package.json @@ -1,19 +1,22 @@ { "name": "@asos/web-toggle-point-features", "description": "toggle point features code", - "version": "0.3.4", + "version": "0.4.0", "license": "MIT", "type": "module", - "main": "./lib/main.es5.cjs", + "main": "./lib/global.js", "sideEffects": false, "exports": { - "node": { - "import": "./lib/main.js", - "require": "./lib/main.es5.cjs" - }, - "default": { - "import": "./lib/browser.js", - "require": "./lib/browser.es5.cjs" + ".": null, + "./*": { + "browser": { + "import": "./lib/*.browser.js", + "require": "./lib/*.browser.es5.cjs" + }, + "default": { + "import": "./lib/*.js", + "require": "./lib/*.es5.cjs" + } } }, "repository": { @@ -31,9 +34,10 @@ "scripts": { "build-dependencies": "path-exists ../../packages/ssr/lib || npm run --prefix ../../packages/ssr build", "prebuild": "npm run build-dependencies", - "build": "npm run clean && npm run build:browser && npm run build:server", - "build:browser": "cross-env BABEL_ENV=browser rollup -c build/rollup.mjs --config_isClient true", - "build:server": "rollup -c build/rollup.mjs --config_isClient false", + "build": "npm run clean && npm run build:browser && npm run build:server && npm run build:eslint-import-backfill", + "build:eslint-import-backfill": "rollup -c build/eslint-import-backfill.rollup.mjs", + "build:browser": "cross-env BABEL_ENV=browser rollup -c build/rollup.mjs --config_isBrowser true", + "build:server": "rollup -c build/rollup.mjs --config_isBrowser false", "prepublishOnly": "npm run build", "clean": "rimraf ./lib", "docs": "rimraf ./docs/**/*.html && jsdoc -c ../jsdoc.conf.js", diff --git a/packages/features/src/browser.js b/packages/features/src/browser.js deleted file mode 100644 index 972b8fa..0000000 --- a/packages/features/src/browser.js +++ /dev/null @@ -1,4 +0,0 @@ -import "./global"; -export { default as globalFeaturesStoreFactory } from "./global/store"; -export { default as reactContextFeaturesStoreFactory } from "./reactContext/store"; -export { default as ssrBackedReactContextFeaturesStoreFactory } from "./ssrBackedReactContext/store"; diff --git a/packages/features/src/global.js b/packages/features/src/global.js index bd618e8..7e8f4e3 100644 --- a/packages/features/src/global.js +++ b/packages/features/src/global.js @@ -31,7 +31,7 @@ import "./external"; * * @function * @memberof module:web-toggle-point-features - * @name SingletonFeaturesStore#useValue + * @name SingletonFeaturesStore#setValue * @param {object} params parameters * @param {object} params.value A value to store, used to drive feature toggles. */ diff --git a/packages/features/src/node.js b/packages/features/src/node.js deleted file mode 100644 index c4489a3..0000000 --- a/packages/features/src/node.js +++ /dev/null @@ -1,5 +0,0 @@ -import "./global"; -export { default as globalFeaturesStoreFactory } from "./global/store"; -export { default as nodeRequestScopedStoreFactory } from "./nodeRequestScoped/store"; -export { default as reactContextFeaturesStoreFactory } from "./reactContext/store"; -export { default as ssrBackedReactContextFeaturesStoreFactory } from "./ssrBackedReactContext/store"; diff --git a/packages/features/src/global/store.js b/packages/features/src/storeFactories/globalFeaturesStoreFactory.js similarity index 95% rename from packages/features/src/global/store.js rename to packages/features/src/storeFactories/globalFeaturesStoreFactory.js index 2a0c8da..9c9a4fc 100644 --- a/packages/features/src/global/store.js +++ b/packages/features/src/storeFactories/globalFeaturesStoreFactory.js @@ -12,7 +12,7 @@ const storeMap = new WeakMap(); * @returns {module:web-toggle-point-features.globalFeaturesStore} A store for features, held globally in the application. */ const globalFeaturesStoreFactory = () => { - const identifier = Symbol(); + const identifier = {}; /** * @name globalFeaturesStore * @memberof module:web-toggle-point-features @@ -20,7 +20,7 @@ const globalFeaturesStoreFactory = () => { * @implements module:web-toggle-point-features.SingletonFeaturesStore */ return { - useValue: ({ value }) => { + setValue: ({ value }) => { storeMap.set(identifier, value); }, getFeatures: () => storeMap.get(identifier) diff --git a/packages/features/src/global/store.test.js b/packages/features/src/storeFactories/globalFeaturesStoreFactory.test.js similarity index 80% rename from packages/features/src/global/store.test.js rename to packages/features/src/storeFactories/globalFeaturesStoreFactory.test.js index 67cbda6..126183d 100644 --- a/packages/features/src/global/store.test.js +++ b/packages/features/src/storeFactories/globalFeaturesStoreFactory.test.js @@ -1,4 +1,4 @@ -import globalFeaturesStoreFactory from "./store"; +import globalFeaturesStoreFactory from "./globalFeaturesStoreFactory"; describe("globalFeaturesStoreFactory", () => { let featuresStoreFactory; @@ -7,22 +7,22 @@ describe("globalFeaturesStoreFactory", () => { featuresStoreFactory = globalFeaturesStoreFactory(); }); - describe("when using a value", () => { + describe("when setting a value", () => { const value = Symbol("test-value"); beforeEach(() => { - featuresStoreFactory.useValue({ value }); + featuresStoreFactory.setValue({ value }); }); it("should store the value for later retrieval", () => { expect(featuresStoreFactory.getFeatures()).toBe(value); }); - describe("when using a different value", () => { + describe("when setting a different value", () => { const differentValue = Symbol("different-value"); beforeEach(() => { - featuresStoreFactory.useValue({ value: differentValue }); + featuresStoreFactory.setValue({ value: differentValue }); }); it("should store the new value for later retrieval", () => { diff --git a/packages/features/src/nodeRequestScoped/store.js b/packages/features/src/storeFactories/nodeRequestScopedFeaturesStoreFactory.js similarity index 74% rename from packages/features/src/nodeRequestScoped/store.js rename to packages/features/src/storeFactories/nodeRequestScopedFeaturesStoreFactory.js index c2232df..9e74106 100644 --- a/packages/features/src/nodeRequestScoped/store.js +++ b/packages/features/src/storeFactories/nodeRequestScopedFeaturesStoreFactory.js @@ -5,19 +5,19 @@ import { AsyncLocalStorage } from "async_hooks"; * Should only be used server-side, for anything user or request specific. * A thin wrapper around node {@link https://nodejs.org/api/async_context.html#class-asynclocalstorage|AsyncLocalStorage}, used as an extension point for future plugins. * @memberof module:web-toggle-point-features - * @returns {module:web-toggle-point-features.requestScopedFeaturesStore} A store for features, scoped for the current request. + * @returns {module:web-toggle-point-features.nodeRequestScopedFeaturesStore} A store for features, scoped for the current request. */ -const requestScopedFeaturesStoreFactory = () => { +const nodeRequestScopedFeaturesStoreFactory = () => { const store = new AsyncLocalStorage(); /** - * @name requestScopedFeaturesStore + * @name nodeRequestScopedFeaturesStore * @memberof module:web-toggle-point-features * @implements module:web-toggle-point-features.FeaturesStore * @implements module:web-toggle-point-features.SingletonFeaturesStore */ return { - useValue: ({ value, scopeCallBack }) => { + setValue: ({ value, scopeCallBack }) => { store.run(value, scopeCallBack); }, getFeatures: () => { @@ -30,4 +30,4 @@ const requestScopedFeaturesStoreFactory = () => { }; }; -export default requestScopedFeaturesStoreFactory; +export default nodeRequestScopedFeaturesStoreFactory; diff --git a/packages/features/src/nodeRequestScoped/store.test.js b/packages/features/src/storeFactories/nodeRequestScopedFeaturesStoreFactory.test.js similarity index 81% rename from packages/features/src/nodeRequestScoped/store.test.js rename to packages/features/src/storeFactories/nodeRequestScopedFeaturesStoreFactory.test.js index ed50279..86ae84d 100644 --- a/packages/features/src/nodeRequestScoped/store.test.js +++ b/packages/features/src/storeFactories/nodeRequestScopedFeaturesStoreFactory.test.js @@ -1,4 +1,4 @@ -import requestScopedStoreFactory from "./store"; +import nodeRequestScopedFeaturesStoreFactory from "./nodeRequestScopedFeaturesStoreFactory"; import { AsyncLocalStorage } from "async_hooks"; jest.mock("async_hooks", () => ({ @@ -8,11 +8,11 @@ jest.mock("async_hooks", () => ({ })) })); -describe("store", () => { +describe("nodeRequestScopedFeaturesStoreFactory", () => { let requestScopedStore; beforeEach(() => { - requestScopedStore = requestScopedStoreFactory(); + requestScopedStore = nodeRequestScopedFeaturesStoreFactory(); }); it("should create an AsyncLocalStorage store", () => { @@ -27,12 +27,12 @@ describe("store", () => { }); }); - describe("when using a value", () => { + describe("when setting a value", () => { const value = Symbol("test-value"); const scopeCallBack = Symbol("test-callback"); beforeEach(() => { - requestScopedStore.useValue({ value, scopeCallBack }); + requestScopedStore.setValue({ value, scopeCallBack }); }); it("should scope the value to the descendants of the callback, by running it in the local storage", () => { diff --git a/packages/features/src/reactContext/store.js b/packages/features/src/storeFactories/reactContextFeaturesStoreFactory.js similarity index 100% rename from packages/features/src/reactContext/store.js rename to packages/features/src/storeFactories/reactContextFeaturesStoreFactory.js diff --git a/packages/features/src/reactContext/store.test.js b/packages/features/src/storeFactories/reactContextFeaturesStoreFactory.test.js similarity index 84% rename from packages/features/src/reactContext/store.test.js rename to packages/features/src/storeFactories/reactContextFeaturesStoreFactory.test.js index f5e0344..e968a1e 100644 --- a/packages/features/src/reactContext/store.test.js +++ b/packages/features/src/storeFactories/reactContextFeaturesStoreFactory.test.js @@ -1,12 +1,12 @@ -import reactContextStoreFactory from "./store"; +import reactContextFeaturesStoreFactory from "./reactContextFeaturesStoreFactory"; import { render, screen } from "@testing-library/react"; -describe("reactContextStoreFactory", () => { +describe("reactContextFeaturesStoreFactory", () => { const name = "test-name"; let reactContextStore; beforeEach(() => { - reactContextStore = reactContextStoreFactory({ name }); + reactContextStore = reactContextFeaturesStoreFactory({ name }); }); describe("when creating a provider", () => { diff --git a/packages/features/src/ssrBackedReactContext/store.js b/packages/features/src/storeFactories/ssrBackedReactContextFeaturesStoreFactory.js similarity index 95% rename from packages/features/src/ssrBackedReactContext/store.js rename to packages/features/src/storeFactories/ssrBackedReactContextFeaturesStoreFactory.js index 44b624f..f2078b9 100644 --- a/packages/features/src/ssrBackedReactContext/store.js +++ b/packages/features/src/storeFactories/ssrBackedReactContextFeaturesStoreFactory.js @@ -1,5 +1,5 @@ import { withJsonIsomorphism } from "@asos/web-toggle-point-ssr"; -import reactContextFeaturesStoreFactory from "../reactContext/store"; +import reactContextFeaturesStoreFactory from "./reactContextFeaturesStoreFactory"; /** * A factory function used to create a store for features, held in a {@link https://reactjs.org/docs/context.html|React context}, backed by server-side rendering. diff --git a/packages/features/src/ssrBackedReactContext/store.test.js b/packages/features/src/storeFactories/ssrBackedReactContextFeaturesStoreFactory.test.js similarity index 89% rename from packages/features/src/ssrBackedReactContext/store.test.js rename to packages/features/src/storeFactories/ssrBackedReactContextFeaturesStoreFactory.test.js index 440d10d..0bfc09a 100644 --- a/packages/features/src/ssrBackedReactContext/store.test.js +++ b/packages/features/src/storeFactories/ssrBackedReactContextFeaturesStoreFactory.test.js @@ -1,7 +1,7 @@ import { withJsonIsomorphism } from "@asos/web-toggle-point-ssr"; import { render, screen } from "@testing-library/react"; -import reactContextFeaturesStoreFactory from "../reactContext/store"; -import ssrBackedReactContextFeaturesStoreFactory from "./store"; +import reactContextFeaturesStoreFactory from "./reactContextFeaturesStoreFactory"; +import ssrBackedReactContextFeaturesStoreFactory from "./ssrBackedReactContextFeaturesStoreFactory"; const MockSSRBackedFeaturesProvider = jest.fn(({ children }) => (
{children}
@@ -12,12 +12,12 @@ jest.mock("@asos/web-toggle-point-ssr", () => ({ const mockOtherStuff = { [Symbol("rest")]: Symbol("rest") }; -const mockReactContextStoreFactory = { +const mockReactContextFeaturesStoreFactory = { providerFactory: jest.fn(), ...mockOtherStuff }; -jest.mock("../reactContext/store", () => - jest.fn(() => mockReactContextStoreFactory) +jest.mock("./reactContextFeaturesStoreFactory", () => + jest.fn(() => mockReactContextFeaturesStoreFactory) ); describe("ssrBackedReactContextFeaturesStoreFactory", () => { @@ -52,7 +52,9 @@ describe("ssrBackedReactContextFeaturesStoreFactory", () => { }); it("should create a reactContextStore via the reactContextStoreFactory", () => { - expect(mockReactContextStoreFactory.providerFactory).toHaveBeenCalled(); + expect( + mockReactContextFeaturesStoreFactory.providerFactory + ).toHaveBeenCalled(); }); it("should create an SSR-backed react component that serializes the provided value in a script with a namespace & named id", () => { diff --git a/packages/react-pointcuts/build/rollup.mjs b/packages/react-pointcuts/build/rollup.mjs index d893632..4ac969c 100644 --- a/packages/react-pointcuts/build/rollup.mjs +++ b/packages/react-pointcuts/build/rollup.mjs @@ -9,8 +9,8 @@ import keepExternalComments from "./keepExternalComments.mjs"; export default ({ config_isClient }) => { const CLIENT = JSON.parse(config_isClient); const [esOutputFile, cjsOutputFile, extraPlugins] = { - false: [pkg.exports.node.import, pkg.exports.node.require, []], - true: [pkg.exports.default.import, pkg.exports.default.require, [terser()]] + false: [pkg.exports.default.import, pkg.exports.default.require, []], + true: [pkg.exports.browser.import, pkg.exports.browser.require, [terser()]] }[CLIENT]; return { diff --git a/packages/react-pointcuts/docs/CHANGELOG.md b/packages/react-pointcuts/docs/CHANGELOG.md index bad889d..df9c037 100644 --- a/packages/react-pointcuts/docs/CHANGELOG.md +++ b/packages/react-pointcuts/docs/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.4.6] - 2025-08-21 + +### Fixed + +- moved to `default` and `browser` exports from `node` and `default`, to support typescript module resolution + ## [0.4.5] - 2025-07-14 ### Fixed diff --git a/packages/react-pointcuts/package.json b/packages/react-pointcuts/package.json index 1543e49..a980125 100644 --- a/packages/react-pointcuts/package.json +++ b/packages/react-pointcuts/package.json @@ -1,18 +1,18 @@ { "name": "@asos/web-toggle-point-react-pointcuts", "description": "react pointcut code", - "version": "0.4.5", + "version": "0.4.6", "license": "MIT", "type": "module", "main": "./lib/main.es5.cjs", "exports": { - "node": { - "import": "./lib/main.js", - "require": "./lib/main.es5.cjs" - }, - "default": { + "browser": { "import": "./lib/browser.js", "require": "./lib/browser.es5.cjs" + }, + "default": { + "import": "./lib/main.js", + "require": "./lib/main.es5.cjs" } }, "repository": { diff --git a/packages/ssr/build/rollup.mjs b/packages/ssr/build/rollup.mjs index 3010b9e..8828873 100644 --- a/packages/ssr/build/rollup.mjs +++ b/packages/ssr/build/rollup.mjs @@ -10,8 +10,8 @@ import terser from "@rollup/plugin-terser"; export default ({ config_isClient }) => { const CLIENT = JSON.parse(config_isClient); const [esOutputFile, cjsOutputFile, extraPlugins] = { - false: [pkg.exports.node.import, pkg.exports.node.require, []], - true: [pkg.exports.default.import, pkg.exports.default.require, [terser()]] + false: [pkg.exports.default.import, pkg.exports.default.require, []], + true: [pkg.exports.browser.import, pkg.exports.browser.require, [terser()]] }[CLIENT]; return { diff --git a/packages/ssr/docs/CHANGELOG.md b/packages/ssr/docs/CHANGELOG.md index 058d6d5..2d4b99d 100644 --- a/packages/ssr/docs/CHANGELOG.md +++ b/packages/ssr/docs/CHANGELOG.md @@ -5,6 +5,13 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.2.4] - 2025-08-21 + +### Fixed + +- moved to `default` and `browser` exports from `node` and `default`, to support typescript module resolution +- support de-structuring of the serialization object returned by the serialization factory, via changed use of `this` + ## [0.2.3] - 2025-03-06 ### Changed diff --git a/packages/ssr/package.json b/packages/ssr/package.json index dcdc958..f3e4ea6 100644 --- a/packages/ssr/package.json +++ b/packages/ssr/package.json @@ -1,18 +1,18 @@ { "name": "@asos/web-toggle-point-ssr", "description": "toggle point server side rendering code", - "version": "0.2.3", + "version": "0.2.4", "license": "MIT", "type": "module", "main": "./lib/main.es5.cjs", "exports": { - "node": { - "import": "./lib/main.js", - "require": "./lib/main.es5.cjs" - }, - "default": { + "browser": { "import": "./lib/browser.js", "require": "./lib/browser.es5.cjs" + }, + "default": { + "import": "./lib/main.js", + "require": "./lib/main.es5.cjs" } }, "repository": { diff --git a/packages/ssr/src/serializationFactory/index.js b/packages/ssr/src/serializationFactory/index.js index c3e6794..f6addae 100644 --- a/packages/ssr/src/serializationFactory/index.js +++ b/packages/ssr/src/serializationFactory/index.js @@ -1,6 +1,13 @@ import jsesc from "jsesc"; import parse from "html-react-parser"; +const getScriptMarkup = (id, { content }) => { + return ``; +}; + // eslint-disable-next-line prettier/prettier, no-empty -- https://github.com/babel/babel/issues/15156 {} /** @@ -53,14 +60,14 @@ const serializationFactory = ({ id, logWarning }) => * @param {object} content The JSON content to be serialized. * @returns {string} A string containing markup for a type="application/json" script element with the specified content. */ - getScriptMarkup({ content }) { - return ``; - }, + getScriptMarkup: getScriptMarkup.bind(null, id), + /** + * @memberof module:web-toggle-point-ssr.serialization + * @param {object} content The JSON content to be serialized. + * @returns {external:React.Component} A react component for rendering a type="application/json" script element with the specified content. + */ getScriptReactElement(...args) { - return parse(this.getScriptMarkup(...args)); + return parse(getScriptMarkup.apply(null, [id, ...args])); }, getJSONFromScript() { const input = document.querySelector(`#${id}`)?.textContent; diff --git a/packages/ssr/src/serializationFactory/index.test.js b/packages/ssr/src/serializationFactory/index.test.js index 7bcd23b..ce72ef8 100644 --- a/packages/ssr/src/serializationFactory/index.test.js +++ b/packages/ssr/src/serializationFactory/index.test.js @@ -27,7 +27,8 @@ describe("serializationFactory", () => { let result; beforeEach(() => { - result = serialization.getScriptMarkup({ content }); + const { getScriptMarkup } = serialization; + result = getScriptMarkup({ content }); }); it("should return a string containing a JSON script tag, appropriately quoted by jsesc", () => { @@ -44,9 +45,8 @@ describe("serializationFactory", () => { describe("when rendering a scriptReactElement with React", () => { let result; beforeEach(() => { - ({ container: result } = render( - serialization.getScriptReactElement({ content }) - )); + const { getScriptReactElement } = serialization; + ({ container: result } = render(getScriptReactElement({ content }))); }); it("should return a react element containing a JSON script tag, appropriately quoted by jsesc", () => { @@ -69,8 +69,9 @@ describe("serializationFactory", () => { describe("when a valid JSON string is passed", () => { beforeEach(() => { + const { getJSONFromScript } = serialization; document.body.innerHTML = ``; - result = serialization.getJSONFromScript(); + result = getJSONFromScript(); }); afterEach(() => { @@ -88,8 +89,9 @@ describe("serializationFactory", () => { describe("when an invalid JSON string is passed", () => { beforeEach(() => { + const { getJSONFromScript } = serialization; document.body.innerHTML = ``; - result = serialization.getJSONFromScript(); + result = getJSONFromScript(); }); it("should have logged a warning", () => { diff --git a/test/automation/base.config.ts b/test/automation/base.config.ts index 3fa6253..d5f9920 100644 --- a/test/automation/base.config.ts +++ b/test/automation/base.config.ts @@ -1,4 +1,4 @@ -import { devices, ReporterDescription } from "@playwright/test"; +import { devices, type ReporterDescription } from "@playwright/test"; const baseConfig = { fullyParallel: true, diff --git a/test/automation/docs/CHANGELOG.md b/test/automation/docs/CHANGELOG.md index 6a53fe4..ca475a7 100644 --- a/test/automation/docs/CHANGELOG.md +++ b/test/automation/docs/CHANGELOG.md @@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). +## [0.1.3] - 2025-08-21 + +### Changed + +- move to import type for `ReporterDescription` + ## [0.1.2] - 2024-12-18 ### Fixed diff --git a/test/automation/package.json b/test/automation/package.json index 4798d47..70dd3cb 100644 --- a/test/automation/package.json +++ b/test/automation/package.json @@ -1,6 +1,6 @@ { "name": "web-toggle-point-automation-tests", - "version": "0.1.2", + "version": "0.1.3", "main": "index.js", "keywords": [], "type": "module",