Skip to content

Commit 9f5a430

Browse files
committed
test cache build
1 parent 96b8068 commit 9f5a430

File tree

3 files changed

+88
-89
lines changed

3 files changed

+88
-89
lines changed

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

Lines changed: 86 additions & 88 deletions
Original file line numberDiff line numberDiff line change
@@ -38,94 +38,6 @@ const UTILS = {
3838
},
3939
};
4040

41-
function getBaseConfigs(pkg) {
42-
const packageName = pkg.name.replace(NPM_ORG, '');
43-
const isUtils = UTILS[packageName] !== undefined;
44-
const baseConfigs = [];
45-
46-
if (!isUtils) {
47-
const isAlgoliasearchClient = packageName === 'algoliasearch';
48-
const commonConfig = {
49-
package: packageName,
50-
name: pkg.name,
51-
output: packageName,
52-
dependencies: pkg.dependencies ? Object.keys(pkg.dependencies) : [],
53-
external: [],
54-
plugins: [],
55-
};
56-
57-
// This non-generated client is an aggregation of client, hence does not follow
58-
// the same build process.
59-
if (isAlgoliasearchClient) {
60-
const litePackageName = `${packageName}/lite`;
61-
baseConfigs.push(
62-
{
63-
...commonConfig,
64-
package: litePackageName,
65-
name: litePackageName,
66-
output: 'lite',
67-
input: 'lite/builds/browser.ts',
68-
formats: BROWSER_FORMATS,
69-
external: ['dom'],
70-
dependencies: [
71-
`${NPM_ORG}client-common`,
72-
`${NPM_ORG}requester-browser-xhr`,
73-
],
74-
globals: {
75-
[litePackageName]: litePackageName,
76-
},
77-
},
78-
// Node build
79-
{
80-
...commonConfig,
81-
package: litePackageName,
82-
name: litePackageName,
83-
output: 'lite',
84-
input: 'lite/builds/node.ts',
85-
formats: NODE_FORMATS,
86-
dependencies: [
87-
`${NPM_ORG}client-common`,
88-
`${NPM_ORG}requester-node-http`,
89-
],
90-
}
91-
);
92-
}
93-
94-
baseConfigs.push(
95-
// Browser build
96-
{
97-
...commonConfig,
98-
input: 'builds/browser.ts',
99-
formats: BROWSER_FORMATS,
100-
external: ['dom'],
101-
globals: {
102-
[packageName]: packageName,
103-
},
104-
},
105-
// Node build
106-
{
107-
...commonConfig,
108-
input: 'builds/node.ts',
109-
formats: NODE_FORMATS,
110-
}
111-
);
112-
113-
return baseConfigs;
114-
}
115-
116-
return [
117-
{
118-
...UTILS[packageName],
119-
formats: NODE_FORMATS,
120-
input: 'index.ts',
121-
dependencies: pkg.dependencies ? Object.keys(pkg.dependencies) : [],
122-
package: packageName,
123-
name: pkg.name,
124-
output: packageName,
125-
},
126-
];
127-
}
128-
12941
/**
13042
* Returns the license at the top of the UMD bundled file.
13143
*/
@@ -168,6 +80,92 @@ function createBundlers({ output, isLiteClient }) {
16880
};
16981
}
17082

83+
/**
84+
* Build configs to iterate on based on the package.json information.
85+
*/
86+
function getBaseConfigs(pkg) {
87+
const packageName = pkg.name.replace(NPM_ORG, '');
88+
const isUtils = UTILS[packageName] !== undefined;
89+
90+
if (isUtils) {
91+
return [
92+
{
93+
...UTILS[packageName],
94+
formats: NODE_FORMATS,
95+
input: 'index.ts',
96+
dependencies: pkg.dependencies ? Object.keys(pkg.dependencies) : [],
97+
package: packageName,
98+
name: pkg.name,
99+
output: packageName,
100+
},
101+
];
102+
}
103+
104+
const baseConfigs = [];
105+
const isAlgoliasearchClient = packageName === 'algoliasearch';
106+
const commonConfig = {
107+
package: packageName,
108+
name: pkg.name,
109+
output: packageName,
110+
dependencies: pkg.dependencies ? Object.keys(pkg.dependencies) : [],
111+
external: [],
112+
plugins: [],
113+
};
114+
const configPerEnv = {
115+
browser: {
116+
...commonConfig,
117+
input: 'builds/browser.ts',
118+
formats: BROWSER_FORMATS,
119+
external: ['dom'],
120+
globals: {
121+
[packageName]: packageName,
122+
},
123+
},
124+
node: {
125+
...commonConfig,
126+
input: 'builds/node.ts',
127+
formats: NODE_FORMATS,
128+
},
129+
};
130+
131+
// This non-generated client is an aggregation of client, hence does not follow
132+
// the same build process.
133+
if (isAlgoliasearchClient) {
134+
const litePackageName = `${packageName}/lite`;
135+
baseConfigs.push(
136+
{
137+
...commonConfig,
138+
...configPerEnv.browser,
139+
package: litePackageName,
140+
name: litePackageName,
141+
output: 'lite',
142+
input: 'lite/builds/browser.ts',
143+
dependencies: [
144+
`${NPM_ORG}client-common`,
145+
`${NPM_ORG}requester-browser-xhr`,
146+
],
147+
globals: {
148+
[litePackageName]: litePackageName,
149+
},
150+
},
151+
// Node build
152+
{
153+
...commonConfig,
154+
package: litePackageName,
155+
name: litePackageName,
156+
output: 'lite',
157+
input: 'lite/builds/node.ts',
158+
dependencies: [
159+
`${NPM_ORG}client-common`,
160+
`${NPM_ORG}requester-node-http`,
161+
],
162+
}
163+
);
164+
}
165+
166+
return [...baseConfigs, configPerEnv.browser, configPerEnv.node];
167+
}
168+
171169
export function buildConfigs(pkg) {
172170
const baseConfigs = getBaseConfigs(pkg);
173171
const rollupConfig = [];

clients/algoliasearch-client-javascript/nx.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
"options": {
66
"cacheableOperations": [
77
"build:utils",
8-
"build:specific",
8+
"build:many",
99
"build:all",
1010
"build"
1111
]

clients/algoliasearch-client-javascript/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
"build:all": "lerna run build --parallel --ignore '{@algolia/requester-*,@algolia/client-common}'",
99
"build:many": "lerna run build --parallel --scope ${0:-'*'}",
1010
"build:utils": "lerna run build --parallel --scope '{@algolia/requester-*,@algolia/client-common}'",
11+
"clean": "lerna run clean --parallel",
1112
"release:bump": "lerna version ${0:-patch} --no-changelog --no-git-tag-version --no-push --exact --force-publish --yes",
1213
"release:publish": "ts-node --project tsconfig.script.json scripts/publish.ts",
1314
"test:lint": "eslint . --ext .js,.ts",

0 commit comments

Comments
 (0)