Skip to content

Commit e947084

Browse files
committed
🔧 Add .js extensions to relative imports for ESM compliance
Update all internal import specifiers to include explicit .js file extensions. This ensures proper module resolution when the package is consumed as a native ESM module, where Node.js requires explicit extensions for relative imports.
1 parent d4d3b30 commit e947084

File tree

12 files changed

+21
-21
lines changed

12 files changed

+21
-21
lines changed

src/helpers/get-public-env.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { ProcessEnv } from '../typings/process-env'
1+
import { ProcessEnv } from '../typings/process-env.js'
22

33
/**
44
* Gets environment variables that start with `NEXT_PUBLIC_` prefix.

src/helpers/is-browser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { PUBLIC_ENV_KEY } from '../script/constants'
1+
import { PUBLIC_ENV_KEY } from '../script/constants.js'
22

33
/**
44
* Checks if the code is running in the browser.

src/helpers/log.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { bold, green, red, white, yellow } from '../lib/picocolors'
1+
import { bold, green, red, white, yellow } from '../lib/picocolors.js'
22

33
export type Level = 'error' | 'warn' | 'info'
44
export type LevelWithSilent = 'silent' | Level

src/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ declare global {
77
}
88
}
99

10-
export * from './provider'
11-
export * from './script'
12-
export { makeEnvPublic } from './utils/make-env-public'
10+
export * from './provider/index.js'
11+
export * from './script/index.js'
12+
export { makeEnvPublic } from './utils/make-env-public.js'

src/provider/env-context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { createContext } from 'react'
22

3-
import { type ProcessEnv } from '../typings/process-env'
3+
import { type ProcessEnv } from '../typings/process-env.js'
44

55
export const EnvContext = createContext<ProcessEnv | null>(null)

src/provider/index.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/* istanbul ignore file */
22

3-
export { EnvProvider } from './env-provider'
4-
export { PublicEnvProvider } from './public-env-provider'
5-
export { useEnvContext } from './use-env-context'
3+
export { EnvProvider } from './env-provider.js'
4+
export { PublicEnvProvider } from './public-env-provider.js'
5+
export { useEnvContext } from './use-env-context.js'

src/provider/use-env-context.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
import { useContext } from 'react'
44

5-
import { EnvContext } from './env-context'
5+
import { EnvContext } from './env-context.js'
66

77
/**
88
* React hook for accessing environment variables from the nearest EnvProvider.

src/script/env.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { isBrowser as isBrowserWithEnv } from '../helpers/is-browser'
2-
import { PUBLIC_ENV_KEY } from './constants'
1+
import { isBrowser as isBrowserWithEnv } from '../helpers/is-browser.js'
2+
import { PUBLIC_ENV_KEY } from './constants.js'
33

44
const IS_BROWSER = typeof window !== 'undefined'
55

src/script/index.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/* istanbul ignore file */
22

3-
export { PUBLIC_ENV_KEY } from './constants'
4-
export { env, requireEnv, serverOnly } from './env'
5-
export { EnvScript } from './env-script'
6-
export { envParsers } from './parsers'
7-
export { PublicEnvScript } from './public-env-script'
3+
export { PUBLIC_ENV_KEY } from './constants.js'
4+
export { env, requireEnv, serverOnly } from './env.js'
5+
export { EnvScript } from './env-script.js'
6+
export { envParsers } from './parsers.js'
7+
export { PublicEnvScript } from './public-env-script.js'

src/script/parsers.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { env } from './env'
1+
import { env } from './env.js'
22

33
/**
44
* Type-safe environment variable parsers for common data types.

0 commit comments

Comments
 (0)