diff --git a/src/build-config-compiletime.ts b/src/build-config-compiletime.ts index 15915cbdbb..e4ccfb9432 100644 --- a/src/build-config-compiletime.ts +++ b/src/build-config-compiletime.ts @@ -28,12 +28,16 @@ const sanitizeBasename = (path: string | undefined = ''): string => { return `/${trim(path, '/')}`; }; +const env = { + NODE_ENV: NODE_ENV || 'development', + BACKEND_URL: sanitizeURL(BACKEND_URL), + FE_SUBDIRECTORY: sanitizeBasename(FE_SUBDIRECTORY), + FE_INSTANCE_SOURCE_DIR: FE_INSTANCE_SOURCE_DIR || 'instance', + SENTRY_DSN, +}; + +export type SoapboxEnv = typeof env; + export default () => ({ - data: { - NODE_ENV: NODE_ENV || 'development', - BACKEND_URL: sanitizeURL(BACKEND_URL), - FE_SUBDIRECTORY: sanitizeBasename(FE_SUBDIRECTORY), - FE_INSTANCE_SOURCE_DIR: FE_INSTANCE_SOURCE_DIR || 'instance', - SENTRY_DSN, - }, + data: env, }); diff --git a/src/build-config.ts b/src/build-config.ts index 38515cdd30..c742a12127 100644 --- a/src/build-config.ts +++ b/src/build-config.ts @@ -1,16 +1,9 @@ -// @ts-nocheck -const { - NODE_ENV, - BACKEND_URL, - FE_SUBDIRECTORY, - FE_INSTANCE_SOURCE_DIR, - SENTRY_DSN, -} = import.meta.compileTime('./build-config-compiletime.ts'); +import type { SoapboxEnv } from './build-config-compiletime'; -export { +export const { NODE_ENV, BACKEND_URL, FE_SUBDIRECTORY, FE_INSTANCE_SOURCE_DIR, SENTRY_DSN, -}; \ No newline at end of file +} = import.meta.compileTime('./build-config-compiletime.ts'); diff --git a/src/service-worker/sw.ts b/src/service-worker/sw.ts index 6fa5afecc5..b6bf3473c5 100644 --- a/src/service-worker/sw.ts +++ b/src/service-worker/sw.ts @@ -9,7 +9,7 @@ import type { Status as StatusEntity, } from 'soapbox/types/entities'; -const locales = import.meta.compileTime('./web-push-locales.ts'); +const locales = import.meta.compileTime>>('./web-push-locales.ts'); /** Limit before we start grouping device notifications into a single notification. */ const MAX_NOTIFICATIONS = 5; diff --git a/src/utils/code-compiletime.ts b/src/utils/code-compiletime.ts index b43c1d86ea..d9606c3a1a 100644 --- a/src/utils/code-compiletime.ts +++ b/src/utils/code-compiletime.ts @@ -35,14 +35,18 @@ const version = (pkg: Record) => { return pkg.version; }; +const code = { + name: pkg.name, + displayName: pkg.displayName, + url: pkg.repository.url, + repository: shortRepoName(pkg.repository.url), + version: version(pkg), + homepage: pkg.homepage, + ref: CI_COMMIT_TAG || CI_COMMIT_SHA || tryGit('git rev-parse HEAD'), +}; + +export type Code = typeof code; + export default () => ({ - data: { - name: pkg.name, - displayName: pkg.displayName, - url: pkg.repository.url, - repository: shortRepoName(pkg.repository.url), - version: version(pkg), - homepage: pkg.homepage, - ref: CI_COMMIT_TAG || CI_COMMIT_SHA || tryGit('git rev-parse HEAD'), - }, + data: code, }); diff --git a/src/utils/code.ts b/src/utils/code.ts index 25e4175351..e42fb6dde1 100644 --- a/src/utils/code.ts +++ b/src/utils/code.ts @@ -1,3 +1,3 @@ -const data: any = import.meta.compileTime('./code-compiletime.ts'); +import type { Code } from './code-compiletime'; -export default data; \ No newline at end of file +export default import.meta.compileTime('./code-compiletime.ts'); \ No newline at end of file