eagerpatch/navita

[Next.js] Edge Runtime not behaving correctly

Zn4rK opened this issue · 0 comments

Zn4rK commented

Using Navita imports directly inside routes that has

export const runtime = 'edge';

Causes the compiler to hang.

I can't remember the details of the Next.js implementation completely, but it might be caused by this line:
https://github.com/vercel/next.js/blob/f3132354285fb18c290bf9aad7f8dc7e0550105d/packages/next/src/build/webpack/plugins/flight-client-entry-plugin.ts#L614

Needs investigation and replication.

Lines in Navita that we need to look into:

const findPagesDirResult = findPagesDir(dir, !!resolvedNextConfig.experimental.appDir);
const hasAppDir = !!(findPagesDirResult && findPagesDirResult.appDir);
const isServer = options.isServer && !(options.nextRuntime === 'edge')
const outputCss = !isServer || hasAppDir;
if (!hasAppDir && !isServer) {
const filename = dev
? 'static/css/[name].css'
: 'static/css/[contenthash].css';
// https://github.com/vercel/next.js/blob/930db5c1afbe541a0b2357c26123c2b365b56624/packages/next/src/build/webpack/config/blocks/css/index.ts#L595
config.plugins.push(
new MiniCssExtractPlugin({
filename,
chunkFilename: filename,
ignoreOrder: true,
}),
);
}