mirror of
https://github.com/hanzoai/next.js.git
synced 2026-10-30 14:46:38 +00:00
The SWC options for ES modules of third-party dependencies that include `next/dist/client` in their filename, e.g. `<snip>/adapter-next/dist/client/index.js`, incorrectly defined `commonjs` as module type because the regular expression that checks for internal Next.js CJS files did not include a leading slash. We're now using `require.resolve` to fully match the Next.js filenames, instead of relying on a partial regex match. fixes #73413
24 lines
857 B
TypeScript
24 lines
857 B
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
|
|
describe('next-dist-client-esm-import', () => {
|
|
const dependencies = require('./package.json').dependencies
|
|
|
|
if ((global as any).isNextDeploy) {
|
|
// The `link:` protocol is incompatible with the npm version that's used
|
|
// when this test is deployed, so we use `file:` instead.
|
|
dependencies['@monorepo/adapter-next'] = 'file:./adapter-next'
|
|
}
|
|
|
|
const { next } = nextTestSetup({
|
|
files: __dirname,
|
|
dependencies,
|
|
})
|
|
|
|
it('should resolve ESM modules that have "next/dist/client" in their filename', async () => {
|
|
// The filename for the client component module that's imported in this
|
|
// fixture is: <node_modules>/@monorepo/adapter-next/dist/client/index.js
|
|
const browser = await next.browser('/')
|
|
expect(await browser.elementByCss('p').text()).toBe('hello world')
|
|
})
|
|
})
|