mirror of
https://github.com/hanzoai/next.js.git
synced 2026-09-24 17:00:51 +00:00
Following up on https://github.com/vercel/next.js/pull/83240 When using ESM syntax in `next.config.ts` on a CJS project, Node.js first assumes it as CJS, then parses it into ESM again, giving a warning: ``` (node:27529) [MODULE_TYPELESS_PACKAGE_JSON] Warning: Module type of file://.../next.config.ts is not specified and it doesn't parse as CommonJS. Reparsing as ES module because module syntax was detected. This incurs a performance overhead. To eliminate this warning, add "type": "module" to .../package.json. ``` Therefore, give users the option to use `next.config.mts` which Node.js expects ESM syntax. The tests are a copy of `next-config-ts-native-ts` and only renamed the config to mts. --------- Co-authored-by: Sebastian "Sebbie" Silbermann <[email protected]>
19 lines
530 B
TypeScript
19 lines
530 B
TypeScript
import { nextTestSetup } from 'e2e-utils'
|
|
|
|
describe('next-config-ts-node-api-cjs', () => {
|
|
// TODO: Remove this once we bump minimum Node.js version to v22
|
|
if (!(process.features as any).typescript) {
|
|
it.skip('requires `process.features.typescript` to feature detect Node.js native TS', () => {})
|
|
return
|
|
}
|
|
|
|
const { next } = nextTestSetup({
|
|
files: __dirname,
|
|
})
|
|
|
|
it('should be able to use Node.js API (CJS)', async () => {
|
|
const $ = await next.render$('/')
|
|
expect($('p').text()).toBe('foo')
|
|
})
|
|
})
|