Skip to content

Commit 96ab1c3

Browse files
authored
fix(javascript): publish script esm (#1787)
1 parent 908d7a0 commit 96ab1c3

File tree

3 files changed

+7
-23
lines changed

3 files changed

+7
-23
lines changed

clients/algoliasearch-client-javascript/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"build:many": "lerna run build --include-dependencies --scope ${0:-'{@algolia/*,algoliasearch}'}",
1111
"clean": "lerna run clean --include-dependencies",
1212
"release:bump": "lerna version ${0:-patch} --no-changelog --no-git-tag-version --no-push --exact --force-publish --yes",
13-
"release:publish": "ts-node --project tsconfig.script.json scripts/publish.ts",
13+
"release:publish": "ts-node --esm --project tsconfig.script.json scripts/publish.ts",
1414
"test:size": "bundlesize"
1515
},
1616
"devDependencies": {

clients/algoliasearch-client-javascript/scripts/publish.ts

Lines changed: 5 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,13 @@
1-
import fsp from 'fs/promises';
2-
import path from 'path';
3-
4-
import execa from 'execa';
1+
import { execaCommand } from 'execa';
52
import semver from 'semver';
63

7-
async function publish(): Promise<void> {
8-
// Read the local version of `algoliasearch/package.json`
9-
const { version } = JSON.parse(
10-
(
11-
await fsp.readFile(
12-
path.resolve(
13-
__dirname,
14-
'..',
15-
'packages',
16-
'algoliasearch',
17-
'package.json'
18-
)
19-
)
20-
).toString()
21-
);
4+
import packageJSON from "../packages/algoliasearch/package.json" assert { type: "json" };
225

6+
async function publish(): Promise<void> {
237
// Get tag like `alpha`, `beta`, ...
24-
const tag = semver.prerelease(version)?.[0];
8+
const tag = semver.prerelease(packageJSON.version)?.[0];
259

26-
await execa.command(
10+
await execaCommand(
2711
`lerna exec --no-bail -- npm_config_registry=https://registry.npmjs.org/ npm publish --access public ${
2812
tag ? `--tag ${tag}` : ''
2913
}`,
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"extends": "./tsconfig.json",
33
"compilerOptions": {
4-
"module": "commonjs"
4+
"resolveJsonModule": true
55
}
66
}

0 commit comments

Comments
 (0)