Skip to content

Commit b4ffe1e

Browse files
chore(javascript): use tsup bundler (generated)
algolia/api-clients-automation#3640 Co-authored-by: algolia-bot <[email protected]> Co-authored-by: Clément Vannicatte <[email protected]>
1 parent 6c62647 commit b4ffe1e

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

78 files changed

+2252
-720
lines changed

base.rollup.config.js

Lines changed: 0 additions & 303 deletions
This file was deleted.

base.tsup.config.ts

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import path from 'path';
2+
3+
import type { Options } from 'tsup';
4+
5+
type PKG = {
6+
dependencies?: Record<string, string>;
7+
name: string;
8+
};
9+
10+
export function getBaseConfig(cwd: string): Options {
11+
return {
12+
clean: true,
13+
sourcemap: true,
14+
splitting: false,
15+
tsconfig: path.resolve(cwd, 'tsconfig.json'),
16+
};
17+
}
18+
19+
export function getDependencies(pkg: PKG, env: 'browser' | 'node'): string[] {
20+
const deps = Object.keys(pkg.dependencies || {}) || [];
21+
22+
if (pkg.name !== 'algoliasearch') {
23+
return deps;
24+
}
25+
26+
if (env === 'node') {
27+
return deps.filter((dep) => dep !== '@algolia/requester-browser-xhr');
28+
}
29+
30+
return deps.filter((dep) => dep !== '@algolia/requester-node-http');
31+
}
32+
33+
export function getBaseNodeOptions(pkg: PKG, cwd: string): Options {
34+
return {
35+
...getBaseConfig(cwd),
36+
platform: 'node',
37+
target: 'node14',
38+
external: [...getDependencies(pkg, 'node'), 'node:crypto'],
39+
};
40+
}
41+
42+
export function getBaseBrowserOptions(pkg: PKG, cwd: string): Options {
43+
return {
44+
...getBaseConfig(cwd),
45+
platform: 'browser',
46+
format: ['esm'],
47+
target: ['chrome109', 'safari15.6', 'firefox115', 'edge126'],
48+
external: [...getDependencies(pkg, 'browser'), 'dom'],
49+
};
50+
}

0 commit comments

Comments
 (0)