Skip to content

Commit d2176dc

Browse files
committed
feat!: move to esm-only
Migrates to emitting only ES modules now that `require(esm)` is supported in all LTS versions of node other than the soon-to-die-off 18.x.
1 parent 5529c89 commit d2176dc

File tree

15 files changed

+33
-36
lines changed

15 files changed

+33
-36
lines changed

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;

packages/core/src/prompts/select-key.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 SelectKeyOptions<T extends { value: any }> extends PromptOptions<SelectKeyPrompt<T>> {
44
options: T[];

packages/core/src/prompts/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 SelectOptions<T extends { value: any }> extends PromptOptions<SelectPrompt<T>> {
44
options: T[];

0 commit comments

Comments
 (0)