Skip to content

Commit 8bde161

Browse files
committed
🔧 Add .js extensions to Next.js module imports for ESM compliance
Extend the ESM compliance fix to include imports from next/script, next/headers, and next/server modules in provider and script components. This ensures proper module resolution when the package is consumed as a native ESM module, where Node.js requires explicit file extensions for all import specifiers including framework modules.
1 parent 56a60cf commit 8bde161

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/provider/public-env-provider.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { connection } from 'next/server'
1+
import { connection } from 'next/server.js'
22
import { type FC, type PropsWithChildren } from 'react'
33

44
import { getPublicEnv } from '../helpers/get-public-env.js'

src/script/env-script.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import Script, { type ScriptProps } from 'next/script'
1+
import Script, { type ScriptProps } from 'next/script.js'
22
import { type FC } from 'react'
33

44
import { escapeJsonForHtml } from '../helpers/escape-json-for-html.js'
@@ -146,7 +146,7 @@ export const EnvScript: FC<EnvScriptProps> = async ({
146146
if (typeof nonce === 'object' && nonce !== null) {
147147
try {
148148
// Dynamic import to avoid bundling server-only code in client contexts
149-
const { headers } = await import('next/headers')
149+
const { headers } = await import('next/headers.js')
150150
// Next.js 16+ requires async headers() call
151151
const headerStore = await headers()
152152

src/script/public-env-script.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
import { type ScriptProps } from 'next/script'
2-
import { connection } from 'next/server'
1+
import { type ScriptProps } from 'next/script.js'
2+
import { connection } from 'next/server.js'
33
import { type FC } from 'react'
44

55
import { getPublicEnv } from '../helpers/get-public-env.js'

0 commit comments

Comments
 (0)