Skip to content

Commit

Permalink
fix(javascript): publish script esm (#1787)
Browse files Browse the repository at this point in the history
  • Loading branch information
shortcuts committed Jul 20, 2023
1 parent 908d7a0 commit 96ab1c3
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 23 deletions.
2 changes: 1 addition & 1 deletion clients/algoliasearch-client-javascript/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
"build:many": "lerna run build --include-dependencies --scope ${0:-'{@algolia/*,algoliasearch}'}",
"clean": "lerna run clean --include-dependencies",
"release:bump": "lerna version ${0:-patch} --no-changelog --no-git-tag-version --no-push --exact --force-publish --yes",
"release:publish": "ts-node --project tsconfig.script.json scripts/publish.ts",
"release:publish": "ts-node --esm --project tsconfig.script.json scripts/publish.ts",
"test:size": "bundlesize"
},
"devDependencies": {
Expand Down
26 changes: 5 additions & 21 deletions clients/algoliasearch-client-javascript/scripts/publish.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,13 @@
import fsp from 'fs/promises';
import path from 'path';

import execa from 'execa';
import { execaCommand } from 'execa';
import semver from 'semver';

async function publish(): Promise<void> {
// Read the local version of `algoliasearch/package.json`
const { version } = JSON.parse(
(
await fsp.readFile(
path.resolve(
__dirname,
'..',
'packages',
'algoliasearch',
'package.json'
)
)
).toString()
);
import packageJSON from "../packages/algoliasearch/package.json" assert { type: "json" };

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

await execa.command(
await execaCommand(
`lerna exec --no-bail -- npm_config_registry=https://registry.npmjs.org/ npm publish --access public ${
tag ? `--tag ${tag}` : ''
}`,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"extends": "./tsconfig.json",
"compilerOptions": {
"module": "commonjs"
"resolveJsonModule": true
}
}

0 comments on commit 96ab1c3

Please sign in to comment.