Files
Josh StoryandGitHub 1b45163bce Exclude next-js condition from middleware, proxy, and instrumentation (#85321)
These scopes aren't fully Next.js environments and can't access many
Next.js APIs. In the future this might change but for now we will
exclude the `next-js` condition when bundling for these entrypoints so
that 3rd parties that target Next.js can do so with the expectation that
regardless of what environment they are running in the full suite of
Next.js libraries they support will work.
2025-10-27 11:58:32 -07:00

62 lines
1.8 KiB
TypeScript

'use client'
// For this to work locally you need to use `pnpm next-with-deps dev|build`
// Make sure you delete node_modules if you are editing the package otherwise it won't
// reinstall and reflect your changes.
import ExportsDefault from 'my-cjs-package/exports'
import * as ExportsNamed from 'my-cjs-package/exports'
import { named as namedExports } from 'my-cjs-package/exports'
import ImportsDefault from 'my-cjs-package/imports'
import * as ImportsNamed from 'my-cjs-package/imports'
import { named as namedImports } from 'my-cjs-package/imports'
const pendingDynamicExports = import('my-cjs-package/exports').then((mod) =>
JSON.stringify(mod)
)
const pendingDynamicImports = import('my-cjs-package/imports').then((mod) =>
JSON.stringify(mod)
)
export default function Client() {
return (
<section>
<h2>Client</h2>
<section>
<h3>Exports</h3>
<section>
<h4>Static</h4>
<label>Default:</label>
<div>{JSON.stringify(ExportsDefault)}</div>
<label>Namespace:</label>
<div>{JSON.stringify(ExportsNamed)}</div>
<label>named:</label>
<div>{JSON.stringify(namedExports)}</div>
</section>
<section>
<h4>Dynamic</h4>
<div>{pendingDynamicExports}</div>
</section>
</section>
<section>
<h3>Imports</h3>
<section>
<h4>Static</h4>
<label>Default:</label>
<div>{JSON.stringify(ImportsDefault)}</div>
<label>Namespace:</label>
<div>{JSON.stringify(ImportsNamed)}</div>
<label>named:</label>
<div>{JSON.stringify(namedImports)}</div>
</section>
<section>
<h4>Dynamic</h4>
<div>{pendingDynamicImports}</div>
</section>
</section>
</section>
)
}