This commit is contained in:
Kismet Hasanaj
2026-05-02 20:07:02 +02:00
parent ce8672e283
commit 34dc9aec52
9428 changed files with 1733330 additions and 0 deletions
+33
View File
@@ -0,0 +1,33 @@
import { COMPILER_NAMES } from '../../shared/lib/constants';
export const edgeConditionName = 'edge-light';
const mainFieldsPerCompiler = {
// For default case, prefer CJS over ESM on server side. e.g. pages dir SSR
[COMPILER_NAMES.server]: [
'main',
'module'
],
[COMPILER_NAMES.client]: [
'browser',
'module',
'main'
],
// For bundling-all strategy, prefer ESM over CJS
'server-esm': [
'module',
'main'
]
};
export function getMainField(compilerType, preferEsm) {
if (compilerType === COMPILER_NAMES.edgeServer) {
return [
'edge-light',
'...'
];
} else if (compilerType === COMPILER_NAMES.client) {
return mainFieldsPerCompiler[COMPILER_NAMES.client];
}
// Prefer module fields over main fields for isomorphic packages on server layer
return preferEsm ? mainFieldsPerCompiler['server-esm'] : mainFieldsPerCompiler[COMPILER_NAMES.server];
}
//# sourceMappingURL=resolve.js.map