Skip to content

fix(javascript): import type for bundler #4020

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 2 commits into from
Oct 23, 2024
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
3 changes: 1 addition & 2 deletions clients/algoliasearch-client-javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@
"packages/*"
],
"scripts": {
"build:all": "lerna run build --include-dependencies",
"build:many": "lerna run build --scope 'algoliasearch' --scope '@algolia/requester-testing' --scope '@algolia/logger-console' --scope ${0:-'{@algolia/*,algoliasearch}'} --include-dependencies",
"build": "lerna run build --scope '@algolia/requester-testing' --scope '@algolia/logger-console' --scope 'algoliasearch' --include-dependencies",
Copy link
Member Author

Choose a reason for hiding this comment

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

now that algoliasearch has everything as a deps, we don't need to select what to run, just ask for algoliasearch

"clean": "lerna run clean",
"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",
Expand Down
1 change: 1 addition & 0 deletions clients/algoliasearch-client-javascript/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"compilerOptions": {
"allowJs": false,
"verbatimModuleSyntax": true,
"allowSyntheticDefaultImports": true,
"declaration": true,
"esModuleInterop": true,
Expand Down
5 changes: 1 addition & 4 deletions scripts/buildLanguages.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ async function buildLanguage(language: Language, gens: Generator[], buildType: B
case 'javascript':
await run('YARN_ENABLE_IMMUTABLE_INSTALLS=false yarn install', { cwd, language });
if (buildType === 'client') {
const packageNames = gens.map(({ additionalProperties: { packageName } }) =>
packageName === 'algoliasearch' ? packageName : `@algolia/${packageName}`,
);
await run(`yarn build:many '{${packageNames.join(',')},}'`, { cwd, language });
await run(`yarn build`, { cwd, language });
break;
}

Expand Down
9 changes: 1 addition & 8 deletions scripts/ci/githubActions/createMatrix.ts
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,7 @@ async function createClientMatrix(baseBranch: string): Promise<void> {
languageMatrix.testsToStore = `${languageMatrix.testsToStore} ${testsRootFolder}/build.gradle`;
break;
case 'javascript':
const packageNames = matrix[language].toRun.map((client) => {
const packageName = GENERATORS[`${language}-${client}`].additionalProperties.packageName;

// `algoliasearch` is not preceded by `@algolia`
return client === 'algoliasearch' ? packageName : `@algolia/${packageName}`;
});

languageMatrix.buildCommand = `cd ${matrix[language].path} && yarn build:many '{${packageNames.join(',')},}'`;
languageMatrix.buildCommand = `cd ${matrix[language].path} && yarn build`;
languageMatrix.testsToStore = `${languageMatrix.testsToStore} ${testsRootFolder}/package.json`;

setOutput('JAVASCRIPT_DATA', JSON.stringify(languageMatrix));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,10 +98,10 @@ import type {
Widgets,
} from '@algolia/client-search';
import { apiClientVersion } from '@algolia/client-search';
import {
import type {
Status,
} from '@algolia/client-abtesting';
import {
import type {
EventType,
} from '@algolia/client-personalization';

Expand All @@ -113,7 +113,7 @@ export * from '{{{dependencyPackage}}}';
{{/dependencies}}
export * from '@algolia/client-search';

export {
export type {
Action,
AdvancedSyntaxFeatures,
AlternativesAsExact,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
import type { SearchForFacetsOptions } from './searchForFacetsOptions';
import type { SearchForHitsOptions } from './searchForHitsOptions';
import { SearchParamsObject } from './searchParamsObject';
import type { SearchParamsObject } from './searchParamsObject';
16 changes: 9 additions & 7 deletions templates/javascript/clients/client/builds/definition.mustache
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
import { createXhrRequester } from '@algolia/requester-browser-xhr';
import { createHttpRequester } from '@algolia/requester-node-http';
import { createFetchRequester } from '@algolia/requester-fetch';
import { createNullLogger, createMemoryCache, createFallbackableCache, createBrowserLocalStorageCache, createNullCache, ClientOptions, serializeQueryParameters, DEFAULT_CONNECT_TIMEOUT_NODE, DEFAULT_READ_TIMEOUT_NODE, DEFAULT_WRITE_TIMEOUT_NODE, DEFAULT_CONNECT_TIMEOUT_BROWSER, DEFAULT_READ_TIMEOUT_BROWSER, DEFAULT_WRITE_TIMEOUT_BROWSER } from '@algolia/client-common';
import { createNullLogger, createMemoryCache, createFallbackableCache, createBrowserLocalStorageCache, createNullCache, serializeQueryParameters, DEFAULT_CONNECT_TIMEOUT_NODE, DEFAULT_READ_TIMEOUT_NODE, DEFAULT_WRITE_TIMEOUT_NODE, DEFAULT_CONNECT_TIMEOUT_BROWSER, DEFAULT_READ_TIMEOUT_BROWSER, DEFAULT_WRITE_TIMEOUT_BROWSER } from '@algolia/client-common';

import type { ClientOptions } from '@algolia/client-common';

import { create{{#lambda.titlecase}}{{clientName}}{{/lambda.titlecase}}, apiClientVersion } from '../src/{{clientName}}';

{{#hasRegionalHost}}
import { Region, REGIONS, RegionOptions } from '../src/{{clientName}}';
import { REGIONS } from '../src/{{clientName}}';
import type { Region, RegionOptions } from '../src/{{clientName}}';

export type { Region, RegionOptions } from '../src/{{clientName}}';
{{/hasRegionalHost}}

{{! We don't use `export *` to prevent exposing the factory, to avoid confusion for the user }}
export {
apiClientVersion,
{{#hasRegionalHost}}
Region,
RegionOptions,
{{/hasRegionalHost}}
{{#isIngestionClient}}
isOnDemandTrigger,
isScheduleTrigger,
isSubscriptionTrigger,
{{/isIngestionClient}}
} from '../src/{{clientName}}';

export * from '../model';

{{#isSearchClient}}
import { GenerateSecuredApiKeyOptions, GetSecuredApiKeyRemainingValidityOptions, SearchClientNodeHelpers } from '../model';
import type { GenerateSecuredApiKeyOptions, GetSecuredApiKeyRemainingValidityOptions, SearchClientNodeHelpers } from '../model';
{{/isSearchClient}}

{{#nodeSearchHelpers}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
{{#apiInfo.apis.0}}

{{#imports}}
import { {{classname}} } from '{{filename}}';
import type { {{classname}} } from '{{filename}}';
{{/imports}}

{{! Imports for the legacy search method signature }}
Expand Down
Loading