From 4a39f641d5022df39e19870201e39dc3db984502 Mon Sep 17 00:00:00 2001 From: algolia-bot Date: Tue, 3 Sep 2024 13:53:00 +0000 Subject: [PATCH] chore(javascript): use tsup bundler (#3640) (generated) [skip ci] MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Clément Vannicatte --- .../base.tsup.config.ts | 10 +- .../packages/algoliasearch/builds/browser.ts | 8 +- .../packages/algoliasearch/builds/models.ts | 27 +++--- .../packages/algoliasearch/builds/node.ts | 7 +- .../packages/algoliasearch/index.d.ts | 2 +- .../packages/algoliasearch/index.js | 2 +- .../packages/algoliasearch/lite.d.ts | 2 +- .../packages/algoliasearch/lite.js | 2 +- .../packages/algoliasearch/package.json | 71 +++++++------- .../packages/algoliasearch/rollup.config.js | 35 ++++++- .../packages/algoliasearch/tsup.config.ts | 92 +++++++++++++++++++ .../packages/client-abtesting/index.d.ts | 2 +- .../packages/client-abtesting/index.js | 2 +- .../packages/client-abtesting/package.json | 45 ++++----- .../client-abtesting/rollup.config.js | 21 ++++- .../packages/client-abtesting/tsup.config.ts | 51 ++++++++++ .../packages/client-analytics/index.d.ts | 2 +- .../packages/client-analytics/index.js | 2 +- .../packages/client-analytics/package.json | 45 ++++----- .../client-analytics/rollup.config.js | 21 ++++- .../packages/client-analytics/tsup.config.ts | 51 ++++++++++ .../packages/client-insights/index.d.ts | 2 +- .../packages/client-insights/index.js | 2 +- .../packages/client-insights/package.json | 45 ++++----- .../packages/client-insights/rollup.config.js | 21 ++++- .../packages/client-insights/tsup.config.ts | 51 ++++++++++ .../client-personalization/index.d.ts | 2 +- .../packages/client-personalization/index.js | 2 +- .../client-personalization/package.json | 45 ++++----- .../client-personalization/rollup.config.js | 21 ++++- .../client-personalization/tsup.config.ts | 51 ++++++++++ .../client-query-suggestions/index.d.ts | 2 +- .../client-query-suggestions/index.js | 2 +- .../client-query-suggestions/package.json | 45 ++++----- .../client-query-suggestions/rollup.config.js | 21 ++++- .../client-query-suggestions/tsup.config.ts | 51 ++++++++++ .../packages/client-search/index.d.ts | 2 +- .../packages/client-search/index.js | 2 +- .../packages/client-search/package.json | 45 ++++----- .../packages/client-search/rollup.config.js | 21 ++++- .../packages/client-search/tsup.config.ts | 51 ++++++++++ .../packages/client-usage/index.d.ts | 2 +- .../packages/client-usage/index.js | 2 +- .../packages/client-usage/package.json | 45 ++++----- .../packages/client-usage/rollup.config.js | 21 ++++- .../packages/client-usage/tsup.config.ts | 51 ++++++++++ .../packages/ingestion/index.d.ts | 2 +- .../packages/ingestion/index.js | 2 +- .../packages/ingestion/package.json | 45 ++++----- .../packages/ingestion/rollup.config.js | 21 ++++- .../packages/ingestion/tsup.config.ts | 51 ++++++++++ .../packages/monitoring/index.d.ts | 2 +- .../packages/monitoring/index.js | 2 +- .../packages/monitoring/package.json | 45 ++++----- .../packages/monitoring/rollup.config.js | 21 ++++- .../packages/monitoring/tsup.config.ts | 51 ++++++++++ .../packages/recommend/index.d.ts | 2 +- .../packages/recommend/index.js | 2 +- .../packages/recommend/package.json | 45 ++++----- .../packages/recommend/rollup.config.js | 21 ++++- .../packages/recommend/tsup.config.ts | 51 ++++++++++ 61 files changed, 1118 insertions(+), 350 deletions(-) create mode 100644 clients/algoliasearch-client-javascript/packages/algoliasearch/tsup.config.ts create mode 100644 clients/algoliasearch-client-javascript/packages/client-abtesting/tsup.config.ts create mode 100644 clients/algoliasearch-client-javascript/packages/client-analytics/tsup.config.ts create mode 100644 clients/algoliasearch-client-javascript/packages/client-insights/tsup.config.ts create mode 100644 clients/algoliasearch-client-javascript/packages/client-personalization/tsup.config.ts create mode 100644 clients/algoliasearch-client-javascript/packages/client-query-suggestions/tsup.config.ts create mode 100644 clients/algoliasearch-client-javascript/packages/client-search/tsup.config.ts create mode 100644 clients/algoliasearch-client-javascript/packages/client-usage/tsup.config.ts create mode 100644 clients/algoliasearch-client-javascript/packages/ingestion/tsup.config.ts create mode 100644 clients/algoliasearch-client-javascript/packages/monitoring/tsup.config.ts create mode 100644 clients/algoliasearch-client-javascript/packages/recommend/tsup.config.ts diff --git a/clients/algoliasearch-client-javascript/base.tsup.config.ts b/clients/algoliasearch-client-javascript/base.tsup.config.ts index f3bb7f54af..f47307929f 100644 --- a/clients/algoliasearch-client-javascript/base.tsup.config.ts +++ b/clients/algoliasearch-client-javascript/base.tsup.config.ts @@ -16,18 +16,18 @@ export function getBaseConfig(cwd: string): Options { }; } -export function getDependencies(pkg: PKG, env: 'node' | 'browser'): string[] { +export function getDependencies(pkg: PKG, env: 'browser' | 'node'): string[] { const deps = Object.keys(pkg.dependencies || {}) || []; - if (pkg.name !== "algoliasearch") { - return deps + if (pkg.name !== 'algoliasearch') { + return deps; } if (env === 'node') { - return deps.filter(dep => dep !== '@algolia/requester-browser-xhr') + return deps.filter((dep) => dep !== '@algolia/requester-browser-xhr'); } - return deps.filter(dep => dep !== '@algolia/requester-node-http') + return deps.filter((dep) => dep !== '@algolia/requester-node-http'); } export function getBaseNodeOptions(pkg: PKG, cwd: string): Options { diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch/builds/browser.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch/builds/browser.ts index 5cc045cbcc..9a551d3f91 100644 --- a/clients/algoliasearch-client-javascript/packages/algoliasearch/builds/browser.ts +++ b/clients/algoliasearch-client-javascript/packages/algoliasearch/builds/browser.ts @@ -4,7 +4,6 @@ import type { AbtestingClient, Region as AbtestingRegion } from '@algolia/client import { abtestingClient } from '@algolia/client-abtesting'; import type { AnalyticsClient, Region as AnalyticsRegion } from '@algolia/client-analytics'; import { analyticsClient } from '@algolia/client-analytics'; -import type { ClientOptions } from '@algolia/client-common'; import { DEFAULT_CONNECT_TIMEOUT_BROWSER, DEFAULT_READ_TIMEOUT_BROWSER, @@ -13,19 +12,19 @@ import { createFallbackableCache, createMemoryCache, } from '@algolia/client-common'; +import type { ClientOptions } from '@algolia/client-common'; import type { PersonalizationClient, Region as PersonalizationRegion } from '@algolia/client-personalization'; import { personalizationClient } from '@algolia/client-personalization'; -import { searchClient, apiClientVersion as searchClientVersion } from '@algolia/client-search'; +import { searchClient } from '@algolia/client-search'; import type { RecommendClient } from '@algolia/recommend'; import { recommendClient } from '@algolia/recommend'; import { createXhrRequester } from '@algolia/requester-browser-xhr'; import type { InitClientOptions, InitClientRegion } from './models'; +import { apiClientVersion } from './models'; export * from './models'; -export const apiClientVersion = searchClientVersion; - /** * The client type. */ @@ -40,7 +39,6 @@ export function algoliasearch(appId: string, apiKey: string, options?: ClientOpt if (!apiKey || typeof apiKey !== 'string') { throw new Error('`apiKey` is missing.'); } - function initRecommend(initOptions: InitClientOptions = {}): RecommendClient { return recommendClient(initOptions.appId || appId, initOptions.apiKey || apiKey, initOptions.options); } diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch/builds/models.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch/builds/models.ts index e16edc0fe3..2d3d93ee8a 100644 --- a/clients/algoliasearch-client-javascript/packages/algoliasearch/builds/models.ts +++ b/clients/algoliasearch-client-javascript/packages/algoliasearch/builds/models.ts @@ -1,7 +1,9 @@ // Code generated by OpenAPI Generator (https://openapi-generator.tech), manual changes will be lost - read more on https://github.com/algolia/api-clients-automation. DO NOT EDIT. +import type { Region as ABTestingRegion } from '@algolia/client-abtesting'; +import type { Region as AnalyticsRegion } from '@algolia/client-analytics'; import type { ClientOptions } from '@algolia/client-common'; -import { +import type { AdvancedSyntaxFeatures, AlternativesAsExact, Anchoring, @@ -74,19 +76,16 @@ import { TypoTolerance, TypoToleranceEnum, Value, -} from '@algolia/client-search/model'; +} from '@algolia/client-search'; +import { apiClientVersion } from '@algolia/client-search'; -export * from '@algolia/client-search/model'; -export * from '@algolia/recommend/model'; -export * from '@algolia/client-personalization/model'; -export * from '@algolia/client-analytics/model'; -export * from '@algolia/client-abtesting/model'; +type Region = ABTestingRegion | AnalyticsRegion; -export { SearchClient } from '@algolia/client-search'; -export { RecommendClient } from '@algolia/recommend'; -export { PersonalizationClient } from '@algolia/client-personalization'; -export { AnalyticsClient } from '@algolia/client-analytics'; -export { AbtestingClient } from '@algolia/client-abtesting'; +export * from '@algolia/client-search'; +export * from '@algolia/recommend'; +export * from '@algolia/client-personalization'; +export * from '@algolia/client-analytics'; +export * from '@algolia/client-abtesting'; export { AdvancedSyntaxFeatures, @@ -161,6 +160,10 @@ export { TypoTolerance, TypoToleranceEnum, Value, + AnalyticsRegion, + ABTestingRegion, + Region, + apiClientVersion, }; /** diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch/builds/node.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch/builds/node.ts index 981a5320c0..5dad6cf77c 100644 --- a/clients/algoliasearch-client-javascript/packages/algoliasearch/builds/node.ts +++ b/clients/algoliasearch-client-javascript/packages/algoliasearch/builds/node.ts @@ -6,7 +6,6 @@ import type { AbtestingClient, Region as AbtestingRegion } from '@algolia/client import { abtestingClient } from '@algolia/client-abtesting'; import type { AnalyticsClient, Region as AnalyticsRegion } from '@algolia/client-analytics'; import { analyticsClient } from '@algolia/client-analytics'; -import type { ClientOptions } from '@algolia/client-common'; import { DEFAULT_CONNECT_TIMEOUT_NODE, DEFAULT_READ_TIMEOUT_NODE, @@ -15,9 +14,10 @@ import { createNullCache, serializeQueryParameters, } from '@algolia/client-common'; +import type { ClientOptions } from '@algolia/client-common'; import type { PersonalizationClient, Region as PersonalizationRegion } from '@algolia/client-personalization'; import { personalizationClient } from '@algolia/client-personalization'; -import { searchClient, apiClientVersion as searchClientVersion } from '@algolia/client-search'; +import { searchClient } from '@algolia/client-search'; import type { RecommendClient } from '@algolia/recommend'; import { recommendClient } from '@algolia/recommend'; import { createHttpRequester } from '@algolia/requester-node-http'; @@ -31,8 +31,6 @@ import type { export * from './models'; -export const apiClientVersion = searchClientVersion; - /** * The client type. */ @@ -47,7 +45,6 @@ export function algoliasearch(appId: string, apiKey: string, options?: ClientOpt if (!apiKey || typeof apiKey !== 'string') { throw new Error('`apiKey` is missing.'); } - function initRecommend(initOptions: InitClientOptions = {}): RecommendClient { return recommendClient(initOptions.appId || appId, initOptions.apiKey || apiKey, initOptions.options); } diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch/index.d.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch/index.d.ts index 7b4d638346..23eac31bdc 100644 --- a/clients/algoliasearch-client-javascript/packages/algoliasearch/index.d.ts +++ b/clients/algoliasearch-client-javascript/packages/algoliasearch/index.d.ts @@ -1,2 +1,2 @@ // eslint-disable-next-line import/no-unresolved -export * from './dist/algoliasearch/builds/node'; +export * from './dist/node'; diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch/index.js b/clients/algoliasearch-client-javascript/packages/algoliasearch/index.js index 1c2d3c260e..d0b8a28f98 100644 --- a/clients/algoliasearch-client-javascript/packages/algoliasearch/index.js +++ b/clients/algoliasearch-client-javascript/packages/algoliasearch/index.js @@ -1,2 +1,2 @@ // eslint-disable-next-line import/no-commonjs,import/extensions -module.exports = require('./dist/algoliasearch.cjs'); \ No newline at end of file +module.exports = require('./dist/node.cjs'); \ No newline at end of file diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch/lite.d.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch/lite.d.ts index 290ed7b79d..0401197d31 100644 --- a/clients/algoliasearch-client-javascript/packages/algoliasearch/lite.d.ts +++ b/clients/algoliasearch-client-javascript/packages/algoliasearch/lite.d.ts @@ -1,2 +1,2 @@ // eslint-disable-next-line import/no-unresolved -export * from './dist/lite/builds/node'; +export * from './dist/lite/node'; diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch/lite.js b/clients/algoliasearch-client-javascript/packages/algoliasearch/lite.js index f12ed2a451..b579d99350 100644 --- a/clients/algoliasearch-client-javascript/packages/algoliasearch/lite.js +++ b/clients/algoliasearch-client-javascript/packages/algoliasearch/lite.js @@ -1,2 +1,2 @@ // eslint-disable-next-line import/no-commonjs,import/extensions -module.exports = require('./dist/lite/lite.cjs'); \ No newline at end of file +module.exports = require('./dist/lite/builds/node.cjs'); \ No newline at end of file diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch/package.json b/clients/algoliasearch-client-javascript/packages/algoliasearch/package.json index 93db1c2c25..6789900430 100644 --- a/clients/algoliasearch-client-javascript/packages/algoliasearch/package.json +++ b/clients/algoliasearch-client-javascript/packages/algoliasearch/package.json @@ -7,49 +7,54 @@ "type": "module", "license": "MIT", "author": "Algolia", - "types": "./index.d.ts", + "scripts": { + "build": "yarn clean && yarn tsup && yarn rollup -c rollup.config.js", + "clean": "rm -rf ./dist || true", + "test": "jest", + "test:bundle": "publint . && attw --pack ." + }, "name": "algoliasearch", "description": "A fully-featured and blazing-fast JavaScript API client to interact with Algolia API.", - "jsdelivr": "./dist/algoliasearch.umd.js", - "unpkg": "./dist/algoliasearch.umd.js", - "browser": { - "./index.js": "./dist/algoliasearch.umd.js", - "./lite.js": "./dist/lite/lite.umd.js" - }, "exports": { ".": { "node": { - "import": "./dist/algoliasearch.esm.node.js", - "module": "./dist/algoliasearch.esm.node.js", - "require": "./dist/algoliasearch.cjs", - "default": "./dist/algoliasearch.cjs", - "types": "./dist/algoliasearch/builds/node.d.ts" + "types": { + "import": "./dist/node.d.ts", + "module": "./dist/node.d.ts", + "require": "./dist/node.d.cts" + }, + "import": "./dist/node.js", + "module": "./dist/node.js", + "require": "./dist/node.cjs" }, - "browser": { - "umd": "./dist/algoliasearch.umd.js", - "module": "./dist/algoliasearch.esm.browser.js", - "import": "./dist/algoliasearch.esm.browser.js", - "default": "./dist/algoliasearch.umd.js", - "types": "./dist/algoliasearch/builds/browser.d.ts" + "default": { + "types": "./dist/browser.d.ts", + "module": "./dist/browser.js", + "import": "./dist/browser.js", + "default": "./dist/algoliasearch.umd.js" } }, "./lite": { "node": { - "import": "./dist/lite/lite.esm.node.js", - "module": "./dist/lite/lite.esm.node.js", - "require": "./dist/lite/lite.cjs", - "default": "./dist/lite/lite.cjs", - "types": "./dist/lite/builds/node.d.ts" + "types": { + "import": "./dist/lite/node.d.ts", + "module": "./dist/lite/node.d.ts", + "require": "./dist/lite/node.d.cts" + }, + "import": "./dist/lite/builds/node.js", + "module": "./dist/lite/builds/node.js", + "require": "./dist/lite/builds/node.cjs" }, - "browser": { - "umd": "./dist/lite/lite.umd.js", - "module": "./dist/lite/lite.esm.browser.js", - "import": "./dist/lite/lite.esm.browser.js", - "default": "./dist/lite/lite.umd.js", - "types": "./dist/lite/builds/browser.d.ts" + "default": { + "types": "./dist/lite/browser.d.ts", + "module": "./dist/lite/builds/browser.js", + "import": "./dist/lite/builds/browser.js", + "default": "./dist/lite/builds/browser.umd.js" } } }, + "jsdelivr": "./dist/algoliasearch.umd.js", + "unpkg": "./dist/algoliasearch.umd.js", "files": [ "dist", "builds", @@ -59,11 +64,6 @@ "lite.js", "lite.d.ts" ], - "scripts": { - "build": "yarn clean && rollup --config", - "clean": "rm -rf ./dist || true", - "test": "jest" - }, "dependencies": { "@algolia/client-abtesting": "5.2.4", "@algolia/client-analytics": "5.2.4", @@ -75,12 +75,15 @@ "@algolia/requester-node-http": "5.2.4" }, "devDependencies": { + "@arethetypeswrong/cli": "0.15.4", "@babel/preset-env": "7.25.4", "@babel/preset-typescript": "7.24.7", "@types/jest": "29.5.12", "@types/node": "22.5.1", "jest": "29.7.0", + "publint": "0.2.10", "rollup": "4.21.2", + "tsup": "8.2.4", "typescript": "5.5.4" }, "engines": { diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch/rollup.config.js b/clients/algoliasearch-client-javascript/packages/algoliasearch/rollup.config.js index 0f45d3972b..babd2ccf7c 100644 --- a/clients/algoliasearch-client-javascript/packages/algoliasearch/rollup.config.js +++ b/clients/algoliasearch-client-javascript/packages/algoliasearch/rollup.config.js @@ -1,5 +1,30 @@ -import { buildConfigs } from '../../base.rollup.config.js'; - -import pkg from './package.json' with { type: 'json' }; - -export default buildConfigs(pkg); \ No newline at end of file +export default [ + { + input: 'dist/lite/builds/browser.min.js', + external: ['dom'], + output: { + esModule: false, + file: 'dist/lite/builds/browser.umd.js', + name: 'lite', + format: 'umd', + sourcemap: false, + globals: { + ['lite']: 'lite', + }, + }, + }, + { + input: 'dist/browser.min.js', + external: ['dom'], + output: { + esModule: false, + file: 'dist/algoliasearch.umd.js', + name: 'algoliasearch', + format: 'umd', + sourcemap: false, + globals: { + ['algoliasearch']: 'algoliasearch', + }, + }, + } +] \ No newline at end of file diff --git a/clients/algoliasearch-client-javascript/packages/algoliasearch/tsup.config.ts b/clients/algoliasearch-client-javascript/packages/algoliasearch/tsup.config.ts new file mode 100644 index 0000000000..bdb085e353 --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/algoliasearch/tsup.config.ts @@ -0,0 +1,92 @@ +import type { Options } from 'tsup'; +import { defineConfig } from 'tsup'; + +import { getBaseNodeOptions, getBaseBrowserOptions, getDependencies } from '../../base.tsup.config'; + +import pkg from './package.json' with { type: 'json' }; + +const nodeOptions: Options = { + ...getBaseNodeOptions(pkg, __dirname), + dts: { entry: { node: 'lite/builds/node.ts' } }, + entry: ['lite/builds/node.ts', 'lite/src/*.ts'], + + outDir: 'dist/lite', +}; + +const nodeConfigs: Options[] = [ + { + ...nodeOptions, + format: 'cjs', + name: 'node lite cjs', + }, + { + ...nodeOptions, + format: 'esm', + name: 'node lite esm', + }, + { + ...nodeOptions, + format: 'cjs', + name: 'node cjs', + dts: { entry: { node: 'builds/node.ts' } }, + entry: ['builds/node.ts'], + outDir: 'dist', + }, + { + ...nodeOptions, + format: 'esm', + name: 'node esm', + dts: { entry: { node: 'builds/node.ts' } }, + entry: ['builds/node.ts'], + outDir: 'dist', + }, +]; + +const browserOptions: Options = { + ...getBaseBrowserOptions(pkg, __dirname), + + globalName: 'lite', + outDir: 'dist/lite', +}; + +const browserConfigs: Options[] = [ + { + ...browserOptions, + minify: false, + name: 'browser esm', + dts: { entry: { browser: 'lite/builds/browser.ts' } }, + entry: ['lite/builds/browser.ts', 'lite/src/*.ts'], + external: ['dom', '@algolia/client-common', '@algolia/requester-browser-xhr'], + }, + { + ...browserOptions, + dts: false, + minify: true, + name: 'browser min esm', + entry: { 'builds/browser.min': 'lite/builds/browser.ts' }, + external: [], + noExternal: ['dom', '@algolia/client-common', '@algolia/requester-browser-xhr'], + }, + { + ...browserOptions, + name: 'algoliasearch esm', + globalName: 'algoliasearch', + dts: { entry: { browser: 'builds/browser.ts' } }, + entry: ['builds/browser.ts'], + outDir: 'dist', + minify: false, + }, + { + ...browserOptions, + name: 'algoliasearch min esm', + globalName: 'algoliasearch', + dts: false, + minify: true, + entry: { 'browser.min': 'builds/browser.ts' }, + outDir: 'dist', + external: [], + noExternal: getDependencies(pkg, 'browser'), + }, +]; + +export default defineConfig([...nodeConfigs, ...browserConfigs]); diff --git a/clients/algoliasearch-client-javascript/packages/client-abtesting/index.d.ts b/clients/algoliasearch-client-javascript/packages/client-abtesting/index.d.ts index 8b0a7c887a..23eac31bdc 100644 --- a/clients/algoliasearch-client-javascript/packages/client-abtesting/index.d.ts +++ b/clients/algoliasearch-client-javascript/packages/client-abtesting/index.d.ts @@ -1,2 +1,2 @@ // eslint-disable-next-line import/no-unresolved -export * from './dist/builds/node'; +export * from './dist/node'; diff --git a/clients/algoliasearch-client-javascript/packages/client-abtesting/index.js b/clients/algoliasearch-client-javascript/packages/client-abtesting/index.js index 99d7d6fca5..5ae95ae019 100644 --- a/clients/algoliasearch-client-javascript/packages/client-abtesting/index.js +++ b/clients/algoliasearch-client-javascript/packages/client-abtesting/index.js @@ -1,2 +1,2 @@ // eslint-disable-next-line import/no-commonjs,import/extensions -module.exports = require('./dist/client-abtesting.cjs'); \ No newline at end of file +module.exports = require('./dist/builds/node.cjs'); \ No newline at end of file diff --git a/clients/algoliasearch-client-javascript/packages/client-abtesting/package.json b/clients/algoliasearch-client-javascript/packages/client-abtesting/package.json index 1c43ec8706..986601df92 100644 --- a/clients/algoliasearch-client-javascript/packages/client-abtesting/package.json +++ b/clients/algoliasearch-client-javascript/packages/client-abtesting/package.json @@ -7,50 +7,53 @@ "type": "module", "license": "MIT", "author": "Algolia", - "types": "./index.d.ts", + "scripts": { + "build": "yarn clean && yarn tsup && yarn rollup -c rollup.config.js", + "clean": "rm -rf ./dist || true", + "test:bundle": "publint . && attw --pack ." + }, "name": "@algolia/client-abtesting", "description": "JavaScript client for client-abtesting", - "jsdelivr": "./dist/client-abtesting.umd.js", - "unpkg": "./dist/client-abtesting.umd.js", - "browser": "./dist/client-abtesting.umd.js", "exports": { ".": { "node": { - "import": "./dist/client-abtesting.esm.node.js", - "module": "./dist/client-abtesting.esm.node.js", - "require": "./dist/client-abtesting.cjs", - "default": "./dist/client-abtesting.cjs", - "types": "./dist/builds/node.d.ts" + "types": { + "import": "./dist/node.d.ts", + "module": "./dist/node.d.ts", + "require": "./dist/node.d.cts" + }, + "import": "./dist/builds/node.js", + "module": "./dist/builds/node.js", + "require": "./dist/builds/node.cjs" }, - "browser": { - "umd": "./dist/client-abtesting.umd.js", - "module": "./dist/client-abtesting.esm.browser.js", - "import": "./dist/client-abtesting.esm.browser.js", - "default": "./dist/client-abtesting.umd.js", - "types": "./dist/builds/browser.d.ts" + "default": { + "types": "./dist/browser.d.ts", + "module": "./dist/builds/browser.js", + "import": "./dist/builds/browser.js", + "default": "./dist/builds/browser.umd.js" } }, - "./src/*": "./src/*.ts", - "./model": "./model/index.ts" + "./src/*": "./src/*.ts" }, + "jsdelivr": "./dist/builds/browser.umd.js", + "unpkg": "./dist/builds/browser.umd.js", "files": [ "dist", "model", "index.js", "index.d.ts" ], - "scripts": { - "build": "yarn clean && rollup --config", - "clean": "rm -rf ./dist || true" - }, "dependencies": { "@algolia/client-common": "5.2.4", "@algolia/requester-browser-xhr": "5.2.4", "@algolia/requester-node-http": "5.2.4" }, "devDependencies": { + "@arethetypeswrong/cli": "0.15.4", "@types/node": "22.5.1", + "publint": "0.2.10", "rollup": "4.21.2", + "tsup": "8.2.4", "typescript": "5.5.4" }, "engines": { diff --git a/clients/algoliasearch-client-javascript/packages/client-abtesting/rollup.config.js b/clients/algoliasearch-client-javascript/packages/client-abtesting/rollup.config.js index 0f45d3972b..e7228cbeb4 100644 --- a/clients/algoliasearch-client-javascript/packages/client-abtesting/rollup.config.js +++ b/clients/algoliasearch-client-javascript/packages/client-abtesting/rollup.config.js @@ -1,5 +1,16 @@ -import { buildConfigs } from '../../base.rollup.config.js'; - -import pkg from './package.json' with { type: 'json' }; - -export default buildConfigs(pkg); \ No newline at end of file +export default [ + { + input: 'dist/builds/browser.min.js', + external: ['dom'], + output: { + esModule: false, + file: 'dist/builds/browser.umd.js', + name: 'abtestingClient', + format: 'umd', + sourcemap: false, + globals: { + ['abtestingClient']: 'abtestingClient', + }, + }, + }, +] \ No newline at end of file diff --git a/clients/algoliasearch-client-javascript/packages/client-abtesting/tsup.config.ts b/clients/algoliasearch-client-javascript/packages/client-abtesting/tsup.config.ts new file mode 100644 index 0000000000..49593d63b4 --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-abtesting/tsup.config.ts @@ -0,0 +1,51 @@ +import type { Options } from 'tsup'; +import { defineConfig } from 'tsup'; + +import { getBaseNodeOptions, getBaseBrowserOptions, getDependencies } from '../../base.tsup.config'; + +import pkg from './package.json' with { type: 'json' }; + +const nodeOptions: Options = { + ...getBaseNodeOptions(pkg, __dirname), + dts: { entry: { node: 'builds/node.ts' } }, + entry: ['builds/node.ts', 'src/*.ts'], +}; + +const nodeConfigs: Options[] = [ + { + ...nodeOptions, + format: 'cjs', + name: 'node cjs', + }, + { + ...nodeOptions, + format: 'esm', + name: 'node esm', + }, +]; + +const browserOptions: Options = { + ...getBaseBrowserOptions(pkg, __dirname), + globalName: 'abtestingClient', +}; + +const browserConfigs: Options[] = [ + { + ...browserOptions, + minify: false, + name: 'browser esm', + dts: { entry: { browser: 'builds/browser.ts' } }, + entry: ['builds/browser.ts', 'src/*.ts'], + }, + { + ...browserOptions, + dts: false, + minify: true, + name: 'browser min esm', + entry: { 'builds/browser.min': 'builds/browser.ts' }, + external: [], + noExternal: getDependencies(pkg, 'browser'), + }, +]; + +export default defineConfig([...nodeConfigs, ...browserConfigs]); diff --git a/clients/algoliasearch-client-javascript/packages/client-analytics/index.d.ts b/clients/algoliasearch-client-javascript/packages/client-analytics/index.d.ts index 8b0a7c887a..23eac31bdc 100644 --- a/clients/algoliasearch-client-javascript/packages/client-analytics/index.d.ts +++ b/clients/algoliasearch-client-javascript/packages/client-analytics/index.d.ts @@ -1,2 +1,2 @@ // eslint-disable-next-line import/no-unresolved -export * from './dist/builds/node'; +export * from './dist/node'; diff --git a/clients/algoliasearch-client-javascript/packages/client-analytics/index.js b/clients/algoliasearch-client-javascript/packages/client-analytics/index.js index 3fe43ed6a2..5ae95ae019 100644 --- a/clients/algoliasearch-client-javascript/packages/client-analytics/index.js +++ b/clients/algoliasearch-client-javascript/packages/client-analytics/index.js @@ -1,2 +1,2 @@ // eslint-disable-next-line import/no-commonjs,import/extensions -module.exports = require('./dist/client-analytics.cjs'); \ No newline at end of file +module.exports = require('./dist/builds/node.cjs'); \ No newline at end of file diff --git a/clients/algoliasearch-client-javascript/packages/client-analytics/package.json b/clients/algoliasearch-client-javascript/packages/client-analytics/package.json index 67197380d7..c49376865b 100644 --- a/clients/algoliasearch-client-javascript/packages/client-analytics/package.json +++ b/clients/algoliasearch-client-javascript/packages/client-analytics/package.json @@ -7,50 +7,53 @@ "type": "module", "license": "MIT", "author": "Algolia", - "types": "./index.d.ts", + "scripts": { + "build": "yarn clean && yarn tsup && yarn rollup -c rollup.config.js", + "clean": "rm -rf ./dist || true", + "test:bundle": "publint . && attw --pack ." + }, "name": "@algolia/client-analytics", "description": "JavaScript client for client-analytics", - "jsdelivr": "./dist/client-analytics.umd.js", - "unpkg": "./dist/client-analytics.umd.js", - "browser": "./dist/client-analytics.umd.js", "exports": { ".": { "node": { - "import": "./dist/client-analytics.esm.node.js", - "module": "./dist/client-analytics.esm.node.js", - "require": "./dist/client-analytics.cjs", - "default": "./dist/client-analytics.cjs", - "types": "./dist/builds/node.d.ts" + "types": { + "import": "./dist/node.d.ts", + "module": "./dist/node.d.ts", + "require": "./dist/node.d.cts" + }, + "import": "./dist/builds/node.js", + "module": "./dist/builds/node.js", + "require": "./dist/builds/node.cjs" }, - "browser": { - "umd": "./dist/client-analytics.umd.js", - "module": "./dist/client-analytics.esm.browser.js", - "import": "./dist/client-analytics.esm.browser.js", - "default": "./dist/client-analytics.umd.js", - "types": "./dist/builds/browser.d.ts" + "default": { + "types": "./dist/browser.d.ts", + "module": "./dist/builds/browser.js", + "import": "./dist/builds/browser.js", + "default": "./dist/builds/browser.umd.js" } }, - "./src/*": "./src/*.ts", - "./model": "./model/index.ts" + "./src/*": "./src/*.ts" }, + "jsdelivr": "./dist/builds/browser.umd.js", + "unpkg": "./dist/builds/browser.umd.js", "files": [ "dist", "model", "index.js", "index.d.ts" ], - "scripts": { - "build": "yarn clean && rollup --config", - "clean": "rm -rf ./dist || true" - }, "dependencies": { "@algolia/client-common": "5.2.4", "@algolia/requester-browser-xhr": "5.2.4", "@algolia/requester-node-http": "5.2.4" }, "devDependencies": { + "@arethetypeswrong/cli": "0.15.4", "@types/node": "22.5.1", + "publint": "0.2.10", "rollup": "4.21.2", + "tsup": "8.2.4", "typescript": "5.5.4" }, "engines": { diff --git a/clients/algoliasearch-client-javascript/packages/client-analytics/rollup.config.js b/clients/algoliasearch-client-javascript/packages/client-analytics/rollup.config.js index 0f45d3972b..da9d3e46c2 100644 --- a/clients/algoliasearch-client-javascript/packages/client-analytics/rollup.config.js +++ b/clients/algoliasearch-client-javascript/packages/client-analytics/rollup.config.js @@ -1,5 +1,16 @@ -import { buildConfigs } from '../../base.rollup.config.js'; - -import pkg from './package.json' with { type: 'json' }; - -export default buildConfigs(pkg); \ No newline at end of file +export default [ + { + input: 'dist/builds/browser.min.js', + external: ['dom'], + output: { + esModule: false, + file: 'dist/builds/browser.umd.js', + name: 'analyticsClient', + format: 'umd', + sourcemap: false, + globals: { + ['analyticsClient']: 'analyticsClient', + }, + }, + }, +] \ No newline at end of file diff --git a/clients/algoliasearch-client-javascript/packages/client-analytics/tsup.config.ts b/clients/algoliasearch-client-javascript/packages/client-analytics/tsup.config.ts new file mode 100644 index 0000000000..9d99b0bbcc --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-analytics/tsup.config.ts @@ -0,0 +1,51 @@ +import type { Options } from 'tsup'; +import { defineConfig } from 'tsup'; + +import { getBaseNodeOptions, getBaseBrowserOptions, getDependencies } from '../../base.tsup.config'; + +import pkg from './package.json' with { type: 'json' }; + +const nodeOptions: Options = { + ...getBaseNodeOptions(pkg, __dirname), + dts: { entry: { node: 'builds/node.ts' } }, + entry: ['builds/node.ts', 'src/*.ts'], +}; + +const nodeConfigs: Options[] = [ + { + ...nodeOptions, + format: 'cjs', + name: 'node cjs', + }, + { + ...nodeOptions, + format: 'esm', + name: 'node esm', + }, +]; + +const browserOptions: Options = { + ...getBaseBrowserOptions(pkg, __dirname), + globalName: 'analyticsClient', +}; + +const browserConfigs: Options[] = [ + { + ...browserOptions, + minify: false, + name: 'browser esm', + dts: { entry: { browser: 'builds/browser.ts' } }, + entry: ['builds/browser.ts', 'src/*.ts'], + }, + { + ...browserOptions, + dts: false, + minify: true, + name: 'browser min esm', + entry: { 'builds/browser.min': 'builds/browser.ts' }, + external: [], + noExternal: getDependencies(pkg, 'browser'), + }, +]; + +export default defineConfig([...nodeConfigs, ...browserConfigs]); diff --git a/clients/algoliasearch-client-javascript/packages/client-insights/index.d.ts b/clients/algoliasearch-client-javascript/packages/client-insights/index.d.ts index 8b0a7c887a..23eac31bdc 100644 --- a/clients/algoliasearch-client-javascript/packages/client-insights/index.d.ts +++ b/clients/algoliasearch-client-javascript/packages/client-insights/index.d.ts @@ -1,2 +1,2 @@ // eslint-disable-next-line import/no-unresolved -export * from './dist/builds/node'; +export * from './dist/node'; diff --git a/clients/algoliasearch-client-javascript/packages/client-insights/index.js b/clients/algoliasearch-client-javascript/packages/client-insights/index.js index e720addb48..5ae95ae019 100644 --- a/clients/algoliasearch-client-javascript/packages/client-insights/index.js +++ b/clients/algoliasearch-client-javascript/packages/client-insights/index.js @@ -1,2 +1,2 @@ // eslint-disable-next-line import/no-commonjs,import/extensions -module.exports = require('./dist/client-insights.cjs'); \ No newline at end of file +module.exports = require('./dist/builds/node.cjs'); \ No newline at end of file diff --git a/clients/algoliasearch-client-javascript/packages/client-insights/package.json b/clients/algoliasearch-client-javascript/packages/client-insights/package.json index 95df22c20e..bc31df3d01 100644 --- a/clients/algoliasearch-client-javascript/packages/client-insights/package.json +++ b/clients/algoliasearch-client-javascript/packages/client-insights/package.json @@ -7,50 +7,53 @@ "type": "module", "license": "MIT", "author": "Algolia", - "types": "./index.d.ts", + "scripts": { + "build": "yarn clean && yarn tsup && yarn rollup -c rollup.config.js", + "clean": "rm -rf ./dist || true", + "test:bundle": "publint . && attw --pack ." + }, "name": "@algolia/client-insights", "description": "JavaScript client for client-insights", - "jsdelivr": "./dist/client-insights.umd.js", - "unpkg": "./dist/client-insights.umd.js", - "browser": "./dist/client-insights.umd.js", "exports": { ".": { "node": { - "import": "./dist/client-insights.esm.node.js", - "module": "./dist/client-insights.esm.node.js", - "require": "./dist/client-insights.cjs", - "default": "./dist/client-insights.cjs", - "types": "./dist/builds/node.d.ts" + "types": { + "import": "./dist/node.d.ts", + "module": "./dist/node.d.ts", + "require": "./dist/node.d.cts" + }, + "import": "./dist/builds/node.js", + "module": "./dist/builds/node.js", + "require": "./dist/builds/node.cjs" }, - "browser": { - "umd": "./dist/client-insights.umd.js", - "module": "./dist/client-insights.esm.browser.js", - "import": "./dist/client-insights.esm.browser.js", - "default": "./dist/client-insights.umd.js", - "types": "./dist/builds/browser.d.ts" + "default": { + "types": "./dist/browser.d.ts", + "module": "./dist/builds/browser.js", + "import": "./dist/builds/browser.js", + "default": "./dist/builds/browser.umd.js" } }, - "./src/*": "./src/*.ts", - "./model": "./model/index.ts" + "./src/*": "./src/*.ts" }, + "jsdelivr": "./dist/builds/browser.umd.js", + "unpkg": "./dist/builds/browser.umd.js", "files": [ "dist", "model", "index.js", "index.d.ts" ], - "scripts": { - "build": "yarn clean && rollup --config", - "clean": "rm -rf ./dist || true" - }, "dependencies": { "@algolia/client-common": "5.2.4", "@algolia/requester-browser-xhr": "5.2.4", "@algolia/requester-node-http": "5.2.4" }, "devDependencies": { + "@arethetypeswrong/cli": "0.15.4", "@types/node": "22.5.1", + "publint": "0.2.10", "rollup": "4.21.2", + "tsup": "8.2.4", "typescript": "5.5.4" }, "engines": { diff --git a/clients/algoliasearch-client-javascript/packages/client-insights/rollup.config.js b/clients/algoliasearch-client-javascript/packages/client-insights/rollup.config.js index 0f45d3972b..fa52dfa433 100644 --- a/clients/algoliasearch-client-javascript/packages/client-insights/rollup.config.js +++ b/clients/algoliasearch-client-javascript/packages/client-insights/rollup.config.js @@ -1,5 +1,16 @@ -import { buildConfigs } from '../../base.rollup.config.js'; - -import pkg from './package.json' with { type: 'json' }; - -export default buildConfigs(pkg); \ No newline at end of file +export default [ + { + input: 'dist/builds/browser.min.js', + external: ['dom'], + output: { + esModule: false, + file: 'dist/builds/browser.umd.js', + name: 'insightsClient', + format: 'umd', + sourcemap: false, + globals: { + ['insightsClient']: 'insightsClient', + }, + }, + }, +] \ No newline at end of file diff --git a/clients/algoliasearch-client-javascript/packages/client-insights/tsup.config.ts b/clients/algoliasearch-client-javascript/packages/client-insights/tsup.config.ts new file mode 100644 index 0000000000..1461ab762c --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-insights/tsup.config.ts @@ -0,0 +1,51 @@ +import type { Options } from 'tsup'; +import { defineConfig } from 'tsup'; + +import { getBaseNodeOptions, getBaseBrowserOptions, getDependencies } from '../../base.tsup.config'; + +import pkg from './package.json' with { type: 'json' }; + +const nodeOptions: Options = { + ...getBaseNodeOptions(pkg, __dirname), + dts: { entry: { node: 'builds/node.ts' } }, + entry: ['builds/node.ts', 'src/*.ts'], +}; + +const nodeConfigs: Options[] = [ + { + ...nodeOptions, + format: 'cjs', + name: 'node cjs', + }, + { + ...nodeOptions, + format: 'esm', + name: 'node esm', + }, +]; + +const browserOptions: Options = { + ...getBaseBrowserOptions(pkg, __dirname), + globalName: 'insightsClient', +}; + +const browserConfigs: Options[] = [ + { + ...browserOptions, + minify: false, + name: 'browser esm', + dts: { entry: { browser: 'builds/browser.ts' } }, + entry: ['builds/browser.ts', 'src/*.ts'], + }, + { + ...browserOptions, + dts: false, + minify: true, + name: 'browser min esm', + entry: { 'builds/browser.min': 'builds/browser.ts' }, + external: [], + noExternal: getDependencies(pkg, 'browser'), + }, +]; + +export default defineConfig([...nodeConfigs, ...browserConfigs]); diff --git a/clients/algoliasearch-client-javascript/packages/client-personalization/index.d.ts b/clients/algoliasearch-client-javascript/packages/client-personalization/index.d.ts index 8b0a7c887a..23eac31bdc 100644 --- a/clients/algoliasearch-client-javascript/packages/client-personalization/index.d.ts +++ b/clients/algoliasearch-client-javascript/packages/client-personalization/index.d.ts @@ -1,2 +1,2 @@ // eslint-disable-next-line import/no-unresolved -export * from './dist/builds/node'; +export * from './dist/node'; diff --git a/clients/algoliasearch-client-javascript/packages/client-personalization/index.js b/clients/algoliasearch-client-javascript/packages/client-personalization/index.js index b44eed22db..5ae95ae019 100644 --- a/clients/algoliasearch-client-javascript/packages/client-personalization/index.js +++ b/clients/algoliasearch-client-javascript/packages/client-personalization/index.js @@ -1,2 +1,2 @@ // eslint-disable-next-line import/no-commonjs,import/extensions -module.exports = require('./dist/client-personalization.cjs'); \ No newline at end of file +module.exports = require('./dist/builds/node.cjs'); \ No newline at end of file diff --git a/clients/algoliasearch-client-javascript/packages/client-personalization/package.json b/clients/algoliasearch-client-javascript/packages/client-personalization/package.json index 9eab421261..2eaa3b6e33 100644 --- a/clients/algoliasearch-client-javascript/packages/client-personalization/package.json +++ b/clients/algoliasearch-client-javascript/packages/client-personalization/package.json @@ -7,50 +7,53 @@ "type": "module", "license": "MIT", "author": "Algolia", - "types": "./index.d.ts", + "scripts": { + "build": "yarn clean && yarn tsup && yarn rollup -c rollup.config.js", + "clean": "rm -rf ./dist || true", + "test:bundle": "publint . && attw --pack ." + }, "name": "@algolia/client-personalization", "description": "JavaScript client for client-personalization", - "jsdelivr": "./dist/client-personalization.umd.js", - "unpkg": "./dist/client-personalization.umd.js", - "browser": "./dist/client-personalization.umd.js", "exports": { ".": { "node": { - "import": "./dist/client-personalization.esm.node.js", - "module": "./dist/client-personalization.esm.node.js", - "require": "./dist/client-personalization.cjs", - "default": "./dist/client-personalization.cjs", - "types": "./dist/builds/node.d.ts" + "types": { + "import": "./dist/node.d.ts", + "module": "./dist/node.d.ts", + "require": "./dist/node.d.cts" + }, + "import": "./dist/builds/node.js", + "module": "./dist/builds/node.js", + "require": "./dist/builds/node.cjs" }, - "browser": { - "umd": "./dist/client-personalization.umd.js", - "module": "./dist/client-personalization.esm.browser.js", - "import": "./dist/client-personalization.esm.browser.js", - "default": "./dist/client-personalization.umd.js", - "types": "./dist/builds/browser.d.ts" + "default": { + "types": "./dist/browser.d.ts", + "module": "./dist/builds/browser.js", + "import": "./dist/builds/browser.js", + "default": "./dist/builds/browser.umd.js" } }, - "./src/*": "./src/*.ts", - "./model": "./model/index.ts" + "./src/*": "./src/*.ts" }, + "jsdelivr": "./dist/builds/browser.umd.js", + "unpkg": "./dist/builds/browser.umd.js", "files": [ "dist", "model", "index.js", "index.d.ts" ], - "scripts": { - "build": "yarn clean && rollup --config", - "clean": "rm -rf ./dist || true" - }, "dependencies": { "@algolia/client-common": "5.2.4", "@algolia/requester-browser-xhr": "5.2.4", "@algolia/requester-node-http": "5.2.4" }, "devDependencies": { + "@arethetypeswrong/cli": "0.15.4", "@types/node": "22.5.1", + "publint": "0.2.10", "rollup": "4.21.2", + "tsup": "8.2.4", "typescript": "5.5.4" }, "engines": { diff --git a/clients/algoliasearch-client-javascript/packages/client-personalization/rollup.config.js b/clients/algoliasearch-client-javascript/packages/client-personalization/rollup.config.js index 0f45d3972b..a4c8c9ce01 100644 --- a/clients/algoliasearch-client-javascript/packages/client-personalization/rollup.config.js +++ b/clients/algoliasearch-client-javascript/packages/client-personalization/rollup.config.js @@ -1,5 +1,16 @@ -import { buildConfigs } from '../../base.rollup.config.js'; - -import pkg from './package.json' with { type: 'json' }; - -export default buildConfigs(pkg); \ No newline at end of file +export default [ + { + input: 'dist/builds/browser.min.js', + external: ['dom'], + output: { + esModule: false, + file: 'dist/builds/browser.umd.js', + name: 'personalizationClient', + format: 'umd', + sourcemap: false, + globals: { + ['personalizationClient']: 'personalizationClient', + }, + }, + }, +] \ No newline at end of file diff --git a/clients/algoliasearch-client-javascript/packages/client-personalization/tsup.config.ts b/clients/algoliasearch-client-javascript/packages/client-personalization/tsup.config.ts new file mode 100644 index 0000000000..d9ac33de74 --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-personalization/tsup.config.ts @@ -0,0 +1,51 @@ +import type { Options } from 'tsup'; +import { defineConfig } from 'tsup'; + +import { getBaseNodeOptions, getBaseBrowserOptions, getDependencies } from '../../base.tsup.config'; + +import pkg from './package.json' with { type: 'json' }; + +const nodeOptions: Options = { + ...getBaseNodeOptions(pkg, __dirname), + dts: { entry: { node: 'builds/node.ts' } }, + entry: ['builds/node.ts', 'src/*.ts'], +}; + +const nodeConfigs: Options[] = [ + { + ...nodeOptions, + format: 'cjs', + name: 'node cjs', + }, + { + ...nodeOptions, + format: 'esm', + name: 'node esm', + }, +]; + +const browserOptions: Options = { + ...getBaseBrowserOptions(pkg, __dirname), + globalName: 'personalizationClient', +}; + +const browserConfigs: Options[] = [ + { + ...browserOptions, + minify: false, + name: 'browser esm', + dts: { entry: { browser: 'builds/browser.ts' } }, + entry: ['builds/browser.ts', 'src/*.ts'], + }, + { + ...browserOptions, + dts: false, + minify: true, + name: 'browser min esm', + entry: { 'builds/browser.min': 'builds/browser.ts' }, + external: [], + noExternal: getDependencies(pkg, 'browser'), + }, +]; + +export default defineConfig([...nodeConfigs, ...browserConfigs]); diff --git a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/index.d.ts b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/index.d.ts index 8b0a7c887a..23eac31bdc 100644 --- a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/index.d.ts +++ b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/index.d.ts @@ -1,2 +1,2 @@ // eslint-disable-next-line import/no-unresolved -export * from './dist/builds/node'; +export * from './dist/node'; diff --git a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/index.js b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/index.js index 1b4a63910d..5ae95ae019 100644 --- a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/index.js +++ b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/index.js @@ -1,2 +1,2 @@ // eslint-disable-next-line import/no-commonjs,import/extensions -module.exports = require('./dist/client-query-suggestions.cjs'); \ No newline at end of file +module.exports = require('./dist/builds/node.cjs'); \ No newline at end of file diff --git a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/package.json b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/package.json index 016656e5ad..0a9d4baba1 100644 --- a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/package.json +++ b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/package.json @@ -7,50 +7,53 @@ "type": "module", "license": "MIT", "author": "Algolia", - "types": "./index.d.ts", + "scripts": { + "build": "yarn clean && yarn tsup && yarn rollup -c rollup.config.js", + "clean": "rm -rf ./dist || true", + "test:bundle": "publint . && attw --pack ." + }, "name": "@algolia/client-query-suggestions", "description": "JavaScript client for client-query-suggestions", - "jsdelivr": "./dist/client-query-suggestions.umd.js", - "unpkg": "./dist/client-query-suggestions.umd.js", - "browser": "./dist/client-query-suggestions.umd.js", "exports": { ".": { "node": { - "import": "./dist/client-query-suggestions.esm.node.js", - "module": "./dist/client-query-suggestions.esm.node.js", - "require": "./dist/client-query-suggestions.cjs", - "default": "./dist/client-query-suggestions.cjs", - "types": "./dist/builds/node.d.ts" + "types": { + "import": "./dist/node.d.ts", + "module": "./dist/node.d.ts", + "require": "./dist/node.d.cts" + }, + "import": "./dist/builds/node.js", + "module": "./dist/builds/node.js", + "require": "./dist/builds/node.cjs" }, - "browser": { - "umd": "./dist/client-query-suggestions.umd.js", - "module": "./dist/client-query-suggestions.esm.browser.js", - "import": "./dist/client-query-suggestions.esm.browser.js", - "default": "./dist/client-query-suggestions.umd.js", - "types": "./dist/builds/browser.d.ts" + "default": { + "types": "./dist/browser.d.ts", + "module": "./dist/builds/browser.js", + "import": "./dist/builds/browser.js", + "default": "./dist/builds/browser.umd.js" } }, - "./src/*": "./src/*.ts", - "./model": "./model/index.ts" + "./src/*": "./src/*.ts" }, + "jsdelivr": "./dist/builds/browser.umd.js", + "unpkg": "./dist/builds/browser.umd.js", "files": [ "dist", "model", "index.js", "index.d.ts" ], - "scripts": { - "build": "yarn clean && rollup --config", - "clean": "rm -rf ./dist || true" - }, "dependencies": { "@algolia/client-common": "5.2.4", "@algolia/requester-browser-xhr": "5.2.4", "@algolia/requester-node-http": "5.2.4" }, "devDependencies": { + "@arethetypeswrong/cli": "0.15.4", "@types/node": "22.5.1", + "publint": "0.2.10", "rollup": "4.21.2", + "tsup": "8.2.4", "typescript": "5.5.4" }, "engines": { diff --git a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/rollup.config.js b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/rollup.config.js index 0f45d3972b..6e9190910b 100644 --- a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/rollup.config.js +++ b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/rollup.config.js @@ -1,5 +1,16 @@ -import { buildConfigs } from '../../base.rollup.config.js'; - -import pkg from './package.json' with { type: 'json' }; - -export default buildConfigs(pkg); \ No newline at end of file +export default [ + { + input: 'dist/builds/browser.min.js', + external: ['dom'], + output: { + esModule: false, + file: 'dist/builds/browser.umd.js', + name: 'querySuggestionsClient', + format: 'umd', + sourcemap: false, + globals: { + ['querySuggestionsClient']: 'querySuggestionsClient', + }, + }, + }, +] \ No newline at end of file diff --git a/clients/algoliasearch-client-javascript/packages/client-query-suggestions/tsup.config.ts b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/tsup.config.ts new file mode 100644 index 0000000000..483607a8c1 --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-query-suggestions/tsup.config.ts @@ -0,0 +1,51 @@ +import type { Options } from 'tsup'; +import { defineConfig } from 'tsup'; + +import { getBaseNodeOptions, getBaseBrowserOptions, getDependencies } from '../../base.tsup.config'; + +import pkg from './package.json' with { type: 'json' }; + +const nodeOptions: Options = { + ...getBaseNodeOptions(pkg, __dirname), + dts: { entry: { node: 'builds/node.ts' } }, + entry: ['builds/node.ts', 'src/*.ts'], +}; + +const nodeConfigs: Options[] = [ + { + ...nodeOptions, + format: 'cjs', + name: 'node cjs', + }, + { + ...nodeOptions, + format: 'esm', + name: 'node esm', + }, +]; + +const browserOptions: Options = { + ...getBaseBrowserOptions(pkg, __dirname), + globalName: 'querySuggestionsClient', +}; + +const browserConfigs: Options[] = [ + { + ...browserOptions, + minify: false, + name: 'browser esm', + dts: { entry: { browser: 'builds/browser.ts' } }, + entry: ['builds/browser.ts', 'src/*.ts'], + }, + { + ...browserOptions, + dts: false, + minify: true, + name: 'browser min esm', + entry: { 'builds/browser.min': 'builds/browser.ts' }, + external: [], + noExternal: getDependencies(pkg, 'browser'), + }, +]; + +export default defineConfig([...nodeConfigs, ...browserConfigs]); diff --git a/clients/algoliasearch-client-javascript/packages/client-search/index.d.ts b/clients/algoliasearch-client-javascript/packages/client-search/index.d.ts index 8b0a7c887a..23eac31bdc 100644 --- a/clients/algoliasearch-client-javascript/packages/client-search/index.d.ts +++ b/clients/algoliasearch-client-javascript/packages/client-search/index.d.ts @@ -1,2 +1,2 @@ // eslint-disable-next-line import/no-unresolved -export * from './dist/builds/node'; +export * from './dist/node'; diff --git a/clients/algoliasearch-client-javascript/packages/client-search/index.js b/clients/algoliasearch-client-javascript/packages/client-search/index.js index f39dabcb50..5ae95ae019 100644 --- a/clients/algoliasearch-client-javascript/packages/client-search/index.js +++ b/clients/algoliasearch-client-javascript/packages/client-search/index.js @@ -1,2 +1,2 @@ // eslint-disable-next-line import/no-commonjs,import/extensions -module.exports = require('./dist/client-search.cjs'); \ No newline at end of file +module.exports = require('./dist/builds/node.cjs'); \ No newline at end of file diff --git a/clients/algoliasearch-client-javascript/packages/client-search/package.json b/clients/algoliasearch-client-javascript/packages/client-search/package.json index b2ad1cce0b..4036726a9f 100644 --- a/clients/algoliasearch-client-javascript/packages/client-search/package.json +++ b/clients/algoliasearch-client-javascript/packages/client-search/package.json @@ -7,50 +7,53 @@ "type": "module", "license": "MIT", "author": "Algolia", - "types": "./index.d.ts", + "scripts": { + "build": "yarn clean && yarn tsup && yarn rollup -c rollup.config.js", + "clean": "rm -rf ./dist || true", + "test:bundle": "publint . && attw --pack ." + }, "name": "@algolia/client-search", "description": "JavaScript client for client-search", - "jsdelivr": "./dist/client-search.umd.js", - "unpkg": "./dist/client-search.umd.js", - "browser": "./dist/client-search.umd.js", "exports": { ".": { "node": { - "import": "./dist/client-search.esm.node.js", - "module": "./dist/client-search.esm.node.js", - "require": "./dist/client-search.cjs", - "default": "./dist/client-search.cjs", - "types": "./dist/builds/node.d.ts" + "types": { + "import": "./dist/node.d.ts", + "module": "./dist/node.d.ts", + "require": "./dist/node.d.cts" + }, + "import": "./dist/builds/node.js", + "module": "./dist/builds/node.js", + "require": "./dist/builds/node.cjs" }, - "browser": { - "umd": "./dist/client-search.umd.js", - "module": "./dist/client-search.esm.browser.js", - "import": "./dist/client-search.esm.browser.js", - "default": "./dist/client-search.umd.js", - "types": "./dist/builds/browser.d.ts" + "default": { + "types": "./dist/browser.d.ts", + "module": "./dist/builds/browser.js", + "import": "./dist/builds/browser.js", + "default": "./dist/builds/browser.umd.js" } }, - "./src/*": "./src/*.ts", - "./model": "./model/index.ts" + "./src/*": "./src/*.ts" }, + "jsdelivr": "./dist/builds/browser.umd.js", + "unpkg": "./dist/builds/browser.umd.js", "files": [ "dist", "model", "index.js", "index.d.ts" ], - "scripts": { - "build": "yarn clean && rollup --config", - "clean": "rm -rf ./dist || true" - }, "dependencies": { "@algolia/client-common": "5.2.4", "@algolia/requester-browser-xhr": "5.2.4", "@algolia/requester-node-http": "5.2.4" }, "devDependencies": { + "@arethetypeswrong/cli": "0.15.4", "@types/node": "22.5.1", + "publint": "0.2.10", "rollup": "4.21.2", + "tsup": "8.2.4", "typescript": "5.5.4" }, "engines": { diff --git a/clients/algoliasearch-client-javascript/packages/client-search/rollup.config.js b/clients/algoliasearch-client-javascript/packages/client-search/rollup.config.js index 0f45d3972b..a21d9b202c 100644 --- a/clients/algoliasearch-client-javascript/packages/client-search/rollup.config.js +++ b/clients/algoliasearch-client-javascript/packages/client-search/rollup.config.js @@ -1,5 +1,16 @@ -import { buildConfigs } from '../../base.rollup.config.js'; - -import pkg from './package.json' with { type: 'json' }; - -export default buildConfigs(pkg); \ No newline at end of file +export default [ + { + input: 'dist/builds/browser.min.js', + external: ['dom'], + output: { + esModule: false, + file: 'dist/builds/browser.umd.js', + name: 'searchClient', + format: 'umd', + sourcemap: false, + globals: { + ['searchClient']: 'searchClient', + }, + }, + }, +] \ No newline at end of file diff --git a/clients/algoliasearch-client-javascript/packages/client-search/tsup.config.ts b/clients/algoliasearch-client-javascript/packages/client-search/tsup.config.ts new file mode 100644 index 0000000000..08d516268c --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-search/tsup.config.ts @@ -0,0 +1,51 @@ +import type { Options } from 'tsup'; +import { defineConfig } from 'tsup'; + +import { getBaseNodeOptions, getBaseBrowserOptions, getDependencies } from '../../base.tsup.config'; + +import pkg from './package.json' with { type: 'json' }; + +const nodeOptions: Options = { + ...getBaseNodeOptions(pkg, __dirname), + dts: { entry: { node: 'builds/node.ts' } }, + entry: ['builds/node.ts', 'src/*.ts'], +}; + +const nodeConfigs: Options[] = [ + { + ...nodeOptions, + format: 'cjs', + name: 'node cjs', + }, + { + ...nodeOptions, + format: 'esm', + name: 'node esm', + }, +]; + +const browserOptions: Options = { + ...getBaseBrowserOptions(pkg, __dirname), + globalName: 'searchClient', +}; + +const browserConfigs: Options[] = [ + { + ...browserOptions, + minify: false, + name: 'browser esm', + dts: { entry: { browser: 'builds/browser.ts' } }, + entry: ['builds/browser.ts', 'src/*.ts'], + }, + { + ...browserOptions, + dts: false, + minify: true, + name: 'browser min esm', + entry: { 'builds/browser.min': 'builds/browser.ts' }, + external: [], + noExternal: getDependencies(pkg, 'browser'), + }, +]; + +export default defineConfig([...nodeConfigs, ...browserConfigs]); diff --git a/clients/algoliasearch-client-javascript/packages/client-usage/index.d.ts b/clients/algoliasearch-client-javascript/packages/client-usage/index.d.ts index 8b0a7c887a..23eac31bdc 100644 --- a/clients/algoliasearch-client-javascript/packages/client-usage/index.d.ts +++ b/clients/algoliasearch-client-javascript/packages/client-usage/index.d.ts @@ -1,2 +1,2 @@ // eslint-disable-next-line import/no-unresolved -export * from './dist/builds/node'; +export * from './dist/node'; diff --git a/clients/algoliasearch-client-javascript/packages/client-usage/index.js b/clients/algoliasearch-client-javascript/packages/client-usage/index.js index d2beb3cb43..5ae95ae019 100644 --- a/clients/algoliasearch-client-javascript/packages/client-usage/index.js +++ b/clients/algoliasearch-client-javascript/packages/client-usage/index.js @@ -1,2 +1,2 @@ // eslint-disable-next-line import/no-commonjs,import/extensions -module.exports = require('./dist/client-usage.cjs'); \ No newline at end of file +module.exports = require('./dist/builds/node.cjs'); \ No newline at end of file diff --git a/clients/algoliasearch-client-javascript/packages/client-usage/package.json b/clients/algoliasearch-client-javascript/packages/client-usage/package.json index 3bf8046184..c4d5655d38 100644 --- a/clients/algoliasearch-client-javascript/packages/client-usage/package.json +++ b/clients/algoliasearch-client-javascript/packages/client-usage/package.json @@ -7,50 +7,53 @@ "type": "module", "license": "MIT", "author": "Algolia", - "types": "./index.d.ts", + "scripts": { + "build": "yarn clean && yarn tsup && yarn rollup -c rollup.config.js", + "clean": "rm -rf ./dist || true", + "test:bundle": "publint . && attw --pack ." + }, "name": "@algolia/client-usage", "description": "JavaScript client for client-usage", - "jsdelivr": "./dist/client-usage.umd.js", - "unpkg": "./dist/client-usage.umd.js", - "browser": "./dist/client-usage.umd.js", "exports": { ".": { "node": { - "import": "./dist/client-usage.esm.node.js", - "module": "./dist/client-usage.esm.node.js", - "require": "./dist/client-usage.cjs", - "default": "./dist/client-usage.cjs", - "types": "./dist/builds/node.d.ts" + "types": { + "import": "./dist/node.d.ts", + "module": "./dist/node.d.ts", + "require": "./dist/node.d.cts" + }, + "import": "./dist/builds/node.js", + "module": "./dist/builds/node.js", + "require": "./dist/builds/node.cjs" }, - "browser": { - "umd": "./dist/client-usage.umd.js", - "module": "./dist/client-usage.esm.browser.js", - "import": "./dist/client-usage.esm.browser.js", - "default": "./dist/client-usage.umd.js", - "types": "./dist/builds/browser.d.ts" + "default": { + "types": "./dist/browser.d.ts", + "module": "./dist/builds/browser.js", + "import": "./dist/builds/browser.js", + "default": "./dist/builds/browser.umd.js" } }, - "./src/*": "./src/*.ts", - "./model": "./model/index.ts" + "./src/*": "./src/*.ts" }, + "jsdelivr": "./dist/builds/browser.umd.js", + "unpkg": "./dist/builds/browser.umd.js", "files": [ "dist", "model", "index.js", "index.d.ts" ], - "scripts": { - "build": "yarn clean && rollup --config", - "clean": "rm -rf ./dist || true" - }, "dependencies": { "@algolia/client-common": "5.2.4", "@algolia/requester-browser-xhr": "5.2.4", "@algolia/requester-node-http": "5.2.4" }, "devDependencies": { + "@arethetypeswrong/cli": "0.15.4", "@types/node": "22.5.1", + "publint": "0.2.10", "rollup": "4.21.2", + "tsup": "8.2.4", "typescript": "5.5.4" }, "engines": { diff --git a/clients/algoliasearch-client-javascript/packages/client-usage/rollup.config.js b/clients/algoliasearch-client-javascript/packages/client-usage/rollup.config.js index 0f45d3972b..5d6d945baa 100644 --- a/clients/algoliasearch-client-javascript/packages/client-usage/rollup.config.js +++ b/clients/algoliasearch-client-javascript/packages/client-usage/rollup.config.js @@ -1,5 +1,16 @@ -import { buildConfigs } from '../../base.rollup.config.js'; - -import pkg from './package.json' with { type: 'json' }; - -export default buildConfigs(pkg); \ No newline at end of file +export default [ + { + input: 'dist/builds/browser.min.js', + external: ['dom'], + output: { + esModule: false, + file: 'dist/builds/browser.umd.js', + name: 'usageClient', + format: 'umd', + sourcemap: false, + globals: { + ['usageClient']: 'usageClient', + }, + }, + }, +] \ No newline at end of file diff --git a/clients/algoliasearch-client-javascript/packages/client-usage/tsup.config.ts b/clients/algoliasearch-client-javascript/packages/client-usage/tsup.config.ts new file mode 100644 index 0000000000..e95fa78454 --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/client-usage/tsup.config.ts @@ -0,0 +1,51 @@ +import type { Options } from 'tsup'; +import { defineConfig } from 'tsup'; + +import { getBaseNodeOptions, getBaseBrowserOptions, getDependencies } from '../../base.tsup.config'; + +import pkg from './package.json' with { type: 'json' }; + +const nodeOptions: Options = { + ...getBaseNodeOptions(pkg, __dirname), + dts: { entry: { node: 'builds/node.ts' } }, + entry: ['builds/node.ts', 'src/*.ts'], +}; + +const nodeConfigs: Options[] = [ + { + ...nodeOptions, + format: 'cjs', + name: 'node cjs', + }, + { + ...nodeOptions, + format: 'esm', + name: 'node esm', + }, +]; + +const browserOptions: Options = { + ...getBaseBrowserOptions(pkg, __dirname), + globalName: 'usageClient', +}; + +const browserConfigs: Options[] = [ + { + ...browserOptions, + minify: false, + name: 'browser esm', + dts: { entry: { browser: 'builds/browser.ts' } }, + entry: ['builds/browser.ts', 'src/*.ts'], + }, + { + ...browserOptions, + dts: false, + minify: true, + name: 'browser min esm', + entry: { 'builds/browser.min': 'builds/browser.ts' }, + external: [], + noExternal: getDependencies(pkg, 'browser'), + }, +]; + +export default defineConfig([...nodeConfigs, ...browserConfigs]); diff --git a/clients/algoliasearch-client-javascript/packages/ingestion/index.d.ts b/clients/algoliasearch-client-javascript/packages/ingestion/index.d.ts index 8b0a7c887a..23eac31bdc 100644 --- a/clients/algoliasearch-client-javascript/packages/ingestion/index.d.ts +++ b/clients/algoliasearch-client-javascript/packages/ingestion/index.d.ts @@ -1,2 +1,2 @@ // eslint-disable-next-line import/no-unresolved -export * from './dist/builds/node'; +export * from './dist/node'; diff --git a/clients/algoliasearch-client-javascript/packages/ingestion/index.js b/clients/algoliasearch-client-javascript/packages/ingestion/index.js index 5ca14e2ae1..5ae95ae019 100644 --- a/clients/algoliasearch-client-javascript/packages/ingestion/index.js +++ b/clients/algoliasearch-client-javascript/packages/ingestion/index.js @@ -1,2 +1,2 @@ // eslint-disable-next-line import/no-commonjs,import/extensions -module.exports = require('./dist/ingestion.cjs'); \ No newline at end of file +module.exports = require('./dist/builds/node.cjs'); \ No newline at end of file diff --git a/clients/algoliasearch-client-javascript/packages/ingestion/package.json b/clients/algoliasearch-client-javascript/packages/ingestion/package.json index 359ff13db6..101baaa831 100644 --- a/clients/algoliasearch-client-javascript/packages/ingestion/package.json +++ b/clients/algoliasearch-client-javascript/packages/ingestion/package.json @@ -7,50 +7,53 @@ "type": "module", "license": "MIT", "author": "Algolia", - "types": "./index.d.ts", + "scripts": { + "build": "yarn clean && yarn tsup && yarn rollup -c rollup.config.js", + "clean": "rm -rf ./dist || true", + "test:bundle": "publint . && attw --pack ." + }, "name": "@algolia/ingestion", "description": "JavaScript client for ingestion", - "jsdelivr": "./dist/ingestion.umd.js", - "unpkg": "./dist/ingestion.umd.js", - "browser": "./dist/ingestion.umd.js", "exports": { ".": { "node": { - "import": "./dist/ingestion.esm.node.js", - "module": "./dist/ingestion.esm.node.js", - "require": "./dist/ingestion.cjs", - "default": "./dist/ingestion.cjs", - "types": "./dist/builds/node.d.ts" + "types": { + "import": "./dist/node.d.ts", + "module": "./dist/node.d.ts", + "require": "./dist/node.d.cts" + }, + "import": "./dist/builds/node.js", + "module": "./dist/builds/node.js", + "require": "./dist/builds/node.cjs" }, - "browser": { - "umd": "./dist/ingestion.umd.js", - "module": "./dist/ingestion.esm.browser.js", - "import": "./dist/ingestion.esm.browser.js", - "default": "./dist/ingestion.umd.js", - "types": "./dist/builds/browser.d.ts" + "default": { + "types": "./dist/browser.d.ts", + "module": "./dist/builds/browser.js", + "import": "./dist/builds/browser.js", + "default": "./dist/builds/browser.umd.js" } }, - "./src/*": "./src/*.ts", - "./model": "./model/index.ts" + "./src/*": "./src/*.ts" }, + "jsdelivr": "./dist/builds/browser.umd.js", + "unpkg": "./dist/builds/browser.umd.js", "files": [ "dist", "model", "index.js", "index.d.ts" ], - "scripts": { - "build": "yarn clean && rollup --config", - "clean": "rm -rf ./dist || true" - }, "dependencies": { "@algolia/client-common": "5.2.4", "@algolia/requester-browser-xhr": "5.2.4", "@algolia/requester-node-http": "5.2.4" }, "devDependencies": { + "@arethetypeswrong/cli": "0.15.4", "@types/node": "22.5.1", + "publint": "0.2.10", "rollup": "4.21.2", + "tsup": "8.2.4", "typescript": "5.5.4" }, "engines": { diff --git a/clients/algoliasearch-client-javascript/packages/ingestion/rollup.config.js b/clients/algoliasearch-client-javascript/packages/ingestion/rollup.config.js index 0f45d3972b..d935732e0b 100644 --- a/clients/algoliasearch-client-javascript/packages/ingestion/rollup.config.js +++ b/clients/algoliasearch-client-javascript/packages/ingestion/rollup.config.js @@ -1,5 +1,16 @@ -import { buildConfigs } from '../../base.rollup.config.js'; - -import pkg from './package.json' with { type: 'json' }; - -export default buildConfigs(pkg); \ No newline at end of file +export default [ + { + input: 'dist/builds/browser.min.js', + external: ['dom'], + output: { + esModule: false, + file: 'dist/builds/browser.umd.js', + name: 'ingestionClient', + format: 'umd', + sourcemap: false, + globals: { + ['ingestionClient']: 'ingestionClient', + }, + }, + }, +] \ No newline at end of file diff --git a/clients/algoliasearch-client-javascript/packages/ingestion/tsup.config.ts b/clients/algoliasearch-client-javascript/packages/ingestion/tsup.config.ts new file mode 100644 index 0000000000..5fb3b5dee7 --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/ingestion/tsup.config.ts @@ -0,0 +1,51 @@ +import type { Options } from 'tsup'; +import { defineConfig } from 'tsup'; + +import { getBaseNodeOptions, getBaseBrowserOptions, getDependencies } from '../../base.tsup.config'; + +import pkg from './package.json' with { type: 'json' }; + +const nodeOptions: Options = { + ...getBaseNodeOptions(pkg, __dirname), + dts: { entry: { node: 'builds/node.ts' } }, + entry: ['builds/node.ts', 'src/*.ts'], +}; + +const nodeConfigs: Options[] = [ + { + ...nodeOptions, + format: 'cjs', + name: 'node cjs', + }, + { + ...nodeOptions, + format: 'esm', + name: 'node esm', + }, +]; + +const browserOptions: Options = { + ...getBaseBrowserOptions(pkg, __dirname), + globalName: 'ingestionClient', +}; + +const browserConfigs: Options[] = [ + { + ...browserOptions, + minify: false, + name: 'browser esm', + dts: { entry: { browser: 'builds/browser.ts' } }, + entry: ['builds/browser.ts', 'src/*.ts'], + }, + { + ...browserOptions, + dts: false, + minify: true, + name: 'browser min esm', + entry: { 'builds/browser.min': 'builds/browser.ts' }, + external: [], + noExternal: getDependencies(pkg, 'browser'), + }, +]; + +export default defineConfig([...nodeConfigs, ...browserConfigs]); diff --git a/clients/algoliasearch-client-javascript/packages/monitoring/index.d.ts b/clients/algoliasearch-client-javascript/packages/monitoring/index.d.ts index 8b0a7c887a..23eac31bdc 100644 --- a/clients/algoliasearch-client-javascript/packages/monitoring/index.d.ts +++ b/clients/algoliasearch-client-javascript/packages/monitoring/index.d.ts @@ -1,2 +1,2 @@ // eslint-disable-next-line import/no-unresolved -export * from './dist/builds/node'; +export * from './dist/node'; diff --git a/clients/algoliasearch-client-javascript/packages/monitoring/index.js b/clients/algoliasearch-client-javascript/packages/monitoring/index.js index 10ff3c9a2a..5ae95ae019 100644 --- a/clients/algoliasearch-client-javascript/packages/monitoring/index.js +++ b/clients/algoliasearch-client-javascript/packages/monitoring/index.js @@ -1,2 +1,2 @@ // eslint-disable-next-line import/no-commonjs,import/extensions -module.exports = require('./dist/monitoring.cjs'); \ No newline at end of file +module.exports = require('./dist/builds/node.cjs'); \ No newline at end of file diff --git a/clients/algoliasearch-client-javascript/packages/monitoring/package.json b/clients/algoliasearch-client-javascript/packages/monitoring/package.json index 4ce67b1d58..72c28dc724 100644 --- a/clients/algoliasearch-client-javascript/packages/monitoring/package.json +++ b/clients/algoliasearch-client-javascript/packages/monitoring/package.json @@ -7,50 +7,53 @@ "type": "module", "license": "MIT", "author": "Algolia", - "types": "./index.d.ts", + "scripts": { + "build": "yarn clean && yarn tsup && yarn rollup -c rollup.config.js", + "clean": "rm -rf ./dist || true", + "test:bundle": "publint . && attw --pack ." + }, "name": "@algolia/monitoring", "description": "JavaScript client for monitoring", - "jsdelivr": "./dist/monitoring.umd.js", - "unpkg": "./dist/monitoring.umd.js", - "browser": "./dist/monitoring.umd.js", "exports": { ".": { "node": { - "import": "./dist/monitoring.esm.node.js", - "module": "./dist/monitoring.esm.node.js", - "require": "./dist/monitoring.cjs", - "default": "./dist/monitoring.cjs", - "types": "./dist/builds/node.d.ts" + "types": { + "import": "./dist/node.d.ts", + "module": "./dist/node.d.ts", + "require": "./dist/node.d.cts" + }, + "import": "./dist/builds/node.js", + "module": "./dist/builds/node.js", + "require": "./dist/builds/node.cjs" }, - "browser": { - "umd": "./dist/monitoring.umd.js", - "module": "./dist/monitoring.esm.browser.js", - "import": "./dist/monitoring.esm.browser.js", - "default": "./dist/monitoring.umd.js", - "types": "./dist/builds/browser.d.ts" + "default": { + "types": "./dist/browser.d.ts", + "module": "./dist/builds/browser.js", + "import": "./dist/builds/browser.js", + "default": "./dist/builds/browser.umd.js" } }, - "./src/*": "./src/*.ts", - "./model": "./model/index.ts" + "./src/*": "./src/*.ts" }, + "jsdelivr": "./dist/builds/browser.umd.js", + "unpkg": "./dist/builds/browser.umd.js", "files": [ "dist", "model", "index.js", "index.d.ts" ], - "scripts": { - "build": "yarn clean && rollup --config", - "clean": "rm -rf ./dist || true" - }, "dependencies": { "@algolia/client-common": "5.2.4", "@algolia/requester-browser-xhr": "5.2.4", "@algolia/requester-node-http": "5.2.4" }, "devDependencies": { + "@arethetypeswrong/cli": "0.15.4", "@types/node": "22.5.1", + "publint": "0.2.10", "rollup": "4.21.2", + "tsup": "8.2.4", "typescript": "5.5.4" }, "engines": { diff --git a/clients/algoliasearch-client-javascript/packages/monitoring/rollup.config.js b/clients/algoliasearch-client-javascript/packages/monitoring/rollup.config.js index 0f45d3972b..857523af0f 100644 --- a/clients/algoliasearch-client-javascript/packages/monitoring/rollup.config.js +++ b/clients/algoliasearch-client-javascript/packages/monitoring/rollup.config.js @@ -1,5 +1,16 @@ -import { buildConfigs } from '../../base.rollup.config.js'; - -import pkg from './package.json' with { type: 'json' }; - -export default buildConfigs(pkg); \ No newline at end of file +export default [ + { + input: 'dist/builds/browser.min.js', + external: ['dom'], + output: { + esModule: false, + file: 'dist/builds/browser.umd.js', + name: 'monitoringClient', + format: 'umd', + sourcemap: false, + globals: { + ['monitoringClient']: 'monitoringClient', + }, + }, + }, +] \ No newline at end of file diff --git a/clients/algoliasearch-client-javascript/packages/monitoring/tsup.config.ts b/clients/algoliasearch-client-javascript/packages/monitoring/tsup.config.ts new file mode 100644 index 0000000000..d603b5acd5 --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/monitoring/tsup.config.ts @@ -0,0 +1,51 @@ +import type { Options } from 'tsup'; +import { defineConfig } from 'tsup'; + +import { getBaseNodeOptions, getBaseBrowserOptions, getDependencies } from '../../base.tsup.config'; + +import pkg from './package.json' with { type: 'json' }; + +const nodeOptions: Options = { + ...getBaseNodeOptions(pkg, __dirname), + dts: { entry: { node: 'builds/node.ts' } }, + entry: ['builds/node.ts', 'src/*.ts'], +}; + +const nodeConfigs: Options[] = [ + { + ...nodeOptions, + format: 'cjs', + name: 'node cjs', + }, + { + ...nodeOptions, + format: 'esm', + name: 'node esm', + }, +]; + +const browserOptions: Options = { + ...getBaseBrowserOptions(pkg, __dirname), + globalName: 'monitoringClient', +}; + +const browserConfigs: Options[] = [ + { + ...browserOptions, + minify: false, + name: 'browser esm', + dts: { entry: { browser: 'builds/browser.ts' } }, + entry: ['builds/browser.ts', 'src/*.ts'], + }, + { + ...browserOptions, + dts: false, + minify: true, + name: 'browser min esm', + entry: { 'builds/browser.min': 'builds/browser.ts' }, + external: [], + noExternal: getDependencies(pkg, 'browser'), + }, +]; + +export default defineConfig([...nodeConfigs, ...browserConfigs]); diff --git a/clients/algoliasearch-client-javascript/packages/recommend/index.d.ts b/clients/algoliasearch-client-javascript/packages/recommend/index.d.ts index 8b0a7c887a..23eac31bdc 100644 --- a/clients/algoliasearch-client-javascript/packages/recommend/index.d.ts +++ b/clients/algoliasearch-client-javascript/packages/recommend/index.d.ts @@ -1,2 +1,2 @@ // eslint-disable-next-line import/no-unresolved -export * from './dist/builds/node'; +export * from './dist/node'; diff --git a/clients/algoliasearch-client-javascript/packages/recommend/index.js b/clients/algoliasearch-client-javascript/packages/recommend/index.js index 76b82deb4a..5ae95ae019 100644 --- a/clients/algoliasearch-client-javascript/packages/recommend/index.js +++ b/clients/algoliasearch-client-javascript/packages/recommend/index.js @@ -1,2 +1,2 @@ // eslint-disable-next-line import/no-commonjs,import/extensions -module.exports = require('./dist/recommend.cjs'); \ No newline at end of file +module.exports = require('./dist/builds/node.cjs'); \ No newline at end of file diff --git a/clients/algoliasearch-client-javascript/packages/recommend/package.json b/clients/algoliasearch-client-javascript/packages/recommend/package.json index 537b2465ea..97b6f23477 100644 --- a/clients/algoliasearch-client-javascript/packages/recommend/package.json +++ b/clients/algoliasearch-client-javascript/packages/recommend/package.json @@ -7,50 +7,53 @@ "type": "module", "license": "MIT", "author": "Algolia", - "types": "./index.d.ts", + "scripts": { + "build": "yarn clean && yarn tsup && yarn rollup -c rollup.config.js", + "clean": "rm -rf ./dist || true", + "test:bundle": "publint . && attw --pack ." + }, "name": "@algolia/recommend", "description": "JavaScript client for recommend", - "jsdelivr": "./dist/recommend.umd.js", - "unpkg": "./dist/recommend.umd.js", - "browser": "./dist/recommend.umd.js", "exports": { ".": { "node": { - "import": "./dist/recommend.esm.node.js", - "module": "./dist/recommend.esm.node.js", - "require": "./dist/recommend.cjs", - "default": "./dist/recommend.cjs", - "types": "./dist/builds/node.d.ts" + "types": { + "import": "./dist/node.d.ts", + "module": "./dist/node.d.ts", + "require": "./dist/node.d.cts" + }, + "import": "./dist/builds/node.js", + "module": "./dist/builds/node.js", + "require": "./dist/builds/node.cjs" }, - "browser": { - "umd": "./dist/recommend.umd.js", - "module": "./dist/recommend.esm.browser.js", - "import": "./dist/recommend.esm.browser.js", - "default": "./dist/recommend.umd.js", - "types": "./dist/builds/browser.d.ts" + "default": { + "types": "./dist/browser.d.ts", + "module": "./dist/builds/browser.js", + "import": "./dist/builds/browser.js", + "default": "./dist/builds/browser.umd.js" } }, - "./src/*": "./src/*.ts", - "./model": "./model/index.ts" + "./src/*": "./src/*.ts" }, + "jsdelivr": "./dist/builds/browser.umd.js", + "unpkg": "./dist/builds/browser.umd.js", "files": [ "dist", "model", "index.js", "index.d.ts" ], - "scripts": { - "build": "yarn clean && rollup --config", - "clean": "rm -rf ./dist || true" - }, "dependencies": { "@algolia/client-common": "5.2.4", "@algolia/requester-browser-xhr": "5.2.4", "@algolia/requester-node-http": "5.2.4" }, "devDependencies": { + "@arethetypeswrong/cli": "0.15.4", "@types/node": "22.5.1", + "publint": "0.2.10", "rollup": "4.21.2", + "tsup": "8.2.4", "typescript": "5.5.4" }, "engines": { diff --git a/clients/algoliasearch-client-javascript/packages/recommend/rollup.config.js b/clients/algoliasearch-client-javascript/packages/recommend/rollup.config.js index 0f45d3972b..ea38581528 100644 --- a/clients/algoliasearch-client-javascript/packages/recommend/rollup.config.js +++ b/clients/algoliasearch-client-javascript/packages/recommend/rollup.config.js @@ -1,5 +1,16 @@ -import { buildConfigs } from '../../base.rollup.config.js'; - -import pkg from './package.json' with { type: 'json' }; - -export default buildConfigs(pkg); \ No newline at end of file +export default [ + { + input: 'dist/builds/browser.min.js', + external: ['dom'], + output: { + esModule: false, + file: 'dist/builds/browser.umd.js', + name: 'recommendClient', + format: 'umd', + sourcemap: false, + globals: { + ['recommendClient']: 'recommendClient', + }, + }, + }, +] \ No newline at end of file diff --git a/clients/algoliasearch-client-javascript/packages/recommend/tsup.config.ts b/clients/algoliasearch-client-javascript/packages/recommend/tsup.config.ts new file mode 100644 index 0000000000..bc77df4e9f --- /dev/null +++ b/clients/algoliasearch-client-javascript/packages/recommend/tsup.config.ts @@ -0,0 +1,51 @@ +import type { Options } from 'tsup'; +import { defineConfig } from 'tsup'; + +import { getBaseNodeOptions, getBaseBrowserOptions, getDependencies } from '../../base.tsup.config'; + +import pkg from './package.json' with { type: 'json' }; + +const nodeOptions: Options = { + ...getBaseNodeOptions(pkg, __dirname), + dts: { entry: { node: 'builds/node.ts' } }, + entry: ['builds/node.ts', 'src/*.ts'], +}; + +const nodeConfigs: Options[] = [ + { + ...nodeOptions, + format: 'cjs', + name: 'node cjs', + }, + { + ...nodeOptions, + format: 'esm', + name: 'node esm', + }, +]; + +const browserOptions: Options = { + ...getBaseBrowserOptions(pkg, __dirname), + globalName: 'recommendClient', +}; + +const browserConfigs: Options[] = [ + { + ...browserOptions, + minify: false, + name: 'browser esm', + dts: { entry: { browser: 'builds/browser.ts' } }, + entry: ['builds/browser.ts', 'src/*.ts'], + }, + { + ...browserOptions, + dts: false, + minify: true, + name: 'browser min esm', + entry: { 'builds/browser.min': 'builds/browser.ts' }, + external: [], + noExternal: getDependencies(pkg, 'browser'), + }, +]; + +export default defineConfig([...nodeConfigs, ...browserConfigs]);