From 0e9bfa3461bc72e1d08c85109bc61e63081dae1b Mon Sep 17 00:00:00 2001 From: Hidetake Iwata Date: Sun, 28 Apr 2024 11:48:46 +0900 Subject: [PATCH] Migrate to ESM (#366) --- eslint.config.mjs => eslint.config.js | 0 jest.config.js | 12 +++++++----- package.json | 1 + src/main.ts | 2 +- tests/run.test.ts | 2 +- tsconfig.json | 6 ++---- 6 files changed, 12 insertions(+), 11 deletions(-) rename eslint.config.mjs => eslint.config.js (100%) diff --git a/eslint.config.mjs b/eslint.config.js similarity index 100% rename from eslint.config.mjs rename to eslint.config.js diff --git a/jest.config.js b/jest.config.js index 7cf1c26..f6a60fb 100644 --- a/jest.config.js +++ b/jest.config.js @@ -1,7 +1,9 @@ -module.exports = { - preset: 'ts-jest', +/** @type {import('ts-jest').JestConfigWithTsJest} */ +export default { + preset: 'ts-jest/presets/default-esm', clearMocks: true, - testEnvironment: 'node', - testMatch: ['**/*.test.ts'], - verbose: true + // https://kulshekhar.github.io/ts-jest/docs/guides/esm-support/ + moduleNameMapper: { + '^(\\.{1,2}/.*)\\.js$': '$1', + }, } diff --git a/package.json b/package.json index 653dd88..71f8a44 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "build": "ncc build --source-map --license licenses.txt src/main.ts", "test": "jest" }, + "type": "module", "dependencies": { "@actions/core": "1.10.1", "@actions/exec": "1.1.1" diff --git a/src/main.ts b/src/main.ts index b45aa97..247adad 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,5 @@ import * as core from '@actions/core' -import { run } from './run' +import { run } from './run.js' const main = async (): Promise => { await run({ diff --git a/tests/run.test.ts b/tests/run.test.ts index 86e5471..ddbeb38 100644 --- a/tests/run.test.ts +++ b/tests/run.test.ts @@ -1,4 +1,4 @@ -import { retry } from '../src/run' +import { retry } from '../src/run.js' describe('retry', () => { test('suceeded', async () => { diff --git a/tsconfig.json b/tsconfig.json index 1adf1fe..92ebc1f 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,6 +1,4 @@ { - "extends": "@tsconfig/node20/tsconfig.json", - "compilerOptions": { - "outDir": "./lib" - } + "$schema": "https://json.schemastore.org/tsconfig", + "extends": "@tsconfig/node20/tsconfig.json" }