diff --git a/.eslintrc.json b/.eslintrc.json index 0e83d94c..69cdba40 100644 --- a/.eslintrc.json +++ b/.eslintrc.json @@ -11,6 +11,7 @@ ], "rules": { "@typescript-eslint/prefer-ts-expect-error": 0, - "@typescript-eslint/ban-ts-comment": 0 + "@typescript-eslint/ban-ts-comment": 0, + "import/no-unresolved": "off" } } diff --git a/package.json b/package.json index d3555d6b..815cdb49 100644 --- a/package.json +++ b/package.json @@ -1,9 +1,8 @@ { "name": "@electron/get", "version": "0.0.0-development", + "type": "module", "description": "Utility for downloading artifacts from different versions of Electron", - "main": "dist/cjs/index.js", - "module": "dist/esm/index.js", "repository": "https://github.com/electron/get", "author": "Samuel Attard", "license": "MIT", @@ -11,7 +10,7 @@ "provenance": true }, "scripts": { - "build": "tsc && tsc -p tsconfig.esm.json", + "build": "tsc", "build:docs": "npx typedoc", "eslint": "eslint --ext .ts src test", "lint": "npm run prettier && npm run eslint", @@ -46,6 +45,7 @@ "@typescript-eslint/eslint-plugin": "^8.19.1", "@typescript-eslint/parser": "^8.0.0", "@vitest/coverage-v8": "3.0.3", + "esbuild-plugin-file-path-extensions": "^2.1.4", "eslint": "^8.57.0", "eslint-config-prettier": "^6.15.0", "eslint-plugin-import": "^2.31.0", diff --git a/src/GotDownloader.ts b/src/GotDownloader.ts index e980a67c..46bfa9c6 100644 --- a/src/GotDownloader.ts +++ b/src/GotDownloader.ts @@ -7,7 +7,7 @@ import fs from 'node:fs'; import path from 'node:path'; import ProgressBar from 'progress'; -import { Downloader } from './Downloader'; +import { Downloader } from './Downloader.js'; const PROGRESS_BAR_DELAY_IN_SECONDS = 30; diff --git a/src/artifact-utils.ts b/src/artifact-utils.ts index ac00198b..94fa3285 100644 --- a/src/artifact-utils.ts +++ b/src/artifact-utils.ts @@ -1,5 +1,5 @@ -import { ElectronArtifactDetails, MirrorOptions } from './types'; -import { ensureIsTruthyString, normalizeVersion } from './utils'; +import { ElectronArtifactDetails, MirrorOptions } from './types.js'; +import { ensureIsTruthyString, normalizeVersion } from './utils.js'; const BASE_URL = 'https://github.com/electron/electron/releases/download/'; const NIGHTLY_BASE_URL = 'https://github.com/electron/nightlies/releases/download/'; diff --git a/src/downloader-resolver.ts b/src/downloader-resolver.ts index c8e1bf83..c448da60 100644 --- a/src/downloader-resolver.ts +++ b/src/downloader-resolver.ts @@ -1,11 +1,11 @@ -import { DownloadOptions } from './types'; -import { Downloader } from './Downloader'; +import { DownloadOptions } from './types.js'; +import { Downloader } from './Downloader.js'; // TODO: Resolve the downloader or default to GotDownloader // Current thoughts are a dot-file traversal for something like // ".electron.downloader" which would be a text file with the name of the // npm module to import() and use as the downloader -import { GotDownloader } from './GotDownloader'; +import { GotDownloader } from './GotDownloader.js'; export async function getDownloaderForSystem(): Promise> { return new GotDownloader(); diff --git a/src/index.ts b/src/index.ts index bccdcbab..3f5128a9 100644 --- a/src/index.ts +++ b/src/index.ts @@ -4,7 +4,7 @@ import path from 'node:path'; import semver from 'semver'; import sumchecker from 'sumchecker'; -import { getArtifactFileName, getArtifactRemoteURL, getArtifactVersion } from './artifact-utils'; +import { getArtifactFileName, getArtifactRemoteURL, getArtifactVersion } from './artifact-utils.js'; import { ElectronArtifactDetails, ElectronDownloadCacheMode, @@ -12,10 +12,10 @@ import { ElectronGenericArtifactDetails, ElectronPlatformArtifactDetails, ElectronPlatformArtifactDetailsWithDefaults, -} from './types'; -import { Cache } from './Cache'; -import { getDownloaderForSystem } from './downloader-resolver'; -import { initializeProxy } from './proxy'; +} from './types.js'; +import { Cache } from './Cache.js'; +import { getDownloaderForSystem } from './downloader-resolver.js'; +import { initializeProxy } from './proxy.js'; import { withTempDirectoryIn, getHostArch, @@ -27,11 +27,11 @@ import { effectiveCacheMode, shouldTryReadCache, TempDirCleanUpMode, -} from './utils'; +} from './utils.js'; -export { getHostArch } from './utils'; -export { initializeProxy } from './proxy'; -export * from './types'; +export { getHostArch } from './utils.js'; +export { initializeProxy } from './proxy.js'; +export * from './types.js'; const d = debug('@electron/get:index'); diff --git a/src/proxy.ts b/src/proxy.ts index dadc388a..7f5bfc67 100644 --- a/src/proxy.ts +++ b/src/proxy.ts @@ -1,5 +1,5 @@ import debug from 'debug'; -import { getEnv, setEnv } from './utils'; +import { getEnv, setEnv } from './utils.js'; const d = debug('@electron/get:proxy'); diff --git a/src/types.ts b/src/types.ts index 26762f7b..4e041c5c 100644 --- a/src/types.ts +++ b/src/types.ts @@ -1,5 +1,5 @@ -import { Downloader } from './Downloader'; -import { GotDownloader, GotDownloaderOptions } from './GotDownloader'; +import { Downloader } from './Downloader.js'; +import { GotDownloader, GotDownloaderOptions } from './GotDownloader.js'; export { Downloader, GotDownloader, GotDownloaderOptions }; diff --git a/src/utils.ts b/src/utils.ts index 4fdcf18b..1fa92dd1 100644 --- a/src/utils.ts +++ b/src/utils.ts @@ -7,7 +7,7 @@ import { ElectronDownloadCacheMode, ElectronGenericArtifactDetails, ElectronPlatformArtifactDetailsWithDefaults, -} from './types'; +} from './types.js'; async function useAndRemoveDirectory( directory: string, diff --git a/tsconfig.esm.json b/tsconfig.esm.json deleted file mode 100644 index f084f096..00000000 --- a/tsconfig.esm.json +++ /dev/null @@ -1,8 +0,0 @@ -{ - "extends": "./tsconfig.json", - "compilerOptions": { - "module": "ESNext", - "moduleResolution": "node", - "outDir": "dist/esm" - } -} diff --git a/tsconfig.json b/tsconfig.json index ea97e05e..2349c4eb 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -2,10 +2,8 @@ "extends": "@tsconfig/node22/tsconfig.json", "compilerOptions": { "sourceMap": true, - "outDir": "dist/cjs", + "outDir": "dist", "types": ["node"], - "allowSyntheticDefaultImports": true, - "declaration": true }, "include": ["src"] } diff --git a/yarn.lock b/yarn.lock index ac728cec..7ee636e7 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1185,6 +1185,11 @@ es6-error@^4.1.1: resolved "https://registry.yarnpkg.com/es6-error/-/es6-error-4.1.1.tgz#9e3af407459deed47e9a91f9b885a84eb05c561d" integrity sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg== +esbuild-plugin-file-path-extensions@^2.1.4: + version "2.1.4" + resolved "https://registry.yarnpkg.com/esbuild-plugin-file-path-extensions/-/esbuild-plugin-file-path-extensions-2.1.4.tgz#cad9d1d3133e95146eeabd76fdf3956a66f6348b" + integrity sha512-lNjylaAsJMprYg28zjUyBivP3y0ms9b7RJZ5tdhDUFLa3sCbqZw4wDnbFUSmnyZYWhCYDPxxp7KkXM2TXGw3PQ== + esbuild@^0.24.2: version "0.24.2" resolved "https://registry.yarnpkg.com/esbuild/-/esbuild-0.24.2.tgz#b5b55bee7de017bff5fb8a4e3e44f2ebe2c3567d"