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

Conversation

shortcuts
Copy link
Member

@shortcuts shortcuts commented Aug 31, 2024

🧭 What and Why

🎟 JIRA Ticket:

Changes included:

closes algolia/algoliasearch-client-javascript#1544

use tsup instead of rollup, just because I wanted to try it out and it seems to exactly do what we need, a bit faster and easier to configure.

also add attw and publint, in order to debug the exported types, package.json#export field, and the resolved imports.

how to verify it works?

  • generate and builds the js clients
  • go to clients/algoliasearch-client-javascript
  • run test:size, should be all green without being too far from the threshold
  • run test:bundle on many clients, they are all green
  • try the 5.2.4-beta.2 directly

@shortcuts shortcuts self-assigned this Aug 31, 2024
@algolia-bot
Copy link
Collaborator

algolia-bot commented Aug 31, 2024

✔️ Code generated!

Name Link
🪓 Triggered by 801b4ae0e1fef99c2f3f30ff320fef154a659f02
🍃 Generated commit 4844297e352b8aa77d6e1c26aef483b32105ac5f
🌲 Generated branch generated/chore/javascript-bundle-assertions
📊 Benchmark results

Benchmarks performed on the method using a mock server, the results might not reflect the real-world performance.

Language Req/s
javascript 1694
php 1512
python 1020
csharp 1013
ruby 967
java 962
swift 778
go 566
kotlin 501

@shortcuts shortcuts changed the title chore(javascript): assert against bundled package chore(javascript): use tsup bundler Sep 1, 2024
@shortcuts shortcuts changed the title chore(javascript): use tsup bundler chore(javascript): use tsup bundler [skip-bc] Sep 2, 2024
@shortcuts shortcuts marked this pull request as ready for review September 2, 2024 14:03
@shortcuts shortcuts requested a review from a team as a code owner September 2, 2024 14:03
@shortcuts shortcuts changed the title chore(javascript): use tsup bundler [skip-bc] chore(javascript): use tsup bundler Sep 2, 2024
Copy link

github-actions bot commented Sep 2, 2024

Copy link
Collaborator

@millotp millotp left a comment

Choose a reason for hiding this comment

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

this is huuuge, congrats !

@@ -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

...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

@@ -12,7 +12,8 @@
"release:bump": "lerna version ${0:-patch} --no-changelog --no-git-tag-version --no-push --exact --force-publish --yes",
"release:publish": "tsc --project scripts/tsconfig.json && node scripts/dist/scripts/publish.js",
"test": "lerna run test $*",
"test:size": "bundlesize"
"test:size": "bundlesize",
"test:bundle": "lerna run test:bundle --verbose --skip-nx-cache --include-dependencies"
Copy link
Collaborator

Choose a reason for hiding this comment

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

why the skip cache everywhere ? on the build step too ?

Copy link
Member Author

Choose a reason for hiding this comment

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

nx and lerna was still in an early phase when I set it up and there wad cache issues, I guess it's legacy but we should be able to remove it as on the ci there's always no cache

Copy link
Collaborator

Choose a reason for hiding this comment

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

we could cache the .nx folder on the CI

Copy link
Member Author

Choose a reason for hiding this comment

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

idk how flaky it is but yup maybe

@@ -1,2 +1,2 @@
// eslint-disable-next-line import/no-unresolved
export * from './dist/lite/builds/node';
export * from './dist/lite/node';
Copy link
Collaborator

Choose a reason for hiding this comment

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

can you delete this template and just create the d.ts file directly pls ?

Copy link
Member Author

Choose a reason for hiding this comment

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

This allows adding a new client without touching the js repo normally, if we remove those it means documenting to add them etc... it's easier that way

Copy link
Collaborator

Choose a reason for hiding this comment

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

some files already need to be copied manually, I think we will just copy the package if we add a new spec

Copy link
Member Author

Choose a reason for hiding this comment

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

some files already need to be copied manually

true but ideally you'd just add your spec and that's it

module.exports = require('./dist/lite/builds/node.cjs');
Copy link
Collaborator

Choose a reason for hiding this comment

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

same

@@ -1,2 +1,2 @@
// eslint-disable-next-line import/no-unresolved
export * from './dist/{{#isAlgoliasearchClient}}algoliasearch/{{/isAlgoliasearchClient}}builds/node';
export * from './dist/node';
Copy link
Collaborator

Choose a reason for hiding this comment

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

same

Copy link
Collaborator

@millotp millotp left a comment

Choose a reason for hiding this comment

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

nothing to add, gg !

@shortcuts shortcuts merged commit ff0c996 into main Sep 3, 2024
25 checks passed
@shortcuts shortcuts deleted the chore/javascript-bundle-assertions branch September 3, 2024 11:52
algolia-bot added a commit that referenced this pull request Sep 3, 2024
Co-authored-by: Clément Vannicatte <vannicattec@gmail.com>
algolia-bot added a commit to algolia/algoliasearch-client-javascript that referenced this pull request Sep 3, 2024
algolia/api-clients-automation#3640

Co-authored-by: algolia-bot <accounts+algolia-api-client-bot@algolia.com>
Co-authored-by: Clément Vannicatte <vannicattec@gmail.com>
@xPaw
Copy link

xPaw commented Sep 12, 2024

After this release, the umd build lite client (dist/lite/builds/browser.umd.js) is being exported as window.lite.liteClient, but before it was being exported as window[ 'algoliasearch/lite' ].liteClient, this does not seem ideal.

@shortcuts
Copy link
Member Author

indeed @xPaw and this shouldn't have changed (created an issue #3700), I'll try to see if we can provide both

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[bug]: Could not find a declaration file for module '@algolia/client-search' in v5.2.2
4 participants