Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(javascript): use tsup bundler #3640

Merged
merged 36 commits into from
Sep 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
445289b
chore(javascript): assert against bundled package
shortcuts Aug 31, 2024
0571a41
feat: tsup
shortcuts Aug 31, 2024
610bca3
chore: gen failures
shortcuts Aug 31, 2024
a9b0ae2
feat: tsup but that works except algoliasearch
shortcuts Sep 1, 2024
1c7c9b8
feat: tsup but now algoliasearch works
shortcuts Sep 1, 2024
c24242b
fix: algoliasearch imports and tests
shortcuts Sep 1, 2024
8f81c94
feat: node and browser for fetch requester
shortcuts Sep 1, 2024
98ef2ce
chore: test
shortcuts Sep 1, 2024
8de72b7
chore: can't reproduce?
shortcuts Sep 1, 2024
b9ba52a
feat: umd
shortcuts Sep 2, 2024
b30393d
Merge branch 'main' into chore/javascript-bundle-assertions
shortcuts Sep 2, 2024
a551920
chore: deps
shortcuts Sep 2, 2024
ec87f65
Merge branch 'main' into chore/javascript-bundle-assertions
shortcuts Sep 2, 2024
2a7122a
fix: path to algoliasearch
shortcuts Sep 2, 2024
ed1edc3
fix: minify esm
shortcuts Sep 2, 2024
750deb1
fix: algoliasearch deps and lite imports
shortcuts Sep 2, 2024
ff711aa
fix: algoliasearch deps and lite imports
shortcuts Sep 2, 2024
1ea8cd8
Merge branch 'main' into chore/javascript-bundle-assertions
shortcuts Sep 2, 2024
4a320a9
chore: reuse some config
shortcuts Sep 2, 2024
7614289
chore: generation file
shortcuts Sep 2, 2024
19a9a4d
Merge branch 'main' into chore/javascript-bundle-assertions
shortcuts Sep 2, 2024
44605ac
chore: lite root files
shortcuts Sep 2, 2024
8c6ca79
chore: template files
shortcuts Sep 2, 2024
33b0d9d
chore: legacy algoliasearch umd file name
shortcuts Sep 2, 2024
5e89f1d
Merge branch 'main' into chore/javascript-bundle-assertions
shortcuts Sep 2, 2024
9323543
chore: prevent flaky builds
shortcuts Sep 2, 2024
1778083
Merge branch 'main' into chore/javascript-bundle-assertions
shortcuts Sep 2, 2024
3e9cbcb
chore: publint and attw on the ci
shortcuts Sep 2, 2024
d79ed18
chore: also on commons
shortcuts Sep 2, 2024
177c6f0
chore: template
shortcuts Sep 2, 2024
96e338a
chore: model not models
shortcuts Sep 3, 2024
f1e404c
chore: package and tsup fixes
shortcuts Sep 3, 2024
214ad33
chore: do not mix types and imports
shortcuts Sep 3, 2024
42f5382
fix: esm with ts refs
shortcuts Sep 3, 2024
1140310
chore: filter requester not matching env
shortcuts Sep 3, 2024
9534650
fix: filter on external deps
shortcuts Sep 3, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,10 @@ jobs:
if: ${{ startsWith(env.head_ref, 'chore/prepare-release-') }}
run: cd clients/algoliasearch-client-javascript && yarn test:size

- name: Test JavaScript bundle and types
if: ${{ startsWith(env.head_ref, 'chore/prepare-release-') }}
run: cd clients/algoliasearch-client-javascript && yarn test:bundle
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lovely


- name: Remove previous CTS output
run: rm -rf ${{ fromJSON(needs.setup.outputs.JAVASCRIPT_DATA).testsToDelete }}

Expand Down
303 changes: 0 additions & 303 deletions clients/algoliasearch-client-javascript/base.rollup.config.js

This file was deleted.

50 changes: 50 additions & 0 deletions clients/algoliasearch-client-javascript/base.tsup.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
import path from 'path';

import type { Options } from 'tsup';

type PKG = {
dependencies?: Record<string, string>;
name: string;
};

export function getBaseConfig(cwd: string): Options {
return {
clean: true,
sourcemap: true,
splitting: false,
tsconfig: path.resolve(cwd, 'tsconfig.json'),
};
}

export function getDependencies(pkg: PKG, env: 'node' | 'browser'): string[] {
const deps = Object.keys(pkg.dependencies || {}) || [];

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-node-http')
}

export function getBaseNodeOptions(pkg: PKG, cwd: string): Options {
return {
...getBaseConfig(cwd),
platform: 'node',
target: 'node14',
external: [...getDependencies(pkg, 'node'), 'node:crypto'],
};
}

export function getBaseBrowserOptions(pkg: PKG, cwd: string): Options {
return {
...getBaseConfig(cwd),
platform: 'browser',
format: ['esm'],
target: ['chrome109', 'safari15.6', 'firefox115', 'edge126'],
Copy link
Collaborator

@millotp millotp Sep 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ie is also a valid target, don't you want to include it ?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The enum for target are prefixes actually, if you don't give a precise version for browsers it asks for it at runtime

external: [...getDependencies(pkg, 'browser'), 'dom'],
};
}
Loading
Loading