Skip to content

Commit

Permalink
feat!: move to ESM
Browse files Browse the repository at this point in the history
  • Loading branch information
aikoven committed Jul 21, 2022
1 parent 7ffa0e2 commit d7d74d2
Show file tree
Hide file tree
Showing 23 changed files with 49 additions and 64 deletions.
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
node_modules
lib
es
yarn-error.log
.idea
15 changes: 6 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,20 +14,17 @@
],
"repository": "deeplay-io/abort-controller-x",
"sideEffects": false,
"main": "lib/index.js",
"module": "es/index.js",
"typings": "lib/index.d.ts",
"type": "module",
"exports": "./lib/index.js",
"typings": "./lib/index.d.ts",
"files": [
"src",
"lib",
"es"
"lib"
],
"scripts": {
"clean": "rimraf lib es",
"clean": "rimraf lib",
"test": "jest",
"build:lib": "tsc -P tsconfig.build.json",
"build:es": "tsc -P tsconfig.es.json",
"build": "npm run build:lib && npm run build:es",
"build": "tsc -P tsconfig.build.json",
"prepublishOnly": "npm test && npm run clean && npm run build"
},
"author": "Daniel Lytkin <aikoven@deeplay.io>",
Expand Down
2 changes: 1 addition & 1 deletion src/AbortError.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
isAbortError,
rethrowAbortError,
throwIfAborted,
} from './AbortError';
} from './AbortError.js';

test('isAbortError', () => {
expect(isAbortError({})).toBe(false);
Expand Down
4 changes: 2 additions & 2 deletions src/abortable.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {abortable} from './abortable';
import {nextTick} from './utils/nextTick';
import {abortable} from './abortable.js';
import {nextTick} from './utils/nextTick.js';

test('abortable endless promise', async () => {
const abortController = new AbortController();
Expand Down
2 changes: 1 addition & 1 deletion src/abortable.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {execute} from './execute';
import {execute} from './execute.js';

/**
* Wrap a promise to reject with `AbortError` once `signal` is aborted.
Expand Down
6 changes: 3 additions & 3 deletions src/all.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import defer = require('defer-promise');
import {AbortError} from './AbortError';
import {all} from './all';
import {nextTick} from './utils/nextTick';
import {AbortError} from './AbortError.js';
import {all} from './all.js';
import {nextTick} from './utils/nextTick.js';

test('external abort', async () => {
const abortController = new AbortController();
Expand Down
2 changes: 1 addition & 1 deletion src/all.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {AbortError, isAbortError} from './AbortError';
import {AbortError, isAbortError} from './AbortError.js';

/**
* Abortable version of `Promise.all`.
Expand Down
2 changes: 1 addition & 1 deletion src/delay.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {execute} from './execute';
import {execute} from './execute.js';

/**
* Returns a promise that fulfills after delay and rejects with
Expand Down
4 changes: 2 additions & 2 deletions src/execute.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import defer = require('defer-promise');
import {execute} from './execute';
import {nextTick} from './utils/nextTick';
import {execute} from './execute.js';
import {nextTick} from './utils/nextTick.js';

test('resolve immediately', async () => {
const abortController = new AbortController();
Expand Down
2 changes: 1 addition & 1 deletion src/execute.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {AbortError} from './AbortError';
import {AbortError} from './AbortError.js';

/**
* Similar to `new Promise(executor)`, but allows executor to return abort
Expand Down
4 changes: 2 additions & 2 deletions src/forever.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {forever} from './forever';
import {nextTick} from './utils/nextTick';
import {forever} from './forever.js';
import {nextTick} from './utils/nextTick.js';

test('forever', async () => {
const abortController = new AbortController();
Expand Down
2 changes: 1 addition & 1 deletion src/forever.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {execute} from './execute';
import {execute} from './execute.js';

/**
* Return a promise that never fulfills and only rejects with `AbortError` once
Expand Down
22 changes: 11 additions & 11 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
export * from './abortable';
export * from './AbortError';
export * from './delay';
export * from './execute';
export * from './forever';
export * from './waitForEvent';
export * from './all';
export * from './race';
export * from './retry';
export * from './spawn';
export * from './run';
export * from './abortable.js';
export * from './AbortError.js';
export * from './delay.js';
export * from './execute.js';
export * from './forever.js';
export * from './waitForEvent.js';
export * from './all.js';
export * from './race.js';
export * from './retry.js';
export * from './spawn.js';
export * from './run.js';
6 changes: 3 additions & 3 deletions src/race.test.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import defer = require('defer-promise');
import {AbortError} from './AbortError';
import {race} from './race';
import {nextTick} from './utils/nextTick';
import {AbortError} from './AbortError.js';
import {race} from './race.js';
import {nextTick} from './utils/nextTick.js';

test('external abort', async () => {
const abortController = new AbortController();
Expand Down
2 changes: 1 addition & 1 deletion src/race.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {AbortError, isAbortError} from './AbortError';
import {AbortError, isAbortError} from './AbortError.js';

/**
* Abortable version of `Promise.race`.
Expand Down
4 changes: 2 additions & 2 deletions src/retry.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {delay} from './delay';
import {rethrowAbortError} from './AbortError';
import {delay} from './delay.js';
import {rethrowAbortError} from './AbortError.js';

export type RetryOptions = {
/**
Expand Down
2 changes: 1 addition & 1 deletion src/run.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {catchAbortError} from './AbortError';
import {catchAbortError} from './AbortError.js';

/**
* Invokes an abortable function with implicitly created `AbortSignal`.
Expand Down
6 changes: 3 additions & 3 deletions src/spawn.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import {spawn} from './spawn';
import {forever} from './forever';
import {delay} from './delay';
import {spawn} from './spawn.js';
import {forever} from './forever.js';
import {delay} from './delay.js';

test('fork manual abort', async () => {
const abortController = new AbortController();
Expand Down
2 changes: 1 addition & 1 deletion src/spawn.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {AbortError, catchAbortError, isAbortError} from './AbortError';
import {AbortError, catchAbortError, isAbortError} from './AbortError.js';

export type SpawnEffects = {
/**
Expand Down
4 changes: 2 additions & 2 deletions src/waitForEvent.test.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {nextTick} from './utils/nextTick';
import {waitForEvent} from './waitForEvent';
import {nextTick} from './utils/nextTick.js';
import {waitForEvent} from './waitForEvent.js';

test('external abort', async () => {
const abortController = new AbortController();
Expand Down
2 changes: 1 addition & 1 deletion src/waitForEvent.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {execute} from './execute';
import {execute} from './execute.js';

export type EventTargetLike<T> =
| EventTargetLike.HasEventTargetAddRemove<T>
Expand Down
10 changes: 0 additions & 10 deletions tsconfig.es.json

This file was deleted.

7 changes: 3 additions & 4 deletions tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
"compilerOptions": {
"target": "es2020",
"lib": ["es2020", "dom"],
"module": "commonjs",
"moduleResolution": "node",
"module": "Node16",
"moduleResolution": "Node16",
"outDir": "lib",
"sourceMap": true,
"declaration": true,
"strict": true,
"noImplicitReturns": true,
"noUnusedLocals": true
},
"files": ["src/index.ts"],
"include": ["src/**/*.test.ts"]
"include": ["src"]
}

0 comments on commit d7d74d2

Please sign in to comment.