Skip to content

Commit

Permalink
chore(javascript): use tsup bundler (#3640) (generated) [skip ci]
Browse files Browse the repository at this point in the history
Co-authored-by: Clément Vannicatte <[email protected]>
  • Loading branch information
algolia-bot and shortcuts committed Sep 3, 2024
1 parent ff0c996 commit 4a39f64
Show file tree
Hide file tree
Showing 61 changed files with 1,118 additions and 350 deletions.
10 changes: 5 additions & 5 deletions clients/algoliasearch-client-javascript/base.tsup.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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.
*/
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -161,6 +160,10 @@ export {
TypoTolerance,
TypoToleranceEnum,
Value,
AnalyticsRegion,
ABTestingRegion,
Region,
apiClientVersion,
};

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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';
Expand All @@ -31,8 +31,6 @@ import type {

export * from './models';

export const apiClientVersion = searchClientVersion;

/**
* The client type.
*/
Expand All @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// eslint-disable-next-line import/no-unresolved
export * from './dist/algoliasearch/builds/node';
export * from './dist/node';
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// eslint-disable-next-line import/no-commonjs,import/extensions
module.exports = require('./dist/algoliasearch.cjs');
module.exports = require('./dist/node.cjs');
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// eslint-disable-next-line import/no-unresolved
export * from './dist/lite/builds/node';
export * from './dist/lite/node';
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
// eslint-disable-next-line import/no-commonjs,import/extensions
module.exports = require('./dist/lite/lite.cjs');
module.exports = require('./dist/lite/builds/node.cjs');
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand All @@ -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",
Expand All @@ -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": {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,30 @@
import { buildConfigs } from '../../base.rollup.config.js';

import pkg from './package.json' with { type: 'json' };

export default buildConfigs(pkg);
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',
},
},
}
]
Loading

0 comments on commit 4a39f64

Please sign in to comment.