From 616e881987e63fba14abc1a71a9cb6231a5a8d26 Mon Sep 17 00:00:00 2001 From: Naoki Oketani Date: Mon, 5 May 2025 11:52:10 +0000 Subject: [PATCH] refactor(build): update TypeScript and Rollup configuration --- rollup.config.ts | 23 +++++++++++------------ src/index.ts | 8 ++++++++ tsconfig.base.json | 22 ++++++++++++++++++++++ tsconfig.json | 23 +++++++---------------- 4 files changed, 48 insertions(+), 28 deletions(-) create mode 100644 src/index.ts create mode 100644 tsconfig.base.json diff --git a/rollup.config.ts b/rollup.config.ts index 1a499f4..b614b18 100644 --- a/rollup.config.ts +++ b/rollup.config.ts @@ -1,19 +1,18 @@ -import commonjs from '@rollup/plugin-commonjs'; -import resolve from '@rollup/plugin-node-resolve'; -import typescript from '@rollup/plugin-typescript'; +// See: https://rollupjs.org/introduction/ + +import commonjs from '@rollup/plugin-commonjs' +import nodeResolve from '@rollup/plugin-node-resolve' +import typescript from '@rollup/plugin-typescript' const config = { - input: 'src/main.ts', + input: 'src/index.ts', output: { + esModule: true, file: 'dist/index.js', - format: 'cjs', + format: 'es', sourcemap: true }, - plugins: [ - resolve(), - commonjs(), - typescript() - ] -}; + plugins: [typescript(), nodeResolve({ preferBuiltins: true }), commonjs()] +} -export default config; \ No newline at end of file +export default config diff --git a/src/index.ts b/src/index.ts new file mode 100644 index 0000000..267fe68 --- /dev/null +++ b/src/index.ts @@ -0,0 +1,8 @@ +/** + * The entrypoint for the action. This file simply imports and runs the action's + * main logic. + */ +import { run } from './main.js' + +/* istanbul ignore next */ +run() diff --git a/tsconfig.base.json b/tsconfig.base.json new file mode 100644 index 0000000..fce35a4 --- /dev/null +++ b/tsconfig.base.json @@ -0,0 +1,22 @@ +{ + "$schema": "https://json.schemastore.org/tsconfig", + "compilerOptions": { + "allowSyntheticDefaultImports": true, + "declaration": false, + "declarationMap": false, + "esModuleInterop": true, + "forceConsistentCasingInFileNames": true, + "lib": ["ES2022"], + "module": "NodeNext", + "moduleResolution": "NodeNext", + "newLine": "lf", + "noImplicitAny": true, + "noUnusedLocals": true, + "noUnusedParameters": false, + "pretty": true, + "resolveJsonModule": true, + "strict": true, + "strictNullChecks": true, + "target": "ES2022" + } +} diff --git a/tsconfig.json b/tsconfig.json index 9542239..b65a760 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,20 +1,11 @@ { + "$schema": "https://json.schemastore.org/tsconfig", + "extends": "./tsconfig.base.json", "compilerOptions": { - "target": "es2020", /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017', 'ES2018', 'ES2019', 'ES2020' or 'ESNEXT'. */ - "module": "NodeNext", /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */ - "outDir": "./lib", /* Redirect output structure to the directory. */ - "rootDir": "./src", /* Specify the root directory of input files. Use to control the output directory structure with --outDir. */ - "strict": true, /* Enable all strict type-checking options. */ - "noImplicitAny": true, /* Raise error on expressions and declarations with an implied 'any' type. */ - "esModuleInterop": true, /* Enables emit interoperability between CommonJS and ES Modules via creation of namespace objects for all imports. Implies 'allowSyntheticDefaultImports'. */ - "baseUrl": "./", - "paths": { - "*": ["src/*"] - } + "module": "NodeNext", + "moduleResolution": "NodeNext", + "outDir": "./dist" }, - "exclude": [ - "node_modules", - "**/*.test.ts", - "vitest.config.ts" - ] + "exclude": ["__fixtures__", "__tests__", "coverage", "dist", "node_modules"], + "include": ["src"] }