Skip to content

Commit c713fd5

Browse files
43081jnatemoo-re
andauthored
feat!: move to esm-only (#246)
Co-authored-by: Nate Moore <[email protected]>
1 parent a818595 commit c713fd5

File tree

18 files changed

+43
-37
lines changed

18 files changed

+43
-37
lines changed

.changeset/legal-bags-tie.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
---
2+
"@clack/prompts": major
3+
"@clack/core": major
4+
---
5+
6+
The package is now distributed as ESM-only. In `v0` releases, the package was dual-published as CJS and ESM.
7+
8+
For existing CJS projects using Node v20+, please see Node's guide on [Loading ECMAScript modules using `require()`](https://nodejs.org/docs/latest-v20.x/api/modules.html#loading-ecmascript-modules-using-require).

.github/workflows/lint.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ jobs:
1818
node-version: 20
1919
cache: "pnpm"
2020
- run: pnpm install
21+
- run: pnpm build
2122
- run: pnpm type-check

build.preset.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ export default definePreset({
66
declaration: true,
77
sourcemap: true,
88
rollup: {
9-
emitCJS: true,
9+
emitCJS: false,
1010
inlineDependencies: true,
1111
esbuild: {
1212
minify: true,

packages/core/package.json

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,12 @@
22
"name": "@clack/core",
33
"version": "0.4.1",
44
"type": "module",
5-
"main": "./dist/index.cjs",
5+
"main": "./dist/index.mjs",
66
"module": "./dist/index.mjs",
77
"exports": {
88
".": {
99
"types": "./dist/index.d.ts",
10-
"import": "./dist/index.mjs",
11-
"require": "./dist/index.cjs"
10+
"default": "./dist/index.mjs"
1211
},
1312
"./package.json": "./package.json"
1413
},

packages/core/src/index.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
export type { ClackState as State } from './types';
2-
export type { ClackSettings } from './utils/settings';
1+
export type { ClackState as State } from './types.js';
2+
export type { ClackSettings } from './utils/settings.js';
33

4-
export { default as ConfirmPrompt } from './prompts/confirm';
5-
export { default as GroupMultiSelectPrompt } from './prompts/group-multiselect';
6-
export { default as MultiSelectPrompt } from './prompts/multi-select';
7-
export { default as PasswordPrompt } from './prompts/password';
8-
export { default as Prompt } from './prompts/prompt';
9-
export { default as SelectPrompt } from './prompts/select';
10-
export { default as SelectKeyPrompt } from './prompts/select-key';
11-
export { default as TextPrompt } from './prompts/text';
12-
export { block, isCancel } from './utils';
13-
export { updateSettings } from './utils/settings';
4+
export { default as ConfirmPrompt } from './prompts/confirm.js';
5+
export { default as GroupMultiSelectPrompt } from './prompts/group-multiselect.js';
6+
export { default as MultiSelectPrompt } from './prompts/multi-select.js';
7+
export { default as PasswordPrompt } from './prompts/password.js';
8+
export { default as Prompt } from './prompts/prompt.js';
9+
export { default as SelectPrompt } from './prompts/select.js';
10+
export { default as SelectKeyPrompt } from './prompts/select-key.js';
11+
export { default as TextPrompt } from './prompts/text.js';
12+
export { block, isCancel } from './utils/index.js';
13+
export { updateSettings } from './utils/settings.js';

packages/core/src/prompts/confirm.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { cursor } from 'sisteransi';
2-
import Prompt, { type PromptOptions } from './prompt';
2+
import Prompt, { type PromptOptions } from './prompt.js';
33

44
interface ConfirmOptions extends PromptOptions<ConfirmPrompt> {
55
active: string;

packages/core/src/prompts/group-multiselect.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Prompt, { type PromptOptions } from './prompt';
1+
import Prompt, { type PromptOptions } from './prompt.js';
22

33
interface GroupMultiSelectOptions<T extends { value: any }>
44
extends PromptOptions<GroupMultiSelectPrompt<T>> {

packages/core/src/prompts/multi-select.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Prompt, { type PromptOptions } from './prompt';
1+
import Prompt, { type PromptOptions } from './prompt.js';
22

33
interface MultiSelectOptions<T extends { value: any }> extends PromptOptions<MultiSelectPrompt<T>> {
44
options: T[];

packages/core/src/prompts/password.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import color from 'picocolors';
2-
import Prompt, { type PromptOptions } from './prompt';
2+
import Prompt, { type PromptOptions } from './prompt.js';
33

44
interface PasswordOptions extends PromptOptions<PasswordPrompt> {
55
mask?: string;

packages/core/src/prompts/prompt.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,10 @@ import { WriteStream } from 'node:tty';
55
import { cursor, erase } from 'sisteransi';
66
import wrap from 'wrap-ansi';
77

8-
import { CANCEL_SYMBOL, diffLines, isActionKey, setRawMode, settings } from '../utils';
8+
import { CANCEL_SYMBOL, diffLines, isActionKey, setRawMode, settings } from '../utils/index.js';
99

10-
import type { ClackEvents, ClackState } from '../types';
11-
import type { Action } from '../utils';
10+
import type { ClackEvents, ClackState } from '../types.js';
11+
import type { Action } from '../utils/index.js';
1212

1313
export interface PromptOptions<Self extends Prompt> {
1414
render(this: Omit<Self, 'prompt'>): string | undefined;

0 commit comments

Comments
 (0)