{"version":3,"sources":["../../../../src/build/swc/index.ts"],"sourcesContent":["import path from 'path'\nimport { pathToFileURL } from 'url'\nimport { arch, platform } from 'os'\nimport { platformArchTriples } from 'next/dist/compiled/@napi-rs/triples'\nimport * as Log from '../output/log'\nimport type {\n  NextConfigComplete,\n  TurbopackLoaderBuiltinCondition,\n  TurbopackLoaderItem,\n  TurbopackRuleCondition,\n  TurbopackRuleConfigCollection,\n  TurbopackRuleConfigItem,\n} from '../../server/config-shared'\nimport { type DefineEnvOptions, getDefineEnv } from '../define-env'\nimport type {\n  NapiPartialProjectOptions,\n  NapiProjectOptions,\n  NapiSourceDiagnostic,\n  NapiCodeFrameLocation,\n  NapiCodeFrameOptions,\n} from './generated-native'\nimport type {\n  Binding,\n  CompilationEvent,\n  DefineEnv,\n  Endpoint,\n  HmrChunkNames,\n  Lockfile,\n  NodeJsHmrUpdate,\n  PartialProjectOptions,\n  Project,\n  ProjectOptions,\n  RawEntrypoints,\n  Route,\n  TurboEngineOptions,\n  TurbopackResult,\n  TurbopackStackFrame,\n  Update,\n  UpdateMessage,\n  WrittenEndpoint,\n} from './types'\nimport { runLoaderWorkerPool } from './loaderWorkerPool'\n\nexport enum HmrTarget {\n  Client = 'client',\n  Server = 'server',\n}\n\ntype RawBindings = typeof import('./generated-native')\ntype RawWasmBindings = typeof import('./generated-wasm') & {\n  default?(): Promise<typeof import('./generated-wasm')>\n}\n\nconst nextVersion = process.env.__NEXT_VERSION as string\n\nconst ArchName = arch()\nconst PlatformName = platform()\n\nfunction infoLog(...args: any[]) {\n  if (process.env.NEXT_PRIVATE_BUILD_WORKER) {\n    return\n  }\n  if (process.env.DEBUG) {\n    Log.info(...args)\n  }\n}\n\n/**\n * Based on napi-rs's target triples, returns triples that have corresponding next-swc binaries.\n */\nexport function getSupportedArchTriples(): Record<string, any> {\n  const { darwin, win32, linux, freebsd, android } = platformArchTriples\n\n  return {\n    darwin,\n    win32: {\n      arm64: win32.arm64,\n      ia32: win32.ia32.filter((triple) => triple.abi === 'msvc'),\n      x64: win32.x64.filter((triple) => triple.abi === 'msvc'),\n    },\n    linux: {\n      // linux[x64] includes `gnux32` abi, with x64 arch.\n      x64: linux.x64.filter((triple) => triple.abi !== 'gnux32'),\n      arm64: linux.arm64,\n      // This target is being deprecated, however we keep it in `knownDefaultWasmFallbackTriples` for now\n      arm: linux.arm,\n    },\n    // Below targets are being deprecated, however we keep it in `knownDefaultWasmFallbackTriples` for now\n    freebsd: {\n      x64: freebsd.x64,\n    },\n    android: {\n      arm64: android.arm64,\n      arm: android.arm,\n    },\n  }\n}\n\nconst triples = (() => {\n  const supportedArchTriples = getSupportedArchTriples()\n  const targetTriple = supportedArchTriples[PlatformName]?.[ArchName]\n\n  // If we have supported triple, return it right away\n  if (targetTriple) {\n    return targetTriple\n  }\n\n  // If there isn't corresponding target triple in `supportedArchTriples`, check if it's excluded from original raw triples\n  // Otherwise, it is completely unsupported platforms.\n  let rawTargetTriple = platformArchTriples[PlatformName]?.[ArchName]\n\n  if (rawTargetTriple) {\n    Log.warn(\n      `next-swc does not have native bindings support for target triple ${rawTargetTriple}. Native features like Turbopack will not be available.`\n    )\n  } else {\n    Log.warn(\n      `next-swc does not have native bindings for platform ${PlatformName}/${ArchName}. Native features like Turbopack will not be available.`\n    )\n  }\n\n  return []\n})()\n\n// Allow to specify an absolute path to the custom turbopack binary to load.\n// If one of env variables is set, `loadNative` will try to use specified\n// binary instead. This is thin, naive interface\n// - `loadBindings` will not validate neither path nor the binary.\n//\n// Note these are internal flag: there's no stability, feature guarantee.\nconst __INTERNAL_CUSTOM_TURBOPACK_BINDINGS =\n  process.env.__INTERNAL_CUSTOM_TURBOPACK_BINDINGS\n\nfunction checkVersionMismatch(pkgData: any) {\n  const version = pkgData.version\n\n  if (version && version !== nextVersion) {\n    Log.warn(\n      `Mismatching @next/swc version, detected: ${version} while Next.js is on ${nextVersion}. Please ensure these match`\n    )\n  }\n}\n\n// These are the platforms we'll try to load wasm bindings first,\n// only try to load native bindings if loading wasm binding somehow fails.\n// Fallback to native binding is for migration period only,\n// once we can verify loading-wasm-first won't cause visible regressions,\n// we'll not include native bindings for these platform at all.\nconst knownDefaultWasmFallbackTriples = [\n  'x86_64-unknown-freebsd',\n  'aarch64-linux-android',\n  'arm-linux-androideabi',\n  'armv7-unknown-linux-gnueabihf',\n  'i686-pc-windows-msvc',\n  // WOA targets are TBD, while current userbase is small we may support it in the future\n  //'aarch64-pc-windows-msvc',\n]\n\n// The last attempt's error code returned when cjs require to native bindings fails.\n// If node.js throws an error without error code, this should be `unknown` instead of undefined.\n// For the wasm-first targets (`knownDefaultWasmFallbackTriples`) this will be `unsupported_target`.\nlet lastNativeBindingsLoadErrorCode:\n  | 'unknown'\n  | 'unsupported_target'\n  | string\n  | undefined = undefined\n// Used to cache racing calls to `loadBindings`\nlet pendingBindings: Promise<Binding> | undefined\n// The cached loaded bindings\nlet loadedBindings: Binding | undefined = undefined\nlet downloadWasmPromise: any\nlet swcTraceFlushGuard: any\nlet downloadNativeBindingsPromise: Promise<void> | undefined = undefined\n\nexport const lockfilePatchPromise: { cur?: Promise<void> } = {}\n\n/** Access the native bindings which should already have been loaded via `installBindings.  Throws if they are not available. */\nexport function getBindingsSync(): Binding {\n  if (!loadedBindings) {\n    if (pendingBindings) {\n      throw new Error(\n        'Bindings not loaded yet, but they are being loaded, did you forget to await?'\n      )\n    }\n    throw new Error(\n      'bindings not loaded yet.  Either call `loadBindings` to wait for them to be available or ensure that `installBindings` has already been called.'\n    )\n  }\n  return loadedBindings\n}\n\n/**\n * Loads the native or wasm binding.\n *\n * By default, this first tries to use a native binding, falling back to a wasm binding if that\n * fails.\n *\n * This function is `async` as wasm requires an asynchronous import in browsers.\n */\nexport async function loadBindings(\n  useWasmBinary: boolean = false\n): Promise<Binding> {\n  if (loadedBindings) {\n    return loadedBindings\n  }\n  if (pendingBindings) {\n    return pendingBindings\n  }\n\n  // Increase Rust stack size as some npm packages being compiled need more than the default.\n  if (!process.env.RUST_MIN_STACK) {\n    process.env.RUST_MIN_STACK = '8388608'\n  }\n\n  if (process.env.NEXT_TEST_WASM) {\n    useWasmBinary = true\n  }\n\n  // rust needs stdout to be blocking, otherwise it will throw an error (on macOS at least) when writing a lot of data (logs) to it\n  // see https://github.com/napi-rs/napi-rs/issues/1630\n  // and https://github.com/nodejs/node/blob/main/doc/api/process.md#a-note-on-process-io\n  if (process.stdout._handle != null) {\n    // @ts-ignore\n    process.stdout._handle.setBlocking?.(true)\n  }\n  if (process.stderr._handle != null) {\n    // @ts-ignore\n    process.stderr._handle.setBlocking?.(true)\n  }\n\n  pendingBindings = new Promise(async (resolve, reject) => {\n    if (!lockfilePatchPromise.cur) {\n      // always run lockfile check once so that it gets patched\n      // even if it doesn't fail to load locally\n      lockfilePatchPromise.cur = (\n        require('../../lib/patch-incorrect-lockfile') as typeof import('../../lib/patch-incorrect-lockfile')\n      )\n        .patchIncorrectLockfile(process.cwd())\n        .catch(console.error)\n    }\n\n    let attempts: any[] = []\n    const disableWasmFallback = process.env.NEXT_DISABLE_SWC_WASM\n    const unsupportedPlatform = triples.some(\n      (triple: any) =>\n        !!triple?.raw && knownDefaultWasmFallbackTriples.includes(triple.raw)\n    )\n    const isWebContainer = process.versions.webcontainer\n    // Normal execution relies on the param `useWasmBinary` flag to load, but\n    // in certain cases where there isn't a native binary we always load wasm fallback first.\n    const shouldLoadWasmFallbackFirst =\n      (!disableWasmFallback && useWasmBinary) ||\n      unsupportedPlatform ||\n      isWebContainer\n\n    if (!unsupportedPlatform && useWasmBinary) {\n      Log.warn(\n        `experimental.useWasmBinary is not an option for supported platform ${PlatformName}/${ArchName} and will be ignored.`\n      )\n    }\n\n    if (shouldLoadWasmFallbackFirst) {\n      lastNativeBindingsLoadErrorCode = 'unsupported_target'\n      const fallbackBindings = await tryLoadWasmWithFallback(attempts)\n      if (fallbackBindings) {\n        return resolve(fallbackBindings)\n      }\n    }\n\n    // Trickle down loading `fallback` bindings:\n    //\n    // - First, try to load native bindings installed in node_modules.\n    // - If that fails with `ERR_MODULE_NOT_FOUND`, treat it as case of https://github.com/npm/cli/issues/4828\n    // that host system where generated package lock is not matching to the guest system running on, try to manually\n    // download corresponding target triple and load it. This won't be triggered if native bindings are failed to load\n    // with other reasons than `ERR_MODULE_NOT_FOUND`.\n    // - Lastly, falls back to wasm binding where possible.\n    try {\n      return resolve(loadNative())\n    } catch (a) {\n      if (\n        Array.isArray(a) &&\n        a.every((m) => m.includes('it was not installed'))\n      ) {\n        let fallbackBindings = await tryLoadNativeWithFallback(attempts)\n\n        if (fallbackBindings) {\n          return resolve(fallbackBindings)\n        }\n      }\n\n      attempts = attempts.concat(a)\n    }\n\n    // For these platforms we already tried to load wasm and failed, skip reattempt\n    if (!shouldLoadWasmFallbackFirst && !disableWasmFallback) {\n      const fallbackBindings = await tryLoadWasmWithFallback(attempts)\n      if (fallbackBindings) {\n        return resolve(fallbackBindings)\n      }\n    }\n\n    await logLoadFailure(attempts, true)\n    // Reject the promise to propagate the error (process.exit was removed to allow telemetry flush)\n    reject(\n      new Error(\n        `Failed to load SWC binary for ${PlatformName}/${ArchName}, see more info here: https://nextjs.org/docs/messages/failed-loading-swc`\n      )\n    )\n  })\n  loadedBindings = await pendingBindings\n  pendingBindings = undefined\n  return loadedBindings\n}\n\nasync function tryLoadNativeWithFallback(attempts: Array<string>) {\n  const nativeBindingsDirectory = path.join(\n    path.dirname(require.resolve('next/package.json')),\n    'next-swc-fallback'\n  )\n\n  if (!downloadNativeBindingsPromise) {\n    downloadNativeBindingsPromise = (\n      require('../../lib/download-swc') as typeof import('../../lib/download-swc')\n    ).downloadNativeNextSwc(\n      nextVersion,\n      nativeBindingsDirectory,\n      triples.map((triple: any) => triple.platformArchABI)\n    )\n  }\n  await downloadNativeBindingsPromise\n\n  try {\n    return loadNative(nativeBindingsDirectory)\n  } catch (a: any) {\n    attempts.push(...[].concat(a))\n  }\n\n  return undefined\n}\n\n// helper for loadBindings\nasync function tryLoadWasmWithFallback(\n  attempts: any[]\n): Promise<Binding | undefined> {\n  try {\n    let bindings = await loadWasm('')\n    ;(\n      require('../../telemetry/events/swc-load-failure') as typeof import('../../telemetry/events/swc-load-failure')\n    ).eventSwcLoadFailure({\n      wasm: 'enabled',\n      nativeBindingsErrorCode: lastNativeBindingsLoadErrorCode,\n    })\n    return bindings\n  } catch (a: any) {\n    attempts.push(...[].concat(a))\n  }\n\n  try {\n    // if not installed already download wasm package on-demand\n    // we download to a custom directory instead of to node_modules\n    // as node_module import attempts are cached and can't be re-attempted\n    // x-ref: https://github.com/nodejs/modules/issues/307\n    const wasmDirectory = path.join(\n      path.dirname(require.resolve('next/package.json')),\n      'wasm'\n    )\n    if (!downloadWasmPromise) {\n      downloadWasmPromise = (\n        require('../../lib/download-swc') as typeof import('../../lib/download-swc')\n      ).downloadWasmSwc(nextVersion, wasmDirectory)\n    }\n    await downloadWasmPromise\n    let bindings = await loadWasm(wasmDirectory)\n    ;(\n      require('../../telemetry/events/swc-load-failure') as typeof import('../../telemetry/events/swc-load-failure')\n    ).eventSwcLoadFailure({\n      wasm: 'fallback',\n      nativeBindingsErrorCode: lastNativeBindingsLoadErrorCode,\n    })\n\n    // still log native load attempts so user is\n    // aware it failed and should be fixed\n    for (const attempt of attempts) {\n      Log.warn(attempt)\n    }\n    return bindings\n  } catch (a: any) {\n    attempts.push(...[].concat(a))\n  }\n}\n\nfunction loadBindingsSync(): Binding {\n  let attempts: any[] = []\n  try {\n    return loadNative()\n  } catch (a) {\n    attempts = attempts.concat(a)\n  }\n\n  // Fire-and-forget telemetry logging (loadBindingsSync must remain synchronous)\n  // Worker error handler will await telemetry.flush() before exit\n  logLoadFailure(attempts)\n\n  throw new Error('Failed to load bindings', { cause: attempts })\n}\n\nlet loggingLoadFailure = false\n\n/**\n * Logs SWC load failure telemetry and error messages.\n *\n * Note: Does NOT call process.exit() - errors must propagate to caller's error handler\n * which will await telemetry.flush() before exit (critical for worker threads with async telemetry).\n */\nasync function logLoadFailure(attempts: any, triedWasm = false) {\n  // make sure we only emit the event and log the failure once\n  if (loggingLoadFailure) return\n  loggingLoadFailure = true\n\n  for (let attempt of attempts) {\n    Log.warn(attempt)\n  }\n\n  await (\n    require('../../telemetry/events/swc-load-failure') as typeof import('../../telemetry/events/swc-load-failure')\n  ).eventSwcLoadFailure({\n    wasm: triedWasm ? 'failed' : undefined,\n    nativeBindingsErrorCode: lastNativeBindingsLoadErrorCode,\n  })\n  await (lockfilePatchPromise.cur || Promise.resolve())\n\n  Log.error(\n    `Failed to load SWC binary for ${PlatformName}/${ArchName}, see more info here: https://nextjs.org/docs/messages/failed-loading-swc`\n  )\n}\n\ntype RustifiedEnv = { name: string; value: string }[]\ntype RustifiedOptionEnv = { name: string; value: string | undefined }[]\n\nexport function createDefineEnv({\n  isTurbopack,\n  clientRouterFilters,\n  config,\n  dev,\n  distDir,\n  projectPath,\n  fetchCacheKeyPrefix,\n  hasRewrites,\n  middlewareMatchers,\n  rewrites,\n}: Omit<\n  DefineEnvOptions,\n  'isClient' | 'isNodeOrEdgeCompilation' | 'isEdgeServer' | 'isNodeServer'\n>): DefineEnv {\n  let defineEnv: DefineEnv = {\n    client: [],\n    edge: [],\n    nodejs: [],\n  }\n\n  for (const variant of Object.keys(defineEnv) as (keyof typeof defineEnv)[]) {\n    defineEnv[variant] = rustifyOptionEnv(\n      getDefineEnv({\n        isTurbopack,\n        clientRouterFilters,\n        config,\n        dev,\n        distDir,\n        projectPath,\n        fetchCacheKeyPrefix,\n        hasRewrites,\n        isClient: variant === 'client',\n        isEdgeServer: variant === 'edge',\n        isNodeServer: variant === 'nodejs',\n        middlewareMatchers,\n        rewrites,\n      })\n    )\n  }\n\n  return defineEnv\n}\n\nfunction rustifyEnv(env: Record<string, string>): RustifiedEnv {\n  return Object.entries(env)\n    .filter(([_, value]) => value != null)\n    .map(([name, value]) => ({\n      name,\n      value,\n    }))\n}\n\nfunction rustifyOptionEnv(\n  env: Record<string, string | undefined>\n): RustifiedOptionEnv {\n  return Object.entries(env).map(([name, value]) => ({\n    name,\n    value,\n  }))\n}\n\nconst normalizePathOnWindows = (p: string) =>\n  path.sep === '\\\\' ? p.replace(/\\\\/g, '/') : p\n\n// TODO(sokra) Support wasm option.\nfunction bindingToApi(\n  binding: RawBindings,\n  bindingPath: string,\n  _wasm: boolean\n): Binding['turbo']['createProject'] {\n  type NativeFunction<T> = (\n    callback: (err: Error, value: T) => void\n  ) => Promise<{ __napiType: 'RootTask' }>\n\n  type NapiEndpoint = { __napiType: 'Endpoint' }\n\n  type NapiEntrypoints = {\n    routes: NapiRoute[]\n    middleware?: NapiMiddleware\n    instrumentation?: NapiInstrumentation\n    pagesDocumentEndpoint: NapiEndpoint\n    pagesAppEndpoint: NapiEndpoint\n    pagesErrorEndpoint: NapiEndpoint\n  }\n\n  type NapiMiddleware = {\n    endpoint: NapiEndpoint\n    isProxy: boolean\n  }\n\n  type NapiInstrumentation = {\n    nodeJs: NapiEndpoint\n    edge: NapiEndpoint\n  }\n\n  type NapiRoute = {\n    pathname: string\n  } & (\n    | {\n        type: 'page'\n        htmlEndpoint: NapiEndpoint\n        dataEndpoint: NapiEndpoint\n      }\n    | {\n        type: 'page-api'\n        endpoint: NapiEndpoint\n      }\n    | {\n        type: 'app-page'\n        pages: {\n          originalName: string\n          htmlEndpoint: NapiEndpoint\n          rscEndpoint: NapiEndpoint\n        }[]\n      }\n    | {\n        type: 'app-route'\n        originalName: string\n        endpoint: NapiEndpoint\n      }\n    | {\n        type: 'conflict'\n      }\n  )\n\n  const cancel = new (class Cancel extends Error {})()\n\n  /**\n   * Utility function to ensure all variants of an enum are handled.\n   */\n  function invariant(\n    never: never,\n    computeMessage: (arg: any) => string\n  ): never {\n    throw new Error(`Invariant: ${computeMessage(never)}`)\n  }\n\n  /**\n   * Calls a native function and streams the result.\n   * If useBuffer is true, all values will be preserved, potentially buffered\n   * if consumed slower than produced. Else, only the latest value will be\n   * preserved.\n   */\n  function subscribe<T>(\n    useBuffer: boolean,\n    nativeFunction:\n      | NativeFunction<T>\n      | ((callback: (err: Error, value: T) => void) => Promise<void>)\n  ): AsyncIterableIterator<T> {\n    type BufferItem =\n      | { err: Error; value: undefined }\n      | { err: undefined; value: T }\n    // A buffer of produced items. This will only contain values if the\n    // consumer is slower than the producer.\n    let buffer: BufferItem[] = []\n    // A deferred value waiting for the next produced item. This will only\n    // exist if the consumer is faster than the producer.\n    let waiting:\n      | {\n          resolve: (value: T) => void\n          reject: (error: Error) => void\n        }\n      | undefined\n    let canceled = false\n\n    // The native function will call this every time it emits a new result. We\n    // either need to notify a waiting consumer, or buffer the new result until\n    // the consumer catches up.\n    function emitResult(err: Error | undefined, value: T | undefined) {\n      if (waiting) {\n        let { resolve, reject } = waiting\n        waiting = undefined\n        if (err) reject(err)\n        else resolve(value!)\n      } else {\n        const item = { err, value } as BufferItem\n        if (useBuffer) buffer.push(item)\n        else buffer[0] = item\n      }\n    }\n\n    async function* createIterator() {\n      const task = await nativeFunction(emitResult)\n      try {\n        while (!canceled) {\n          if (buffer.length > 0) {\n            const item = buffer.shift()!\n            if (item.err) throw item.err\n            yield item.value\n          } else {\n            // eslint-disable-next-line no-loop-func\n            yield new Promise<T>((resolve, reject) => {\n              waiting = { resolve, reject }\n            })\n          }\n        }\n      } catch (e) {\n        if (e === cancel) return\n        throw e\n      } finally {\n        if (task) {\n          binding.rootTaskDispose(task)\n        }\n      }\n    }\n\n    const iterator = createIterator()\n    iterator.return = async () => {\n      canceled = true\n      if (waiting) waiting.reject(cancel)\n      return { value: undefined, done: true } as IteratorReturnResult<never>\n    }\n    return iterator\n  }\n\n  async function rustifyProjectOptions(\n    options: ProjectOptions\n  ): Promise<NapiProjectOptions> {\n    return {\n      ...options,\n      nextConfig: await serializeNextConfig(\n        options.nextConfig,\n        path.join(options.rootPath, options.projectPath)\n      ),\n      env: rustifyEnv(options.env),\n    }\n  }\n\n  async function rustifyPartialProjectOptions(\n    options: PartialProjectOptions\n  ): Promise<NapiPartialProjectOptions> {\n    return {\n      ...options,\n      nextConfig:\n        options.nextConfig &&\n        (await serializeNextConfig(\n          options.nextConfig,\n          path.join(options.rootPath, options.projectPath)\n        )),\n      env: options.env && rustifyEnv(options.env),\n    }\n  }\n\n  class ProjectImpl implements Project {\n    private readonly _nativeProject: { __napiType: 'Project' }\n\n    constructor(nativeProject: { __napiType: 'Project' }) {\n      this._nativeProject = nativeProject\n\n      if (typeof binding.registerWorkerScheduler === 'function') {\n        runLoaderWorkerPool(binding, bindingPath)\n      }\n    }\n\n    async update(options: PartialProjectOptions) {\n      await binding.projectUpdate(\n        this._nativeProject,\n        await rustifyPartialProjectOptions(options)\n      )\n    }\n\n    async writeAnalyzeData(\n      appDirOnly: boolean\n    ): Promise<TurbopackResult<void>> {\n      const napiResult = (await binding.projectWriteAnalyzeData(\n        this._nativeProject,\n        appDirOnly\n      )) as TurbopackResult<void>\n      return napiResult\n    }\n\n    async writeAllEntrypointsToDisk(\n      appDirOnly: boolean\n    ): Promise<TurbopackResult<Partial<RawEntrypoints>>> {\n      const napiEndpoints = (await binding.projectWriteAllEntrypointsToDisk(\n        this._nativeProject,\n        appDirOnly\n      )) as TurbopackResult<Partial<NapiEntrypoints>>\n\n      if ('routes' in napiEndpoints) {\n        return napiEntrypointsToRawEntrypoints(\n          napiEndpoints as TurbopackResult<NapiEntrypoints>\n        )\n      } else {\n        return {\n          issues: napiEndpoints.issues,\n          diagnostics: napiEndpoints.diagnostics,\n        }\n      }\n    }\n\n    entrypointsSubscribe() {\n      const subscription = subscribe<TurbopackResult<NapiEntrypoints | {}>>(\n        false,\n        async (callback) =>\n          binding.projectEntrypointsSubscribe(this._nativeProject, callback)\n      )\n      return (async function* () {\n        for await (const entrypoints of subscription) {\n          if ('routes' in (entrypoints as TurbopackResult<NapiEntrypoints>)) {\n            yield napiEntrypointsToRawEntrypoints(\n              entrypoints as TurbopackResult<NapiEntrypoints>\n            )\n          } else {\n            yield {\n              issues: entrypoints.issues,\n              diagnostics: entrypoints.diagnostics,\n            } as TurbopackResult<{}>\n          }\n        }\n      })()\n    }\n\n    hmrEvents(\n      chunkName: string,\n      target: HmrTarget.Client\n    ): AsyncIterableIterator<TurbopackResult<Update>>\n    hmrEvents(\n      chunkName: string,\n      target: HmrTarget.Server\n    ): AsyncIterableIterator<TurbopackResult<NodeJsHmrUpdate>>\n    hmrEvents(chunkName: string, target: HmrTarget.Client | HmrTarget.Server) {\n      return subscribe(true, async (callback) =>\n        binding.projectHmrEvents(\n          this._nativeProject,\n          chunkName,\n          target,\n          callback\n        )\n      )\n    }\n\n    /**\n     * Subscribe to the list of output chunk paths that can receive HMR updates.\n     * Chunk paths are output file paths like \"server/chunks/ssr/..._.js\" for server\n     * or \"_next/static/chunks/app/page.js\" for client.\n     */\n    hmrChunkNamesSubscribe(target: HmrTarget) {\n      return subscribe<TurbopackResult<HmrChunkNames>>(\n        false,\n        async (callback) =>\n          binding.projectHmrChunkNamesSubscribe(\n            this._nativeProject,\n            target,\n            callback\n          )\n      )\n    }\n\n    traceSource(\n      stackFrame: TurbopackStackFrame,\n      currentDirectoryFileUrl: string\n    ): Promise<TurbopackStackFrame | null> {\n      return binding.projectTraceSource(\n        this._nativeProject,\n        stackFrame,\n        currentDirectoryFileUrl\n      )\n    }\n\n    getSourceForAsset(filePath: string): Promise<string | null> {\n      return binding.projectGetSourceForAsset(this._nativeProject, filePath)\n    }\n\n    getSourceMap(filePath: string): Promise<string | null> {\n      return binding.projectGetSourceMap(this._nativeProject, filePath)\n    }\n\n    getSourceMapSync(filePath: string): string | null {\n      return binding.projectGetSourceMapSync(this._nativeProject, filePath)\n    }\n\n    updateInfoSubscribe(aggregationMs: number) {\n      return subscribe<TurbopackResult<UpdateMessage>>(true, async (callback) =>\n        binding.projectUpdateInfoSubscribe(\n          this._nativeProject,\n          aggregationMs,\n          callback\n        )\n      )\n    }\n\n    compilationEventsSubscribe(eventTypes?: string[]) {\n      return subscribe<TurbopackResult<CompilationEvent>>(\n        true,\n        async (callback) => {\n          binding.projectCompilationEventsSubscribe(\n            this._nativeProject,\n            callback,\n            eventTypes\n          )\n        }\n      )\n    }\n\n    invalidateFileSystemCache(): Promise<void> {\n      return binding.projectInvalidateFileSystemCache(this._nativeProject)\n    }\n\n    shutdown(): Promise<void> {\n      return binding.projectShutdown(this._nativeProject)\n    }\n\n    onExit(): Promise<void> {\n      return binding.projectOnExit(this._nativeProject)\n    }\n  }\n\n  class EndpointImpl implements Endpoint {\n    private readonly _nativeEndpoint: { __napiType: 'Endpoint' }\n\n    constructor(nativeEndpoint: { __napiType: 'Endpoint' }) {\n      this._nativeEndpoint = nativeEndpoint\n    }\n\n    async writeToDisk(): Promise<TurbopackResult<WrittenEndpoint>> {\n      return (await binding.endpointWriteToDisk(\n        this._nativeEndpoint\n      )) as TurbopackResult<WrittenEndpoint>\n    }\n\n    async clientChanged(): Promise<AsyncIterableIterator<TurbopackResult>> {\n      const clientSubscription = subscribe<TurbopackResult>(\n        false,\n        async (callback) =>\n          binding.endpointClientChangedSubscribe(this._nativeEndpoint, callback)\n      )\n      await clientSubscription.next()\n      return clientSubscription\n    }\n\n    async serverChanged(\n      includeIssues: boolean\n    ): Promise<AsyncIterableIterator<TurbopackResult>> {\n      const serverSubscription = subscribe<TurbopackResult>(\n        false,\n        async (callback) =>\n          binding.endpointServerChangedSubscribe(\n            this._nativeEndpoint,\n            includeIssues,\n            callback\n          )\n      )\n      await serverSubscription.next()\n      return serverSubscription\n    }\n  }\n\n  async function serializeNextConfig(\n    nextConfig: NextConfigComplete,\n    projectPath: string\n  ): Promise<string> {\n    // Avoid mutating the existing `nextConfig` object. NOTE: This is only a shallow clone.\n    let nextConfigSerializable: Record<string, any> = { ...nextConfig }\n\n    // These values are never read by Turbopack and are potentially non-serializable.\n    nextConfigSerializable.exportPathMap = {}\n    nextConfigSerializable.generateBuildId =\n      nextConfigSerializable.generateBuildId && {}\n    nextConfigSerializable.webpack = nextConfigSerializable.webpack && {}\n\n    if (nextConfigSerializable.modularizeImports) {\n      nextConfigSerializable.modularizeImports = Object.fromEntries(\n        Object.entries<any>(nextConfigSerializable.modularizeImports).map(\n          ([mod, config]) => [\n            mod,\n            {\n              ...config,\n              transform:\n                typeof config.transform === 'string'\n                  ? config.transform\n                  : Object.entries(config.transform),\n            },\n          ]\n        )\n      )\n    }\n\n    // These are relative paths, but might be backslash-separated on Windows\n    nextConfigSerializable.distDir = normalizePathOnWindows(\n      nextConfigSerializable.distDir\n    )\n    nextConfigSerializable.distDirRoot = normalizePathOnWindows(\n      nextConfigSerializable.distDirRoot\n    )\n\n    // loaderFile is an absolute path, we need it to be relative for turbopack.\n    if (nextConfigSerializable.images.loaderFile) {\n      nextConfigSerializable.images = {\n        ...nextConfigSerializable.images,\n        loaderFile:\n          './' +\n          normalizePathOnWindows(\n            path.relative(projectPath, nextConfigSerializable.images.loaderFile)\n          ),\n      }\n    }\n\n    // cacheHandler can be an absolute path, we need it to be relative for turbopack.\n    if (nextConfigSerializable.cacheHandler) {\n      nextConfigSerializable.cacheHandler =\n        './' +\n        normalizePathOnWindows(\n          path.isAbsolute(nextConfigSerializable.cacheHandler)\n            ? path.relative(projectPath, nextConfigSerializable.cacheHandler)\n            : nextConfigSerializable.cacheHandler\n        )\n    }\n    if (nextConfigSerializable.cacheHandlers) {\n      nextConfigSerializable.cacheHandlers = Object.fromEntries(\n        Object.entries(\n          nextConfigSerializable.cacheHandlers as Record<string, string>\n        )\n          .filter(([_, value]) => value != null)\n          .map(([key, value]) => [\n            key,\n            './' +\n              normalizePathOnWindows(\n                path.isAbsolute(value)\n                  ? path.relative(projectPath, value)\n                  : value\n              ),\n          ])\n      )\n    }\n\n    if (nextConfigSerializable.turbopack != null) {\n      // clone to allow in-place mutations\n      const turbopack = { ...nextConfigSerializable.turbopack }\n\n      if (turbopack.rules) {\n        turbopack.rules = serializeTurbopackRules(turbopack.rules)\n      }\n\n      // Serialize ignoreIssue rules: convert RegExp to {source, flags}\n      if (turbopack.ignoreIssue) {\n        function serializePatternField(\n          value: string | RegExp,\n          stringType: 'glob' | 'string'\n        ) {\n          if (value instanceof RegExp) {\n            return {\n              type: 'regex' as const,\n              source: value.source,\n              flags: value.flags,\n            }\n          }\n          return { type: stringType, value }\n        }\n\n        turbopack.ignoreIssue = turbopack.ignoreIssue.map(\n          (rule: {\n            path: string | RegExp\n            title?: string | RegExp\n            description?: string | RegExp\n          }) => ({\n            path: serializePatternField(rule.path, 'glob'),\n            title:\n              rule.title != null\n                ? serializePatternField(rule.title, 'string')\n                : undefined,\n            description:\n              rule.description != null\n                ? serializePatternField(rule.description, 'string')\n                : undefined,\n          })\n        )\n      }\n\n      nextConfigSerializable.turbopack = turbopack\n    }\n\n    return JSON.stringify(nextConfigSerializable, null, 2)\n  }\n\n  type SerializedRuleCondition =\n    | { all: SerializedRuleCondition[] }\n    | { any: SerializedRuleCondition[] }\n    | { not: SerializedRuleCondition }\n    | TurbopackLoaderBuiltinCondition\n    | {\n        path?:\n          | { type: 'regex'; value: { source: string; flags: string } }\n          | { type: 'glob'; value: string }\n        content?: { source: string; flags: string }\n        query?:\n          | { type: 'regex'; value: { source: string; flags: string } }\n          | { type: 'constant'; value: string }\n        contentType?:\n          | { type: 'regex'; value: { source: string; flags: string } }\n          | { type: 'glob'; value: string }\n      }\n\n  // converts regexes to a `RegexComponents` object so that it can be JSON-serialized when passed to\n  // Turbopack\n  function serializeRuleCondition(\n    cond: TurbopackRuleCondition\n  ): SerializedRuleCondition {\n    function regexComponents(regex: RegExp) {\n      return {\n        source: regex.source,\n        flags: regex.flags,\n      }\n    }\n\n    if (typeof cond === 'string') {\n      return cond\n    } else if ('all' in cond) {\n      return { ...cond, all: cond.all.map(serializeRuleCondition) }\n    } else if ('any' in cond) {\n      return { ...cond, any: cond.any.map(serializeRuleCondition) }\n    } else if ('not' in cond) {\n      return { ...cond, not: serializeRuleCondition(cond.not) }\n    } else {\n      return {\n        ...cond,\n        path:\n          cond.path == null\n            ? undefined\n            : cond.path instanceof RegExp\n              ? {\n                  type: 'regex',\n                  value: regexComponents(cond.path),\n                }\n              : { type: 'glob', value: cond.path },\n        content: cond.content && regexComponents(cond.content),\n        query:\n          cond.query == null\n            ? undefined\n            : cond.query instanceof RegExp\n              ? {\n                  type: 'regex',\n                  value: regexComponents(cond.query),\n                }\n              : { type: 'constant', value: cond.query },\n        contentType:\n          cond.contentType == null\n            ? undefined\n            : cond.contentType instanceof RegExp\n              ? {\n                  type: 'regex',\n                  value: regexComponents(cond.contentType),\n                }\n              : { type: 'glob', value: cond.contentType },\n      }\n    }\n  }\n\n  // Note: Returns an updated `turbopackRules` with serialized conditions. Does not mutate in-place.\n  function serializeTurbopackRules(\n    turbopackRules: Record<string, TurbopackRuleConfigCollection>\n  ): Record<string, any> {\n    const serializedRules: Record<string, any> = {}\n    for (const [glob, rule] of Object.entries(turbopackRules)) {\n      if (Array.isArray(rule)) {\n        serializedRules[glob] = rule.map((item) => {\n          if (\n            typeof item !== 'string' &&\n            ('loaders' in item || 'type' in item || 'condition' in item)\n          ) {\n            return serializeConfigItem(item as TurbopackRuleConfigItem, glob)\n          } else {\n            checkLoaderItem(item as TurbopackLoaderItem, glob)\n            return item\n          }\n        })\n      } else {\n        serializedRules[glob] = serializeConfigItem(rule, glob)\n      }\n    }\n\n    return serializedRules\n\n    function serializeConfigItem(\n      rule: TurbopackRuleConfigItem,\n      glob: string\n    ): any {\n      if (!rule) return rule\n      if (rule.loaders) {\n        for (const item of rule.loaders) {\n          checkLoaderItem(item, glob)\n        }\n      }\n      let serializedRule: any = rule\n      if (rule.condition != null) {\n        serializedRule = {\n          ...rule,\n          condition: serializeRuleCondition(rule.condition),\n        }\n      }\n      return serializedRule\n    }\n\n    function checkLoaderItem(loaderItem: TurbopackLoaderItem, glob: string) {\n      if (\n        typeof loaderItem !== 'string' &&\n        !(require('util') as typeof import('util')).isDeepStrictEqual(\n          loaderItem,\n          JSON.parse(JSON.stringify(loaderItem))\n        )\n      ) {\n        throw new Error(\n          `loader ${loaderItem.loader} for match \"${glob}\" does not have serializable options. ` +\n            'Ensure that options passed are plain JavaScript objects and values.'\n        )\n      }\n    }\n  }\n\n  function napiEntrypointsToRawEntrypoints(\n    entrypoints: TurbopackResult<NapiEntrypoints>\n  ): TurbopackResult<RawEntrypoints> {\n    const routes = new Map()\n    for (const { pathname, ...nativeRoute } of entrypoints.routes) {\n      let route: Route\n      const routeType = nativeRoute.type\n      switch (routeType) {\n        case 'page':\n          route = {\n            type: 'page',\n            htmlEndpoint: new EndpointImpl(nativeRoute.htmlEndpoint),\n            dataEndpoint: new EndpointImpl(nativeRoute.dataEndpoint),\n          }\n          break\n        case 'page-api':\n          route = {\n            type: 'page-api',\n            endpoint: new EndpointImpl(nativeRoute.endpoint),\n          }\n          break\n        case 'app-page':\n          route = {\n            type: 'app-page',\n            pages: nativeRoute.pages.map((page) => ({\n              originalName: page.originalName,\n              htmlEndpoint: new EndpointImpl(page.htmlEndpoint),\n              rscEndpoint: new EndpointImpl(page.rscEndpoint),\n            })),\n          }\n          break\n        case 'app-route':\n          route = {\n            type: 'app-route',\n            originalName: nativeRoute.originalName,\n            endpoint: new EndpointImpl(nativeRoute.endpoint),\n          }\n          break\n        case 'conflict':\n          route = {\n            type: 'conflict',\n          }\n          break\n        default: {\n          const _exhaustiveCheck: never = routeType\n          invariant(\n            nativeRoute,\n            () => `Unknown route type: ${_exhaustiveCheck}`\n          )\n        }\n      }\n      routes.set(pathname, route)\n    }\n    const napiMiddlewareToMiddleware = (middleware: NapiMiddleware) => ({\n      endpoint: new EndpointImpl(middleware.endpoint),\n      isProxy: middleware.isProxy,\n    })\n    const middleware = entrypoints.middleware\n      ? napiMiddlewareToMiddleware(entrypoints.middleware)\n      : undefined\n    const napiInstrumentationToInstrumentation = (\n      instrumentation: NapiInstrumentation\n    ) => ({\n      nodeJs: new EndpointImpl(instrumentation.nodeJs),\n      edge: new EndpointImpl(instrumentation.edge),\n    })\n    const instrumentation = entrypoints.instrumentation\n      ? napiInstrumentationToInstrumentation(entrypoints.instrumentation)\n      : undefined\n\n    return {\n      routes,\n      middleware,\n      instrumentation,\n      pagesDocumentEndpoint: new EndpointImpl(\n        entrypoints.pagesDocumentEndpoint\n      ),\n      pagesAppEndpoint: new EndpointImpl(entrypoints.pagesAppEndpoint),\n      pagesErrorEndpoint: new EndpointImpl(entrypoints.pagesErrorEndpoint),\n      issues: entrypoints.issues,\n      diagnostics: entrypoints.diagnostics,\n    }\n  }\n\n  return async function createProject(\n    options: ProjectOptions,\n    turboEngineOptions,\n    callbacks?: import('./types').TurbopackProjectCallbacks\n  ) {\n    return new ProjectImpl(\n      await binding.projectNew(\n        await rustifyProjectOptions(options),\n        turboEngineOptions || {},\n        {\n          throwTurbopackInternalError: (\n            require('../../shared/lib/turbopack/internal-error') as typeof import('../../shared/lib/turbopack/internal-error')\n          ).throwTurbopackInternalError,\n          onBeforeDeferredEntries: callbacks?.onBeforeDeferredEntries,\n        }\n      )\n    )\n  }\n}\n\n// helper for loadWasm\nasync function loadWasmRawBindings(importPath = ''): Promise<RawWasmBindings> {\n  let attempts = []\n\n  // Used by `run-tests` to force use of a locally-built wasm binary. This environment variable is\n  // unstable and subject to change.\n  const testWasmDir = process.env.NEXT_TEST_WASM_DIR\n\n  if (testWasmDir) {\n    // assume these are node.js bindings and don't need a call to `.default()`\n    const rawBindings = await import(\n      pathToFileURL(path.join(testWasmDir, 'wasm.js')).toString()\n    )\n    infoLog(`next-swc build: wasm build ${testWasmDir}`)\n    return rawBindings\n  } else {\n    for (let pkg of ['@next/swc-wasm-nodejs', '@next/swc-wasm-web']) {\n      try {\n        let pkgPath = pkg\n\n        if (importPath) {\n          // the import path must be exact when not in node_modules\n          pkgPath = path.join(importPath, pkg, 'wasm.js')\n        }\n        const importedRawBindings = await import(\n          pathToFileURL(pkgPath).toString()\n        )\n        let rawBindings\n        if (pkg === '@next/swc-wasm-web') {\n          // https://rustwasm.github.io/docs/wasm-bindgen/examples/without-a-bundler.html\n          // `default` must be called to initialize the module\n          rawBindings = await importedRawBindings.default!()\n        } else {\n          rawBindings = importedRawBindings\n        }\n        infoLog(`next-swc build: wasm build ${pkg}`)\n        return rawBindings\n      } catch (e: any) {\n        // Only log attempts for loading wasm when loading as fallback\n        if (importPath) {\n          if (e?.code === 'ERR_MODULE_NOT_FOUND') {\n            attempts.push(`Attempted to load ${pkg}, but it was not installed`)\n          } else {\n            attempts.push(\n              `Attempted to load ${pkg}, but an error occurred: ${e.message ?? e}`\n            )\n          }\n        }\n      }\n    }\n  }\n\n  throw attempts\n}\n\n// helper for tryLoadWasmWithFallback / loadBindings.\nasync function loadWasm(importPath = '') {\n  const rawBindings = await loadWasmRawBindings(importPath)\n\n  function removeUndefined(obj: any): any {\n    // serde-wasm-bindgen expect that `undefined` values map to `()` in rust, but we want to treat\n    // those fields as non-existent, so remove them before passing them to rust.\n    //\n    // The native (non-wasm) bindings use `JSON.stringify`, which strips undefined values.\n    if (typeof obj !== 'object' || obj === null) {\n      return obj\n    }\n    if (Array.isArray(obj)) {\n      return obj.map(removeUndefined)\n    }\n    const newObj: { [key: string]: any } = {}\n    for (const [k, v] of Object.entries(obj)) {\n      if (typeof v !== 'undefined') {\n        newObj[k] = removeUndefined(v)\n      }\n    }\n    return newObj\n  }\n\n  // Note wasm binary does not support async intefaces yet, all async\n  // interface coereces to sync interfaces.\n  let wasmBindings = {\n    css: {\n      lightning: {\n        transform: function (_options: any) {\n          throw new Error(\n            '`css.lightning.transform` is not supported by the wasm bindings.'\n          )\n        },\n        transformStyleAttr: function (_options: any) {\n          throw new Error(\n            '`css.lightning.transformStyleAttr` is not supported by the wasm bindings.'\n          )\n        },\n        featureNamesToMask: function (_names: string[]) {\n          throw new Error(\n            '`css.lightning.featureNamesToMask` is not supported by the wasm bindings.'\n          )\n        },\n      },\n    },\n    isWasm: true,\n    transform(src: string, options: any): Promise<any> {\n      return rawBindings.transform(src.toString(), removeUndefined(options))\n    },\n    transformSync(src: string, options: any) {\n      return rawBindings.transformSync(src.toString(), removeUndefined(options))\n    },\n    minify(src: string, options: any): Promise<any> {\n      return rawBindings.minify(src.toString(), removeUndefined(options))\n    },\n    minifySync(src: string, options: any) {\n      return rawBindings.minifySync(src.toString(), removeUndefined(options))\n    },\n    parse(src: string, options: any): Promise<any> {\n      return rawBindings.parse(src.toString(), removeUndefined(options))\n    },\n    getTargetTriple() {\n      return undefined\n    },\n    turbo: {\n      createProject(\n        _options: ProjectOptions,\n        _turboEngineOptions?: TurboEngineOptions | undefined,\n        _callbacks?: import('./types').TurbopackProjectCallbacks | undefined\n      ): Promise<Project> {\n        throw new Error(\n          `Turbopack is not supported on this platform (${PlatformName}/${ArchName}) because native bindings are not available. ` +\n            `Only WebAssembly (WASM) bindings were loaded, and Turbopack requires native bindings. ` +\n            `Use the --webpack flag instead.`\n        )\n      },\n      startTurbopackTraceServer(\n        _traceFilePath: string,\n        _port: number | undefined\n      ): void {\n        throw new Error(\n          `Turbopack trace server is not supported on this platform (${PlatformName}/${ArchName}) because native bindings are not available. ` +\n            `Only WebAssembly (WASM) bindings were loaded, and Turbopack requires native bindings.`\n        )\n      },\n    },\n    mdx: {\n      compile(src: string, options: any) {\n        return rawBindings.mdxCompile(\n          src,\n          removeUndefined(getMdxOptions(options))\n        )\n      },\n      compileSync(src: string, options: any) {\n        return rawBindings.mdxCompileSync(\n          src,\n          removeUndefined(getMdxOptions(options))\n        )\n      },\n    },\n    reactCompiler: {\n      isReactCompilerRequired(_filename: string) {\n        return Promise.resolve(true)\n      },\n    },\n    rspack: {\n      getModuleNamedExports(_resourcePath: string): Promise<string[]> {\n        throw new Error(\n          '`rspack.getModuleNamedExports` is not supported by the wasm bindings.'\n        )\n      },\n      warnForEdgeRuntime(\n        _source: string,\n        _isProduction: boolean\n      ): Promise<NapiSourceDiagnostic[]> {\n        throw new Error(\n          '`rspack.warnForEdgeRuntime` is not supported by the wasm bindings.'\n        )\n      },\n    },\n    expandNextJsTemplate(\n      content: Buffer,\n      templatePath: string,\n      nextPackageDirPath: string,\n      replacements: Record<`VAR_${string}`, string>,\n      injections: Record<string, string>,\n      imports: Record<string, string | null>\n    ): string {\n      return rawBindings.expandNextJsTemplate(\n        content,\n        templatePath,\n        nextPackageDirPath,\n        replacements,\n        injections,\n        imports\n      )\n    },\n    codeFrameColumns(\n      source: string,\n      location: NapiCodeFrameLocation,\n      options?: NapiCodeFrameOptions\n    ): string | undefined {\n      return rawBindings.codeFrameColumns(\n        Buffer.from(source),\n        location,\n        options\n      )\n    },\n    lockfileTryAcquire(_filePath: string, _content?: string | null) {\n      throw new Error(\n        '`lockfileTryAcquire` is not supported by the wasm bindings.'\n      )\n    },\n    lockfileTryAcquireSync(_filePath: string, _content?: string | null) {\n      throw new Error(\n        '`lockfileTryAcquireSync` is not supported by the wasm bindings.'\n      )\n    },\n    lockfileUnlock(_lockfile: Lockfile) {\n      throw new Error('`lockfileUnlock` is not supported by the wasm bindings.')\n    },\n    lockfileUnlockSync(_lockfile: Lockfile) {\n      throw new Error(\n        '`lockfileUnlockSync` is not supported by the wasm bindings.'\n      )\n    },\n  }\n  return wasmBindings\n}\n\n/**\n * Loads the native (non-wasm) bindings. Prefer `loadBindings` over this API, as that includes a\n * wasm fallback.\n */\nfunction loadNative(importPath?: string): Binding {\n  if (loadedBindings) {\n    return loadedBindings\n  }\n\n  if (process.env.NEXT_TEST_WASM) {\n    throw new Error('cannot run loadNative when `NEXT_TEST_WASM` is set')\n  }\n\n  const customBindingsPath = !!__INTERNAL_CUSTOM_TURBOPACK_BINDINGS\n    ? require.resolve(__INTERNAL_CUSTOM_TURBOPACK_BINDINGS)\n    : null\n  const customBindings: RawBindings =\n    customBindingsPath != null ? require(customBindingsPath!) : null\n  let bindings: RawBindings = customBindings\n  let bindingsPath = customBindingsPath\n  // callers expect that if loadNative throws, it's an array of strings.\n  let attempts: any[] = []\n\n  const NEXT_TEST_NATIVE_DIR = process.env.NEXT_TEST_NATIVE_DIR\n  for (const triple of triples) {\n    if (NEXT_TEST_NATIVE_DIR) {\n      try {\n        const bindingForTest = `${NEXT_TEST_NATIVE_DIR}/next-swc.${triple.platformArchABI}.node`\n        // Use the binary directly to skip `pnpm pack` for testing as it's slow because of the large native binary.\n        bindingsPath = require.resolve(bindingForTest)\n        bindings = require(bindingsPath)\n        infoLog(\n          'next-swc build: local built @next/swc from NEXT_TEST_NATIVE_DIR'\n        )\n        break\n      } catch (e: any) {\n        attempts.push(\n          `Failed to load triple ${triple.platformArchABI}: ${e.message ?? e}`\n        )\n      }\n    } else if (process.env.NEXT_TEST_NATIVE_IGNORE_LOCAL_INSTALL !== 'true') {\n      try {\n        const normalBinding = `@next/swc/native/next-swc.${triple.platformArchABI}.node`\n        bindings = require(normalBinding)\n        bindingsPath = require.resolve(normalBinding)\n        infoLog('next-swc build: local built @next/swc')\n        break\n      } catch (e) {}\n    }\n  }\n\n  if (!bindings) {\n    if (NEXT_TEST_NATIVE_DIR) {\n      throw attempts\n    }\n\n    for (const triple of triples) {\n      let pkg = importPath\n        ? path.join(\n            importPath,\n            `@next/swc-${triple.platformArchABI}`,\n            `next-swc.${triple.platformArchABI}.node`\n          )\n        : `@next/swc-${triple.platformArchABI}`\n      try {\n        bindings = require(pkg)\n        bindingsPath = require.resolve(pkg)\n        if (!importPath) {\n          checkVersionMismatch(require(`${pkg}/package.json`))\n        }\n        break\n      } catch (e: any) {\n        if (e?.code === 'MODULE_NOT_FOUND') {\n          attempts.push(`Attempted to load ${pkg}, but it was not installed`)\n        } else {\n          attempts.push(\n            `Attempted to load ${pkg}, but an error occurred: ${e.message ?? e}`\n          )\n        }\n        lastNativeBindingsLoadErrorCode = e?.code ?? 'unknown'\n      }\n    }\n  }\n\n  if (bindings) {\n    loadedBindings = {\n      isWasm: false,\n      transform(src: string, options: any) {\n        const isModule =\n          typeof src !== 'undefined' &&\n          typeof src !== 'string' &&\n          !Buffer.isBuffer(src)\n        options = options || {}\n\n        if (options?.jsc?.parser) {\n          options.jsc.parser.syntax = options.jsc.parser.syntax ?? 'ecmascript'\n        }\n\n        return bindings.transform(\n          isModule ? JSON.stringify(src) : src,\n          isModule,\n          toBuffer(options)\n        )\n      },\n\n      transformSync(src: string, options: any) {\n        if (typeof src === 'undefined') {\n          throw new Error(\n            \"transformSync doesn't implement reading the file from filesystem\"\n          )\n        } else if (Buffer.isBuffer(src)) {\n          throw new Error(\n            \"transformSync doesn't implement taking the source code as Buffer\"\n          )\n        }\n        const isModule = typeof src !== 'string'\n        options = options || {}\n\n        if (options?.jsc?.parser) {\n          options.jsc.parser.syntax = options.jsc.parser.syntax ?? 'ecmascript'\n        }\n\n        return bindings.transformSync(\n          isModule ? JSON.stringify(src) : src,\n          isModule,\n          toBuffer(options)\n        )\n      },\n\n      minify(src: string, options: any) {\n        return bindings.minify(Buffer.from(src), toBuffer(options ?? {}))\n      },\n\n      minifySync(src: string, options: any) {\n        return bindings.minifySync(Buffer.from(src), toBuffer(options ?? {}))\n      },\n\n      parse(src: string, options: any) {\n        return bindings.parse(src, toBuffer(options ?? {}))\n      },\n\n      getTargetTriple: bindings.getTargetTriple,\n      initCustomTraceSubscriber: bindings.initCustomTraceSubscriber,\n      teardownTraceSubscriber: bindings.teardownTraceSubscriber,\n      turbo: {\n        createProject: bindingToApi(\n          customBindings ?? bindings,\n          customBindingsPath ?? bindingsPath!,\n          false\n        ),\n        startTurbopackTraceServer(traceFilePath, port) {\n          Log.warn(\n            `Turbopack trace server started. View trace at https://trace.nextjs.org${port != null ? `?port=${port}` : ''}`\n          )\n          ;(customBindings ?? bindings).startTurbopackTraceServer(\n            traceFilePath,\n            port\n          )\n        },\n      },\n      mdx: {\n        compile(src: string, options: any) {\n          return bindings.mdxCompile(src, toBuffer(getMdxOptions(options)))\n        },\n        compileSync(src: string, options: any) {\n          bindings.mdxCompileSync(src, toBuffer(getMdxOptions(options)))\n        },\n      },\n      css: {\n        lightning: {\n          transform(transformOptions: any) {\n            return bindings.lightningCssTransform(transformOptions)\n          },\n          transformStyleAttr(transformAttrOptions: any) {\n            return bindings.lightningCssTransformStyleAttribute(\n              transformAttrOptions\n            )\n          },\n          featureNamesToMask(names: string[]) {\n            return bindings.lightningcssFeatureNamesToMaskNapi(names)\n          },\n        },\n      },\n      reactCompiler: {\n        isReactCompilerRequired: (filename: string) => {\n          return bindings.isReactCompilerRequired(filename)\n        },\n      },\n      rspack: {\n        getModuleNamedExports: function (\n          resourcePath: string\n        ): Promise<string[]> {\n          return bindings.getModuleNamedExports(resourcePath)\n        },\n        warnForEdgeRuntime: function (\n          source: string,\n          isProduction: boolean\n        ): Promise<NapiSourceDiagnostic[]> {\n          return bindings.warnForEdgeRuntime(source, isProduction)\n        },\n      },\n      expandNextJsTemplate(\n        content: Buffer,\n        templatePath: string,\n        nextPackageDirPath: string,\n        replacements: Record<`VAR_${string}`, string>,\n        injections: Record<string, string>,\n        imports: Record<string, string | null>\n      ): string {\n        return bindings.expandNextJsTemplate(\n          content,\n          templatePath,\n          nextPackageDirPath,\n          replacements,\n          injections,\n          imports\n        )\n      },\n      lockfileTryAcquire(filePath: string, content?: string | null) {\n        return bindings.lockfileTryAcquire(filePath, content)\n      },\n      lockfileTryAcquireSync(filePath: string, content?: string | null) {\n        return bindings.lockfileTryAcquireSync(filePath, content)\n      },\n      lockfileUnlock(lockfile: Lockfile) {\n        return bindings.lockfileUnlock(lockfile)\n      },\n      lockfileUnlockSync(lockfile: Lockfile) {\n        return bindings.lockfileUnlockSync(lockfile)\n      },\n      codeFrameColumns(source, location, options) {\n        // napi-rs translates Option::None as null but wasm-bindgen translates it to `null`\n        // convert here for consistency\n        return bindings.codeFrameColumns(source, location, options) ?? undefined\n      },\n    }\n    return loadedBindings!\n  }\n\n  throw attempts\n}\n\n/// Build a mdx options object contains default values that\n/// can be parsed with serde_wasm_bindgen.\nfunction getMdxOptions(options: any = {}) {\n  return {\n    ...options,\n    development: options.development ?? false,\n    jsx: options.jsx ?? false,\n    mdxType: options.mdxType ?? 'commonMark',\n  }\n}\n\nfunction toBuffer(t: any) {\n  return Buffer.from(JSON.stringify(t))\n}\n\nexport async function transform(src: string, options?: any): Promise<any> {\n  let bindings = getBindingsSync()\n  return bindings.transform(src, options)\n}\n\n/** Synchronously transforms the source and loads the native bindings. */\nexport function transformSync(src: string, options?: any): any {\n  const bindings = loadBindingsSync()\n  return bindings.transformSync(src, options)\n}\n\nexport function minify(\n  src: string,\n  options: any\n): Promise<{ code: string; map: any }> {\n  const bindings = getBindingsSync()\n  return bindings.minify(src, options)\n}\n\nexport function isReactCompilerRequired(filename: string): Promise<boolean> {\n  const bindings = getBindingsSync()\n  return bindings.reactCompiler.isReactCompilerRequired(filename)\n}\n\nexport async function parse(src: string, options: any): Promise<any> {\n  const bindings = getBindingsSync()\n  const parserOptions = (\n    require('./options') as typeof import('./options')\n  ).getParserOptions(options)\n  const parsed = await bindings.parse(src, parserOptions)\n  return JSON.parse(parsed)\n}\n\nexport function getBinaryMetadata() {\n  return {\n    target: loadedBindings?.getTargetTriple?.(),\n  }\n}\n\n/**\n * Initialize trace subscriber to emit traces.\n *\n */\nexport function initCustomTraceSubscriber(traceFileName?: string) {\n  if (!swcTraceFlushGuard) {\n    // Wasm binary doesn't support trace emission\n    swcTraceFlushGuard =\n      getBindingsSync().initCustomTraceSubscriber?.(traceFileName)\n  }\n}\n\nfunction once(fn: () => void): () => void {\n  let executed = false\n\n  return function (): void {\n    if (!executed) {\n      executed = true\n\n      fn()\n    }\n  }\n}\n\n/**\n * Teardown swc's trace subscriber if there's an initialized flush guard exists.\n *\n * This is workaround to amend behavior with process.exit\n * (https://github.com/vercel/next.js/blob/4db8c49cc31e4fc182391fae6903fb5ef4e8c66e/packages/next/bin/next.ts#L134=)\n * seems preventing napi's cleanup hook execution (https://github.com/swc-project/swc/blob/main/crates/node/src/util.rs#L48-L51=),\n *\n * instead parent process manually drops guard when process gets signal to exit.\n */\nexport const teardownTraceSubscriber = once(() => {\n  try {\n    if (swcTraceFlushGuard) {\n      getBindingsSync().teardownTraceSubscriber?.(swcTraceFlushGuard)\n    }\n  } catch (e) {\n    // Suppress exceptions, this fn allows to fail to load native bindings\n  }\n})\n\nexport async function getModuleNamedExports(\n  resourcePath: string\n): Promise<string[]> {\n  return getBindingsSync().rspack.getModuleNamedExports(resourcePath)\n}\n\nexport async function warnForEdgeRuntime(\n  source: string,\n  isProduction: boolean\n): Promise<NapiSourceDiagnostic[]> {\n  return getBindingsSync().rspack.warnForEdgeRuntime(source, isProduction)\n}\n"],"names":["path","pathToFileURL","arch","platform","platformArchTriples","Log","getDefineEnv","runLoaderWorkerPool","HmrTarget","nextVersion","process","env","__NEXT_VERSION","ArchName","PlatformName","infoLog","args","NEXT_PRIVATE_BUILD_WORKER","DEBUG","info","getSupportedArchTriples","darwin","win32","linux","freebsd","android","arm64","ia32","filter","triple","abi","x64","arm","triples","supportedArchTriples","targetTriple","rawTargetTriple","warn","__INTERNAL_CUSTOM_TURBOPACK_BINDINGS","checkVersionMismatch","pkgData","version","knownDefaultWasmFallbackTriples","lastNativeBindingsLoadErrorCode","undefined","pendingBindings","loadedBindings","downloadWasmPromise","swcTraceFlushGuard","downloadNativeBindingsPromise","lockfilePatchPromise","getBindingsSync","Error","loadBindings","useWasmBinary","RUST_MIN_STACK","NEXT_TEST_WASM","stdout","_handle","setBlocking","stderr","Promise","resolve","reject","cur","require","patchIncorrectLockfile","cwd","catch","console","error","attempts","disableWasmFallback","NEXT_DISABLE_SWC_WASM","unsupportedPlatform","some","raw","includes","isWebContainer","versions","webcontainer","shouldLoadWasmFallbackFirst","fallbackBindings","tryLoadWasmWithFallback","loadNative","a","Array","isArray","every","m","tryLoadNativeWithFallback","concat","logLoadFailure","nativeBindingsDirectory","join","dirname","downloadNativeNextSwc","map","platformArchABI","push","bindings","loadWasm","eventSwcLoadFailure","wasm","nativeBindingsErrorCode","wasmDirectory","downloadWasmSwc","attempt","loadBindingsSync","cause","loggingLoadFailure","triedWasm","createDefineEnv","isTurbopack","clientRouterFilters","config","dev","distDir","projectPath","fetchCacheKeyPrefix","hasRewrites","middlewareMatchers","rewrites","defineEnv","client","edge","nodejs","variant","Object","keys","rustifyOptionEnv","isClient","isEdgeServer","isNodeServer","rustifyEnv","entries","_","value","name","normalizePathOnWindows","p","sep","replace","bindingToApi","binding","bindingPath","_wasm","cancel","Cancel","invariant","never","computeMessage","subscribe","useBuffer","nativeFunction","buffer","waiting","canceled","emitResult","err","item","createIterator","task","length","shift","e","rootTaskDispose","iterator","return","done","rustifyProjectOptions","options","nextConfig","serializeNextConfig","rootPath","rustifyPartialProjectOptions","ProjectImpl","constructor","nativeProject","_nativeProject","registerWorkerScheduler","update","projectUpdate","writeAnalyzeData","appDirOnly","napiResult","projectWriteAnalyzeData","writeAllEntrypointsToDisk","napiEndpoints","projectWriteAllEntrypointsToDisk","napiEntrypointsToRawEntrypoints","issues","diagnostics","entrypointsSubscribe","subscription","callback","projectEntrypointsSubscribe","entrypoints","hmrEvents","chunkName","target","projectHmrEvents","hmrChunkNamesSubscribe","projectHmrChunkNamesSubscribe","traceSource","stackFrame","currentDirectoryFileUrl","projectTraceSource","getSourceForAsset","filePath","projectGetSourceForAsset","getSourceMap","projectGetSourceMap","getSourceMapSync","projectGetSourceMapSync","updateInfoSubscribe","aggregationMs","projectUpdateInfoSubscribe","compilationEventsSubscribe","eventTypes","projectCompilationEventsSubscribe","invalidateFileSystemCache","projectInvalidateFileSystemCache","shutdown","projectShutdown","onExit","projectOnExit","EndpointImpl","nativeEndpoint","_nativeEndpoint","writeToDisk","endpointWriteToDisk","clientChanged","clientSubscription","endpointClientChangedSubscribe","next","serverChanged","includeIssues","serverSubscription","endpointServerChangedSubscribe","nextConfigSerializable","exportPathMap","generateBuildId","webpack","modularizeImports","fromEntries","mod","transform","distDirRoot","images","loaderFile","relative","cacheHandler","isAbsolute","cacheHandlers","key","turbopack","rules","serializeTurbopackRules","ignoreIssue","serializePatternField","stringType","RegExp","type","source","flags","rule","title","description","JSON","stringify","serializeRuleCondition","cond","regexComponents","regex","all","any","not","content","query","contentType","turbopackRules","serializedRules","glob","serializeConfigItem","checkLoaderItem","loaders","serializedRule","condition","loaderItem","isDeepStrictEqual","parse","loader","routes","Map","pathname","nativeRoute","route","routeType","htmlEndpoint","dataEndpoint","endpoint","pages","page","originalName","rscEndpoint","_exhaustiveCheck","set","napiMiddlewareToMiddleware","middleware","isProxy","napiInstrumentationToInstrumentation","instrumentation","nodeJs","pagesDocumentEndpoint","pagesAppEndpoint","pagesErrorEndpoint","createProject","turboEngineOptions","callbacks","projectNew","throwTurbopackInternalError","onBeforeDeferredEntries","loadWasmRawBindings","importPath","testWasmDir","NEXT_TEST_WASM_DIR","rawBindings","toString","pkg","pkgPath","importedRawBindings","default","code","message","removeUndefined","obj","newObj","k","v","wasmBindings","css","lightning","_options","transformStyleAttr","featureNamesToMask","_names","isWasm","src","transformSync","minify","minifySync","getTargetTriple","turbo","_turboEngineOptions","_callbacks","startTurbopackTraceServer","_traceFilePath","_port","mdx","compile","mdxCompile","getMdxOptions","compileSync","mdxCompileSync","reactCompiler","isReactCompilerRequired","_filename","rspack","getModuleNamedExports","_resourcePath","warnForEdgeRuntime","_source","_isProduction","expandNextJsTemplate","templatePath","nextPackageDirPath","replacements","injections","imports","codeFrameColumns","location","Buffer","from","lockfileTryAcquire","_filePath","_content","lockfileTryAcquireSync","lockfileUnlock","_lockfile","lockfileUnlockSync","customBindingsPath","customBindings","bindingsPath","NEXT_TEST_NATIVE_DIR","bindingForTest","NEXT_TEST_NATIVE_IGNORE_LOCAL_INSTALL","normalBinding","isModule","isBuffer","jsc","parser","syntax","toBuffer","initCustomTraceSubscriber","teardownTraceSubscriber","traceFilePath","port","transformOptions","lightningCssTransform","transformAttrOptions","lightningCssTransformStyleAttribute","names","lightningcssFeatureNamesToMaskNapi","filename","resourcePath","isProduction","lockfile","development","jsx","mdxType","t","parserOptions","getParserOptions","parsed","getBinaryMetadata","traceFileName","once","fn","executed"],"mappings":"AAAA,OAAOA,UAAU,OAAM;AACvB,SAASC,aAAa,QAAQ,MAAK;AACnC,SAASC,IAAI,EAAEC,QAAQ,QAAQ,KAAI;AACnC,SAASC,mBAAmB,QAAQ,sCAAqC;AACzE,YAAYC,SAAS,gBAAe;AASpC,SAAgCC,YAAY,Q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