UNPKG

@aziontech/opennextjs-azion

Version:
21 lines (20 loc) 973 B
/** * This code was originally copied and modified from the @opennextjs/cloudflare repository. * Significant changes have been made to adapt it for use with Azion. */ import { join } from "node:path"; import { getCrossPlatformPathRegex } from "@opennextjs/aws/utils/regex.js"; export function shimRequireHook(options) { return { name: "replaceRelative", setup(build) { // Note: we (empty) shim require-hook modules as they generate problematic code that uses requires build.onResolve({ filter: getCrossPlatformPathRegex(String.raw `^\./require-hook$`, { escape: false }) }, () => ({ path: join(options.outputDir, "azion-runtime/shims/empty.js"), })); build.onResolve({ filter: getCrossPlatformPathRegex(String.raw `^\./node-environment$`, { escape: false }) }, () => ({ path: join(options.outputDir, "azion-runtime/shims/empty.js"), })); }, }; }