diff --git a/package.json b/package.json index b839fa3..7f12285 100644 --- a/package.json +++ b/package.json @@ -2,6 +2,7 @@ "name": "setup-xc-action", "version": "1.0.1", "description": "GitHub Action to setup Microchip XC compilers", + "type": "module", "main": "dist/index.js", "scripts": { "build": "ncc build src/main.ts -m --no-source-map-register --license licenses.txt", diff --git a/src/main.ts b/src/main.ts index 079cdb0..6d1b020 100644 --- a/src/main.ts +++ b/src/main.ts @@ -289,6 +289,7 @@ export async function run(): Promise { } // Only run if this file is being executed directly (not imported for testing) -if (require.main === module) { +const isMain = import.meta.url === new URL(process.argv[1], 'file:').href +if (isMain) { run() } diff --git a/tsconfig.eslint.json b/tsconfig.eslint.json index 616cdbf..ff74c87 100644 --- a/tsconfig.eslint.json +++ b/tsconfig.eslint.json @@ -3,7 +3,8 @@ "include": ["src/**/*", "__tests__/**/*"], "exclude": ["node_modules"], "compilerOptions": { - "types": ["node", "vitest/globals"] + "types": ["node", "vitest/globals"], + "rootDir": "." } } diff --git a/tsconfig.json b/tsconfig.json index ac56c14..c8aad91 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -1,8 +1,9 @@ { "compilerOptions": { - "target": "ES2021", - "module": "commonjs", - "lib": ["ES2021"], + "target": "ES2022", + "module": "nodenext", + "moduleResolution": "nodenext", + "lib": ["ES2022"], "outDir": "./lib", "rootDir": "./src", "strict": true, @@ -13,7 +14,8 @@ "resolveJsonModule": true, "declaration": true, "declarationMap": true, - "sourceMap": true + "sourceMap": true, + "verbatimModuleSyntax": false }, "include": ["src/**/*"], "exclude": ["node_modules", "__tests__"]