Skip to content

Commit 5d17278

Browse files
committed
own review
1 parent 9eb3d28 commit 5d17278

File tree

8 files changed

+61
-75
lines changed

8 files changed

+61
-75
lines changed

clients/algoliasearch-client-javascript/base.rollup.config.js

Lines changed: 47 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@ function createBundlers({ output, isLiteClient }) {
8585
}
8686

8787
/**
88-
* Build configs to iterate on based on the package.json information.
88+
* Build configs to iterate on based on the given `package.json`.
8989
*/
9090
function getBaseConfigs(pkg) {
9191
const packageName = pkg.name.replace(NPM_ORG, '');
@@ -97,20 +97,19 @@ function getBaseConfigs(pkg) {
9797
output: packageName,
9898
plugins: [],
9999
external: [],
100+
formats: NODE_FORMATS,
100101
};
101102

102103
if (isUtils) {
103104
return [
104105
{
105106
...commonConfig,
106107
...UTILS[packageName],
107-
formats: NODE_FORMATS,
108108
input: 'index.ts',
109109
},
110110
];
111111
}
112112

113-
const baseConfigs = [];
114113
const isAlgoliasearchClient = packageName === 'algoliasearch';
115114
const configPerEnv = {
116115
browser: {
@@ -125,47 +124,52 @@ function getBaseConfigs(pkg) {
125124
node: {
126125
...commonConfig,
127126
input: 'builds/node.ts',
128-
formats: NODE_FORMATS,
129127
},
130128
};
131129

132-
// This non-generated client is an aggregation of client, hence does not follow
133-
// the same build process.
134-
if (isAlgoliasearchClient) {
135-
const litePackageName = `${packageName}/lite`;
136-
baseConfigs.push(
137-
{
138-
...commonConfig,
139-
...configPerEnv.browser,
140-
package: litePackageName,
141-
name: litePackageName,
142-
output: 'lite',
143-
input: 'lite/builds/browser.ts',
144-
dependencies: [
145-
`${NPM_ORG}client-common`,
146-
`${NPM_ORG}requester-browser-xhr`,
147-
],
148-
globals: {
149-
[litePackageName]: litePackageName,
150-
},
151-
},
152-
// Node build
153-
{
154-
...commonConfig,
155-
...configPerEnv.node,
156-
package: litePackageName,
157-
name: litePackageName,
158-
output: 'lite',
159-
input: 'lite/builds/node.ts',
160-
dependencies: [
161-
`${NPM_ORG}client-common`,
162-
`${NPM_ORG}requester-node-http`,
163-
],
164-
}
165-
);
130+
if (!isAlgoliasearchClient) {
131+
return [configPerEnv.browser, configPerEnv.node];
166132
}
167133

168-
return [configPerEnv.browser, configPerEnv.node, ...baseConfigs];
134+
/**
135+
* Algoliasearch is am aggregation of sub clients, plus provide a `lite` version
136+
* that needs its own build.
137+
*/
138+
const litePackageName = `${packageName}/lite`;
139+
return [
140+
// algoliasearch client configs
141+
configPerEnv.browser,
142+
configPerEnv.node,
143+
// lite client configs
144+
{
145+
...commonConfig,
146+
...configPerEnv.browser,
147+
package: litePackageName,
148+
name: litePackageName,
149+
output: 'lite',
150+
input: 'lite/builds/browser.ts',
151+
dependencies: [
152+
`${NPM_ORG}client-common`,
153+
`${NPM_ORG}requester-browser-xhr`,
154+
],
155+
globals: {
156+
[litePackageName]: litePackageName,
157+
},
158+
},
159+
// Node build
160+
{
161+
...commonConfig,
162+
...configPerEnv.node,
163+
package: litePackageName,
164+
name: litePackageName,
165+
output: 'lite',
166+
input: 'lite/builds/node.ts',
167+
dependencies: [
168+
`${NPM_ORG}client-common`,
169+
`${NPM_ORG}requester-node-http`,
170+
],
171+
},
172+
];
169173
}
170174

171175
/**
@@ -179,20 +183,18 @@ function shouldCheckForTypes(name, currentFormat, isLiteClient) {
179183
};
180184

181185
// Initialize with defaults
182-
if (!TYPES_TO_CHECK[name]) {
186+
if (TYPES_TO_CHECK[name] === undefined) {
183187
TYPES_TO_CHECK[name] = defaults;
184188
}
185189

186-
const isBrowserFormat = BROWSER_FORMATS.includes(currentFormat);
187-
const isNodeFormat = NODE_FORMATS.includes(currentFormat);
188-
189-
if (isBrowserFormat && TYPES_TO_CHECK[name].browser) {
190+
// We then set the value for the key to false when it matches its build format
191+
if (BROWSER_FORMATS.includes(currentFormat) && TYPES_TO_CHECK[name].browser) {
190192
TYPES_TO_CHECK[name].browser = false;
191193

192194
return true;
193195
}
194196

195-
if (isNodeFormat && TYPES_TO_CHECK[name].node) {
197+
if (NODE_FORMATS.includes(currentFormat) && TYPES_TO_CHECK[name].node) {
196198
TYPES_TO_CHECK[name].node = false;
197199

198200
return true;

clients/algoliasearch-client-javascript/packages/client-common/rollup.config.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@ import { buildConfigs } from '../../base.rollup.config';
22

33
import pkg from './package.json';
44

5-
const configs = buildConfigs(pkg);
6-
7-
export default configs;
5+
export default buildConfigs(pkg);

clients/algoliasearch-client-javascript/packages/requester-browser-xhr/rollup.config.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@ import { buildConfigs } from '../../base.rollup.config';
22

33
import pkg from './package.json';
44

5-
const configs = buildConfigs(pkg);
6-
7-
export default configs;
5+
export default buildConfigs(pkg);

clients/algoliasearch-client-javascript/packages/requester-fetch/rollup.config.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@ import { buildConfigs } from '../../base.rollup.config';
22

33
import pkg from './package.json';
44

5-
const configs = buildConfigs(pkg);
6-
7-
export default configs;
5+
export default buildConfigs(pkg);

clients/algoliasearch-client-javascript/packages/requester-node-http/rollup.config.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@ import { buildConfigs } from '../../base.rollup.config';
22

33
import pkg from './package.json';
44

5-
const configs = buildConfigs(pkg);
6-
7-
export default configs;
5+
export default buildConfigs(pkg);

clients/algoliasearch-client-javascript/yarn.lock

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@ __metadata:
1313
"@algolia/requester-browser-xhr": 5.0.0-alpha.5
1414
"@algolia/requester-node-http": 5.0.0-alpha.5
1515
"@types/node": 16.11.47
16-
rollup: 2.77.2
1716
typescript: 4.7.4
1817
languageName: unknown
1918
linkType: soft
@@ -26,7 +25,6 @@ __metadata:
2625
"@algolia/requester-browser-xhr": 5.0.0-alpha.5
2726
"@algolia/requester-node-http": 5.0.0-alpha.5
2827
"@types/node": 16.11.47
29-
rollup: 2.77.2
3028
typescript: 4.7.4
3129
languageName: unknown
3230
linkType: soft
@@ -52,7 +50,6 @@ __metadata:
5250
"@algolia/requester-browser-xhr": 5.0.0-alpha.5
5351
"@algolia/requester-node-http": 5.0.0-alpha.5
5452
"@types/node": 16.11.47
55-
rollup: 2.77.2
5653
typescript: 4.7.4
5754
languageName: unknown
5855
linkType: soft
@@ -65,7 +62,6 @@ __metadata:
6562
"@algolia/requester-browser-xhr": 5.0.0-alpha.5
6663
"@algolia/requester-node-http": 5.0.0-alpha.5
6764
"@types/node": 16.11.47
68-
rollup: 2.77.2
6965
typescript: 4.7.4
7066
languageName: unknown
7167
linkType: soft
@@ -78,7 +74,6 @@ __metadata:
7874
"@algolia/requester-browser-xhr": 5.0.0-alpha.5
7975
"@algolia/requester-node-http": 5.0.0-alpha.5
8076
"@types/node": 16.11.47
81-
rollup: 2.77.2
8277
typescript: 4.7.4
8378
languageName: unknown
8479
linkType: soft
@@ -91,7 +86,6 @@ __metadata:
9186
"@algolia/requester-browser-xhr": 5.0.0-alpha.5
9287
"@algolia/requester-node-http": 5.0.0-alpha.5
9388
"@types/node": 16.11.47
94-
rollup: 2.77.2
9589
typescript: 4.7.4
9690
languageName: unknown
9791
linkType: soft
@@ -104,7 +98,6 @@ __metadata:
10498
"@algolia/requester-browser-xhr": 5.0.0-alpha.5
10599
"@algolia/requester-node-http": 5.0.0-alpha.5
106100
"@types/node": 16.11.47
107-
rollup: 2.77.2
108101
typescript: 4.7.4
109102
languageName: unknown
110103
linkType: soft
@@ -117,7 +110,6 @@ __metadata:
117110
"@algolia/requester-browser-xhr": 5.0.0-alpha.5
118111
"@algolia/requester-node-http": 5.0.0-alpha.5
119112
"@types/node": 16.11.47
120-
rollup: 2.77.2
121113
typescript: 4.7.4
122114
languageName: unknown
123115
linkType: soft
@@ -130,7 +122,6 @@ __metadata:
130122
"@algolia/requester-browser-xhr": 5.0.0-alpha.5
131123
"@algolia/requester-node-http": 5.0.0-alpha.5
132124
"@types/node": 16.11.47
133-
rollup: 2.77.2
134125
typescript: 4.7.4
135126
languageName: unknown
136127
linkType: soft
@@ -3830,7 +3821,6 @@ __metadata:
38303821
"@types/jest": 28.1.6
38313822
"@types/node": 16.11.47
38323823
jest: 28.1.3
3833-
rollup: 2.77.2
38343824
ts-jest: 28.0.7
38353825
typescript: 4.7.4
38363826
languageName: unknown

scripts/ci/githubActions/createMatrix.ts

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,15 @@ async function getClientMatrix(baseBranch: string): Promise<void> {
107107
case 'java':
108108
testsToStore = `${testsToStore} ${testsRootFolder}/build.gradle`;
109109
break;
110-
// The CI runs on a node docker image, therefore it's not needed to run via the CLI
110+
/**
111+
* The CI runs on a node docker image, therefore it's not needed to run
112+
* via the CLI for the JavaScript client.
113+
*/
111114
case 'javascript':
115+
const npmNamespace = getClientsConfigField(
116+
'javascript',
117+
'npmNamespace'
118+
);
112119
const packages = matrix[language].toRun.map((client) => {
113120
const packageName =
114121
GENERATORS[`${language}-${client}`].additionalProperties
@@ -117,10 +124,7 @@ async function getClientMatrix(baseBranch: string): Promise<void> {
117124
// `algoliasearch` is not preceded by `@algolia`
118125
return client === 'algoliasearch'
119126
? packageName
120-
: `${getClientsConfigField(
121-
'javascript',
122-
'npmNamespace'
123-
)}/${packageName}`;
127+
: `${npmNamespace}/${packageName}`;
124128
});
125129

126130
buildCommand = `cd ${

templates/javascript/clients/rollup.mustache

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,4 @@ import { buildConfigs } from '../../base.rollup.config';
22

33
import pkg from './package.json';
44

5-
const configs = buildConfigs(pkg);
6-
7-
export default configs;
5+
export default buildConfigs(pkg);

0 commit comments

Comments
 (0)