Skip to content

feat(javascript): nest lite package in algoliasearch #729

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

Merged
merged 1 commit into from
Jun 22, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
2 changes: 1 addition & 1 deletion .github/workflows/check.yml
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ jobs:

- name: Build clients
if: ${{ steps.cache.outputs.cache-hit != 'true' && matrix.client.language != 'php' }}
run: yarn cli build clients ${{ matrix.client.language }} ${{ matrix.client.toRun }}
run: yarn cli build clients ${{ matrix.client.language }} ${{ matrix.client.toBuild }}

- name: Build JavaScript 'algoliasearch' client
if: ${{ steps.cache.outputs.cache-hit != 'true' && matrix.client.language == 'javascript' }}
Expand Down
5 changes: 2 additions & 3 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,10 @@ pom.xml
dist
.cache

.openapi-generator
**.openapi-generator
/openapitools.json
**/.openapi-generator-ignore

clients/algoliasearch-client-javascript/packages/*/.openapi-generator-ignore
tests/output/*/.openapi-generator-ignore
**.php-cs-fixer.cache

generators/bin
Expand Down
62 changes: 48 additions & 14 deletions clients/algoliasearch-client-javascript/base.rollup.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ import fs from 'fs';
const NPM_ORG = '@experimental-api-clients-automation/';

// Output formats
const BROWSER_FORMATS = ['esm-browser', 'cjs-browser', 'umd-browser'];
const NODE_FORMATS = ['esm-node', 'cjs-node'];
const BROWSER_FORMATS = ['esm-browser', 'umd'];
const NODE_FORMATS = ['esm-node', 'cjs'];

// Utils package with default options
const UTILS = {
Expand Down Expand Up @@ -103,10 +103,46 @@ export function getPackageConfigs() {
dependencies: [`${NPM_ORG}client-common`],
external: [],
};
let liteBuildConfig = [];

// This non-generated client is an aggregation of client, hence does not follow
// the same build process.
if (isAlgoliasearchClient) {
const litePackageName = `${packageName}/lite`;
// `algoliasearch/lite` related
liteBuildConfig = [
{
...commonConfig,
package: litePackageName,
name: litePackageName,
output: 'lite',
input: 'lite/builds/browser.ts',
formats: BROWSER_FORMATS,
external: ['dom'],
dependencies: [
...commonConfig.dependencies,
`${NPM_ORG}requester-browser-xhr`,
],
globals: {
[litePackageName]: litePackageName,
},
},
// Node build
{
...commonConfig,
package: litePackageName,
name: litePackageName,
output: 'lite',
input: 'lite/builds/node.ts',
formats: NODE_FORMATS,
dependencies: [
...commonConfig.dependencies,
`${NPM_ORG}requester-node-http`,
],
},
];

// `algoliasearch` related
commonConfig.name = packageName;
commonConfig.dependencies = [
`${NPM_ORG}client-analytics`,
Expand All @@ -117,6 +153,7 @@ export function getPackageConfigs() {
}

return [
...liteBuildConfig,
// Browser build
{
...commonConfig,
Expand Down Expand Up @@ -160,36 +197,33 @@ export function createLicense(name, version) {
/**
* Bundlers with their output format and file name for the given client.
*/
export function createBundlers({ output, clientPath }) {
export function createBundlers({ output, clientPath, isLiteClient }) {
const commonOptions = {
exports: 'named',
};

const path = isLiteClient ? `${clientPath}/dist/lite` : `${clientPath}/dist`;

return {
'esm-node': {
...commonOptions,
file: `${clientPath}/dist/${output}.esm.node.js`,
file: `${path}/${output}.esm.node.js`,
format: 'es',
},
'esm-browser': {
...commonOptions,
file: `${clientPath}/dist/${output}.esm.browser.js`,
file: `${path}/${output}.esm.browser.js`,
format: 'es',
},
'umd-browser': {
umd: {
...commonOptions,
file: `${clientPath}/dist/${output}.umd.browser.js`,
file: `${path}/${output}.umd.js`,
format: 'umd',
esModule: false,
},
'cjs-node': {
...commonOptions,
file: `${clientPath}/dist/${output}.cjs.node.js`,
format: 'cjs',
},
'cjs-browser': {
cjs: {
...commonOptions,
file: `${clientPath}/dist/${output}.cjs.browser.js`,
file: `${path}/${output}.cjs.js`,
format: 'cjs',
},
};
Expand Down
22 changes: 11 additions & 11 deletions clients/algoliasearch-client-javascript/bundlesize.config.json
Original file line number Diff line number Diff line change
@@ -1,43 +1,43 @@
{
"files": [
{
"path": "packages/algoliasearch/dist/algoliasearch.umd.browser.js",
"path": "packages/algoliasearch/dist/algoliasearch.umd.js",
"maxSize": "7.60KB"
},
{
"path": "packages/algoliasearch-lite/dist/algoliasearch-lite.umd.browser.js",
"maxSize": "3.85KB"
"path": "packages/algoliasearch/dist/lite/lite.umd.js",
"maxSize": "3.80KB"
},
{
"path": "packages/client-abtesting/dist/client-abtesting.umd.browser.js",
"path": "packages/client-abtesting/dist/client-abtesting.umd.js",
"maxSize": "3.95KB"
},
{
"path": "packages/client-analytics/dist/client-analytics.umd.browser.js",
"path": "packages/client-analytics/dist/client-analytics.umd.js",
"maxSize": "4.55KB"
},
{
"path": "packages/client-insights/dist/client-insights.umd.browser.js",
"path": "packages/client-insights/dist/client-insights.umd.js",
"maxSize": "3.80KB"
},
{
"path": "packages/client-personalization/dist/client-personalization.umd.browser.js",
"path": "packages/client-personalization/dist/client-personalization.umd.js",
"maxSize": "3.95KB"
},
{
"path": "packages/client-query-suggestions/dist/client-query-suggestions.umd.browser.js",
"path": "packages/client-query-suggestions/dist/client-query-suggestions.umd.js",
"maxSize": "4.00KB"
},
{
"path": "packages/client-search/dist/client-search.umd.browser.js",
"path": "packages/client-search/dist/client-search.umd.js",
"maxSize": "6.30KB"
},
{
"path": "packages/client-sources/dist/client-sources.umd.browser.js",
"path": "packages/client-sources/dist/client-sources.umd.js",
"maxSize": "3.80KB"
},
{
"path": "packages/recommend/dist/recommend.umd.browser.js",
"path": "packages/recommend/dist/recommend.umd.js",
"maxSize": "3.80KB"
}
]
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading