@openuiai/next 16.0.11 → 16.0.12
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/bin/next +1 -1
- package/dist/build/index.js +3 -3
- package/dist/build/swc/index.js +3 -1
- package/dist/build/swc/index.js.map +1 -1
- package/dist/build/webpack-config.js +2 -2
- package/dist/client/app-bootstrap.js +1 -1
- package/dist/client/index.js +1 -1
- package/dist/esm/build/index.js +3 -3
- package/dist/esm/build/swc/index.js +3 -1
- package/dist/esm/build/swc/index.js.map +1 -1
- package/dist/esm/build/webpack-config.js +2 -2
- package/dist/esm/client/app-bootstrap.js +1 -1
- package/dist/esm/client/index.js +1 -1
- package/dist/esm/lib/verify-typescript-setup.js +8 -0
- package/dist/esm/lib/verify-typescript-setup.js.map +1 -1
- package/dist/esm/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/esm/server/lib/app-info-log.js +1 -1
- package/dist/esm/server/lib/start-server.js +1 -1
- package/dist/esm/shared/lib/errors/canary-only-config-error.js +1 -1
- package/dist/lib/verify-typescript-setup.js +8 -0
- package/dist/lib/verify-typescript-setup.js.map +1 -1
- package/dist/server/dev/hot-reloader-webpack.js +1 -1
- package/dist/server/lib/app-info-log.js +1 -1
- package/dist/server/lib/start-server.js +1 -1
- package/dist/shared/lib/errors/canary-only-config-error.js +1 -1
- package/dist/telemetry/anonymous-meta.js +1 -1
- package/dist/telemetry/events/session-stopped.js +2 -2
- package/dist/telemetry/events/version.js +2 -2
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"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 { getParserOptions } from './options'\nimport { eventSwcLoadFailure } from '../../telemetry/events/swc-load-failure'\nimport { patchIncorrectLockfile } from '../../lib/patch-incorrect-lockfile'\nimport { downloadNativeNextSwc, downloadWasmSwc } from '../../lib/download-swc'\nimport type { NextConfigComplete } from '../../server/config-shared'\nimport { type DefineEnvOptions, getDefineEnv } from '../define-env'\nimport type {\n NapiPartialProjectOptions,\n NapiProjectOptions,\n NapiSourceDiagnostic,\n} from './generated-native'\nimport type {\n Binding,\n CompilationEvent,\n DefineEnv,\n Endpoint,\n HmrIdentifiers,\n Lockfile,\n Project,\n ProjectOptions,\n RawEntrypoints,\n Route,\n TurboEngineOptions,\n TurbopackResult,\n TurbopackStackFrame,\n Update,\n UpdateMessage,\n WrittenEndpoint,\n} from './types'\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 `Trying to load next-swc for target triple ${rawTargetTriple}, but there next-swc does not have native bindings support`\n )\n } else {\n Log.warn(\n `Trying to load next-swc for unsupported platforms ${PlatformName}/${ArchName}`\n )\n }\n\n return []\n})()\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 calls to `loadBindings`\nlet pendingBindings: Promise<Binding>\n// some things call `loadNative` directly instead of `loadBindings`... Cache calls to that\n// separately.\nlet nativeBindings: Binding\n// can allow hacky sync access to bindings for loadBindingsSync\nlet wasmBindings: Binding\nlet downloadWasmPromise: any\nlet swcTraceFlushGuard: any\nlet downloadNativeBindingsPromise: Promise<void> | undefined = undefined\n\nexport const lockfilePatchPromise: { cur?: Promise<void> } = {}\n\n/**\n * Attempts to load a 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 (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 = patchIncorrectLockfile(process.cwd()).catch(\n console.error\n )\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 logLoadFailure(attempts, true)\n })\n return pendingBindings\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 = 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 // @ts-expect-error TODO: this event has a wrong type.\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 = downloadWasmSwc(nextVersion, wasmDirectory)\n }\n await downloadWasmPromise\n let bindings = await loadWasm(wasmDirectory)\n // @ts-expect-error TODO: this event has a wrong type.\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() {\n let attempts: any[] = []\n try {\n return loadNative()\n } catch (a) {\n attempts = attempts.concat(a)\n }\n\n // HACK: we can leverage the wasm bindings if they are already loaded\n // this may introduce race conditions\n if (wasmBindings) {\n return wasmBindings\n }\n\n logLoadFailure(attempts)\n throw new Error('Failed to load bindings', { cause: attempts })\n}\n\nlet loggingLoadFailure = false\n\nfunction 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 // @ts-expect-error TODO: this event has a wrong type.\n eventSwcLoadFailure({\n wasm: triedWasm ? 'failed' : undefined,\n nativeBindingsErrorCode: lastNativeBindingsLoadErrorCode,\n })\n .then(() => lockfilePatchPromise.cur || Promise.resolve())\n .finally(() => {\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 process.exit(1)\n })\n}\n\ntype RustifiedEnv = { name: string; value: string }[]\ntype RustifiedOptionEnv = { name: string; value: string | undefined }[]\n\nexport function createDefineEnv({\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 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\n// TODO(sokra) Support wasm option.\nfunction bindingToApi(\n binding: RawBindings,\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: Partial<ProjectOptions>\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\n async update(options: Partial<ProjectOptions>) {\n await binding.projectUpdate(\n this._nativeProject,\n await rustifyPartialProjectOptions(options)\n )\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(identifier: string) {\n return subscribe<TurbopackResult<Update>>(true, async (callback) =>\n binding.projectHmrEvents(this._nativeProject, identifier, callback)\n )\n }\n\n hmrIdentifiersSubscribe() {\n return subscribe<TurbopackResult<HmrIdentifiers>>(\n false,\n async (callback) =>\n binding.projectHmrIdentifiersSubscribe(this._nativeProject, callback)\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 nextConfigSerializable.generateBuildId =\n await nextConfigSerializable.generateBuildId?.()\n\n // TODO: these functions takes arguments, have to be supported in a different way\n nextConfigSerializable.exportPathMap = {}\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 // loaderFile is an absolute path, we need it to be relative.\n if (nextConfigSerializable.images.loaderFile) {\n nextConfigSerializable.images = {\n ...nextConfigSerializable.images,\n loaderFile:\n './' +\n path.relative(projectPath, nextConfigSerializable.images.loaderFile),\n }\n }\n\n // cacheHandler can be an absolute path, we need it to be relative.\n if (nextConfigSerializable.cacheHandler) {\n nextConfigSerializable.cacheHandler =\n './' +\n (path.isAbsolute(nextConfigSerializable.cacheHandler)\n ? path.relative(projectPath, nextConfigSerializable.cacheHandler)\n : nextConfigSerializable.cacheHandler)\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 (path.isAbsolute(value)\n ? path.relative(projectPath, value)\n : value),\n ])\n )\n }\n\n return JSON.stringify(nextConfigSerializable, null, 2)\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 ) {\n return new ProjectImpl(\n await binding.projectNew(\n await rustifyProjectOptions(options),\n turboEngineOptions || {},\n {} as any\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 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 },\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 ): Promise<Project> {\n throw new Error(\n '`turbo.createProject` is not supported by the wasm bindings.'\n )\n },\n startTurbopackTraceServer(\n _traceFilePath: string,\n _port: number | undefined\n ): void {\n throw new Error(\n '`turbo.startTurbopackTraceServer` is not supported by the wasm 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 lockfileTryAcquire(_filePath: string) {\n throw new Error(\n '`lockfileTryAcquire` is not supported by the wasm bindings.'\n )\n },\n lockfileTryAcquireSync(_filePath: string) {\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) {\n if (nativeBindings) {\n return nativeBindings\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 customBindings: RawBindings | null = null\n let bindings: RawBindings | null = customBindings\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 // Use the binary directly to skip `pnpm pack` for testing as it's slow because of the large native binary.\n bindings = require(\n `${NEXT_TEST_NATIVE_DIR}/next-swc.${triple.platformArchABI}.node`\n )\n infoLog(\n 'next-swc build: local built @next/swc from NEXT_TEST_NATIVE_DIR'\n )\n break\n } catch (e) {}\n } else {\n try {\n bindings = require(\n `@next/swc/native/next-swc.${triple.platformArchABI}.node`\n )\n infoLog('next-swc build: local built @next/swc')\n break\n } catch (e) {}\n }\n }\n\n if (!bindings) {\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 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 nativeBindings = {\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(customBindings ?? bindings, false),\n startTurbopackTraceServer: bindings.startTurbopackTraceServer,\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 },\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) {\n return bindings.lockfileTryAcquire(filePath)\n },\n lockfileTryAcquireSync(filePath: string) {\n return bindings.lockfileTryAcquireSync(filePath)\n },\n lockfileUnlock(lockfile: Lockfile) {\n return bindings.lockfileUnlock(lockfile)\n },\n lockfileUnlockSync(lockfile: Lockfile) {\n return bindings.lockfileUnlockSync(lockfile)\n },\n }\n return nativeBindings\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 isWasm(): Promise<boolean> {\n let bindings = await loadBindings()\n return bindings.isWasm\n}\n\nexport async function transform(src: string, options?: any): Promise<any> {\n let bindings = await loadBindings()\n return bindings.transform(src, options)\n}\n\nexport function transformSync(src: string, options?: any): any {\n let bindings = loadBindingsSync()\n return bindings.transformSync(src, options)\n}\n\nexport async function minify(\n src: string,\n options: any\n): Promise<{ code: string; map: any }> {\n let bindings = await loadBindings()\n return bindings.minify(src, options)\n}\n\nexport async function isReactCompilerRequired(\n filename: string\n): Promise<boolean> {\n let bindings = await loadBindings()\n return bindings.reactCompiler.isReactCompilerRequired(filename)\n}\n\nexport async function parse(src: string, options: any): Promise<any> {\n let bindings = await loadBindings()\n let parserOptions = getParserOptions(options)\n return bindings\n .parse(src, parserOptions)\n .then((astStr: any) => JSON.parse(astStr))\n}\n\nexport function getBinaryMetadata() {\n let bindings\n try {\n bindings = loadNative()\n } catch (e) {\n // Suppress exceptions, this fn allows to fail to load native bindings\n }\n\n return {\n target: bindings?.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 let bindings = loadNative()\n swcTraceFlushGuard = bindings.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 let bindings = loadNative()\n if (swcTraceFlushGuard) {\n bindings.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 const bindings = await loadBindings()\n return bindings.rspack.getModuleNamedExports(resourcePath)\n}\n\nexport async function warnForEdgeRuntime(\n source: string,\n isProduction: boolean\n): Promise<NapiSourceDiagnostic[]> {\n const bindings = await loadBindings()\n return bindings.rspack.warnForEdgeRuntime(source, isProduction)\n}\n"],"names":["path","pathToFileURL","arch","platform","platformArchTriples","Log","getParserOptions","eventSwcLoadFailure","patchIncorrectLockfile","downloadNativeNextSwc","downloadWasmSwc","getDefineEnv","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","checkVersionMismatch","pkgData","version","knownDefaultWasmFallbackTriples","lastNativeBindingsLoadErrorCode","undefined","pendingBindings","nativeBindings","wasmBindings","downloadWasmPromise","swcTraceFlushGuard","downloadNativeBindingsPromise","lockfilePatchPromise","loadBindings","useWasmBinary","RUST_MIN_STACK","NEXT_TEST_WASM","stdout","_handle","setBlocking","stderr","Promise","resolve","_reject","cur","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","require","map","platformArchABI","push","bindings","loadWasm","wasm","nativeBindingsErrorCode","wasmDirectory","attempt","loadBindingsSync","Error","cause","loggingLoadFailure","triedWasm","then","finally","exit","createDefineEnv","clientRouterFilters","config","dev","distDir","projectPath","fetchCacheKeyPrefix","hasRewrites","middlewareMatchers","rewrites","defineEnv","client","edge","nodejs","variant","Object","keys","rustifyOptionEnv","isClient","isEdgeServer","isNodeServer","rustifyEnv","entries","_","value","name","bindingToApi","binding","_wasm","cancel","Cancel","invariant","never","computeMessage","subscribe","useBuffer","nativeFunction","buffer","waiting","canceled","emitResult","err","reject","item","createIterator","task","length","shift","e","rootTaskDispose","iterator","return","done","rustifyProjectOptions","options","nextConfig","serializeNextConfig","rootPath","rustifyPartialProjectOptions","ProjectImpl","constructor","nativeProject","_nativeProject","update","projectUpdate","writeAllEntrypointsToDisk","appDirOnly","napiEndpoints","projectWriteAllEntrypointsToDisk","napiEntrypointsToRawEntrypoints","issues","diagnostics","entrypointsSubscribe","subscription","callback","projectEntrypointsSubscribe","entrypoints","hmrEvents","identifier","projectHmrEvents","hmrIdentifiersSubscribe","projectHmrIdentifiersSubscribe","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","generateBuildId","exportPathMap","webpack","modularizeImports","fromEntries","mod","transform","images","loaderFile","relative","cacheHandler","isAbsolute","cacheHandlers","key","JSON","stringify","routes","Map","pathname","nativeRoute","route","routeType","type","htmlEndpoint","dataEndpoint","endpoint","pages","page","originalName","rscEndpoint","_exhaustiveCheck","set","napiMiddlewareToMiddleware","middleware","isProxy","napiInstrumentationToInstrumentation","instrumentation","nodeJs","pagesDocumentEndpoint","pagesAppEndpoint","pagesErrorEndpoint","createProject","turboEngineOptions","projectNew","loadWasmRawBindings","importPath","testWasmDir","NEXT_TEST_WASM_DIR","rawBindings","toString","pkg","pkgPath","importedRawBindings","default","code","message","removeUndefined","obj","newObj","k","v","css","lightning","_options","transformStyleAttr","isWasm","src","transformSync","minify","minifySync","parse","getTargetTriple","turbo","_turboEngineOptions","startTurbopackTraceServer","_traceFilePath","_port","mdx","compile","mdxCompile","getMdxOptions","compileSync","mdxCompileSync","reactCompiler","isReactCompilerRequired","_filename","rspack","getModuleNamedExports","_resourcePath","warnForEdgeRuntime","_source","_isProduction","expandNextJsTemplate","content","templatePath","nextPackageDirPath","replacements","injections","imports","lockfileTryAcquire","_filePath","lockfileTryAcquireSync","lockfileUnlock","_lockfile","lockfileUnlockSync","customBindings","NEXT_TEST_NATIVE_DIR","isModule","Buffer","isBuffer","jsc","parser","syntax","toBuffer","from","initCustomTraceSubscriber","teardownTraceSubscriber","transformOptions","lightningCssTransform","transformAttrOptions","lightningCssTransformStyleAttribute","filename","resourcePath","source","isProduction","lockfile","development","jsx","mdxType","t","parserOptions","astStr","getBinaryMetadata","target","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;AACpC,SAASC,gBAAgB,QAAQ,YAAW;AAC5C,SAASC,mBAAmB,QAAQ,0CAAyC;AAC7E,SAASC,sBAAsB,QAAQ,qCAAoC;AAC3E,SAASC,qBAAqB,EAAEC,eAAe,QAAQ,yBAAwB;AAE/E,SAAgCC,YAAY,QAAQ,gBAAe;AA8BnE,MAAMC,cAAcC,QAAQC,GAAG,CAACC,cAAc;AAE9C,MAAMC,WAAWd;AACjB,MAAMe,eAAed;AAErB,SAASe,QAAQ,GAAGC,IAAW;IAC7B,IAAIN,QAAQC,GAAG,CAACM,yBAAyB,EAAE;QACzC;IACF;IACA,IAAIP,QAAQC,GAAG,CAACO,KAAK,EAAE;QACrBhB,IAAIiB,IAAI,IAAIH;IACd;AACF;AAEA;;CAEC,GACD,OAAO,SAASI;IACd,MAAM,EAAEC,MAAM,EAAEC,KAAK,EAAEC,KAAK,EAAEC,OAAO,EAAEC,OAAO,EAAE,GAAGxB;IAEnD,OAAO;QACLoB;QACAC,OAAO;YACLI,OAAOJ,MAAMI,KAAK;YAClBC,MAAML,MAAMK,IAAI,CAACC,MAAM,CAAC,CAACC,SAAWA,OAAOC,GAAG,KAAK;YACnDC,KAAKT,MAAMS,GAAG,CAACH,MAAM,CAAC,CAACC,SAAWA,OAAOC,GAAG,KAAK;QACnD;QACAP,OAAO;YACL,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IAC1C,IAAI;QACF,IAAI5Q,WAAWhB;QACf,IAAIhC,oBAAoB;YACtBgD,SAASyP,uBAAuB,oBAAhCzP,SAASyP,uBAAuB,MAAhCzP,UAAmChD;QACrC;IACF,EAAE,OAAO8G,GAAG;IACV,sEAAsE;IACxE;AACF,GAAE;AAEF,OAAO,eAAe8J,sBACpBmC,YAAoB;IAEpB,MAAM/P,WAAW,MAAM7C;IACvB,OAAO6C,SAAS2N,MAAM,CAACC,qBAAqB,CAACmC;AAC/C;AAEA,OAAO,eAAejC,mBACpBkC,MAAc,EACdC,YAAqB;IAErB,MAAMjQ,WAAW,MAAM7C;IACvB,OAAO6C,SAAS2N,MAAM,CAACG,kBAAkB,CAACkC,QAAQC;AACpD","ignoreList":[0]}
|
|
1
|
+
{"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 { getParserOptions } from './options'\nimport { eventSwcLoadFailure } from '../../telemetry/events/swc-load-failure'\nimport { patchIncorrectLockfile } from '../../lib/patch-incorrect-lockfile'\nimport { downloadNativeNextSwc, downloadWasmSwc } from '../../lib/download-swc'\nimport type { NextConfigComplete } from '../../server/config-shared'\nimport { type DefineEnvOptions, getDefineEnv } from '../define-env'\nimport type {\n NapiPartialProjectOptions,\n NapiProjectOptions,\n NapiSourceDiagnostic,\n} from './generated-native'\nimport type {\n Binding,\n CompilationEvent,\n DefineEnv,\n Endpoint,\n HmrIdentifiers,\n Lockfile,\n Project,\n ProjectOptions,\n RawEntrypoints,\n Route,\n TurboEngineOptions,\n TurbopackResult,\n TurbopackStackFrame,\n Update,\n UpdateMessage,\n WrittenEndpoint,\n} from './types'\n\ntype RawBindings = typeof import('./generated-native')\ntype RawWasmBindings = typeof import('./generated-wasm') & {\n default?(): Promise<typeof import('./generated-wasm')>\n}\n\n// Use a fixed version for SWC binary downloads (official Next.js version)\n// This allows the fork to use official SWC binaries\nconst nextVersion = '16.0.0'\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 `Trying to load next-swc for target triple ${rawTargetTriple}, but there next-swc does not have native bindings support`\n )\n } else {\n Log.warn(\n `Trying to load next-swc for unsupported platforms ${PlatformName}/${ArchName}`\n )\n }\n\n return []\n})()\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 calls to `loadBindings`\nlet pendingBindings: Promise<Binding>\n// some things call `loadNative` directly instead of `loadBindings`... Cache calls to that\n// separately.\nlet nativeBindings: Binding\n// can allow hacky sync access to bindings for loadBindingsSync\nlet wasmBindings: Binding\nlet downloadWasmPromise: any\nlet swcTraceFlushGuard: any\nlet downloadNativeBindingsPromise: Promise<void> | undefined = undefined\n\nexport const lockfilePatchPromise: { cur?: Promise<void> } = {}\n\n/**\n * Attempts to load a 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 (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 = patchIncorrectLockfile(process.cwd()).catch(\n console.error\n )\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 logLoadFailure(attempts, true)\n })\n return pendingBindings\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 = 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 // @ts-expect-error TODO: this event has a wrong type.\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 = downloadWasmSwc(nextVersion, wasmDirectory)\n }\n await downloadWasmPromise\n let bindings = await loadWasm(wasmDirectory)\n // @ts-expect-error TODO: this event has a wrong type.\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() {\n let attempts: any[] = []\n try {\n return loadNative()\n } catch (a) {\n attempts = attempts.concat(a)\n }\n\n // HACK: we can leverage the wasm bindings if they are already loaded\n // this may introduce race conditions\n if (wasmBindings) {\n return wasmBindings\n }\n\n logLoadFailure(attempts)\n throw new Error('Failed to load bindings', { cause: attempts })\n}\n\nlet loggingLoadFailure = false\n\nfunction 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 // @ts-expect-error TODO: this event has a wrong type.\n eventSwcLoadFailure({\n wasm: triedWasm ? 'failed' : undefined,\n nativeBindingsErrorCode: lastNativeBindingsLoadErrorCode,\n })\n .then(() => lockfilePatchPromise.cur || Promise.resolve())\n .finally(() => {\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 process.exit(1)\n })\n}\n\ntype RustifiedEnv = { name: string; value: string }[]\ntype RustifiedOptionEnv = { name: string; value: string | undefined }[]\n\nexport function createDefineEnv({\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 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\n// TODO(sokra) Support wasm option.\nfunction bindingToApi(\n binding: RawBindings,\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: Partial<ProjectOptions>\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\n async update(options: Partial<ProjectOptions>) {\n await binding.projectUpdate(\n this._nativeProject,\n await rustifyPartialProjectOptions(options)\n )\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(identifier: string) {\n return subscribe<TurbopackResult<Update>>(true, async (callback) =>\n binding.projectHmrEvents(this._nativeProject, identifier, callback)\n )\n }\n\n hmrIdentifiersSubscribe() {\n return subscribe<TurbopackResult<HmrIdentifiers>>(\n false,\n async (callback) =>\n binding.projectHmrIdentifiersSubscribe(this._nativeProject, callback)\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 nextConfigSerializable.generateBuildId =\n await nextConfigSerializable.generateBuildId?.()\n\n // TODO: these functions takes arguments, have to be supported in a different way\n nextConfigSerializable.exportPathMap = {}\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 // loaderFile is an absolute path, we need it to be relative.\n if (nextConfigSerializable.images.loaderFile) {\n nextConfigSerializable.images = {\n ...nextConfigSerializable.images,\n loaderFile:\n './' +\n path.relative(projectPath, nextConfigSerializable.images.loaderFile),\n }\n }\n\n // cacheHandler can be an absolute path, we need it to be relative.\n if (nextConfigSerializable.cacheHandler) {\n nextConfigSerializable.cacheHandler =\n './' +\n (path.isAbsolute(nextConfigSerializable.cacheHandler)\n ? path.relative(projectPath, nextConfigSerializable.cacheHandler)\n : nextConfigSerializable.cacheHandler)\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 (path.isAbsolute(value)\n ? path.relative(projectPath, value)\n : value),\n ])\n )\n }\n\n return JSON.stringify(nextConfigSerializable, null, 2)\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 ) {\n return new ProjectImpl(\n await binding.projectNew(\n await rustifyProjectOptions(options),\n turboEngineOptions || {},\n {} as any\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 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 },\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 ): Promise<Project> {\n throw new Error(\n '`turbo.createProject` is not supported by the wasm bindings.'\n )\n },\n startTurbopackTraceServer(\n _traceFilePath: string,\n _port: number | undefined\n ): void {\n throw new Error(\n '`turbo.startTurbopackTraceServer` is not supported by the wasm 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 lockfileTryAcquire(_filePath: string) {\n throw new Error(\n '`lockfileTryAcquire` is not supported by the wasm bindings.'\n )\n },\n lockfileTryAcquireSync(_filePath: string) {\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) {\n if (nativeBindings) {\n return nativeBindings\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 customBindings: RawBindings | null = null\n let bindings: RawBindings | null = customBindings\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 // Use the binary directly to skip `pnpm pack` for testing as it's slow because of the large native binary.\n bindings = require(\n `${NEXT_TEST_NATIVE_DIR}/next-swc.${triple.platformArchABI}.node`\n )\n infoLog(\n 'next-swc build: local built @next/swc from NEXT_TEST_NATIVE_DIR'\n )\n break\n } catch (e) {}\n } else {\n try {\n bindings = require(\n `@next/swc/native/next-swc.${triple.platformArchABI}.node`\n )\n infoLog('next-swc build: local built @next/swc')\n break\n } catch (e) {}\n }\n }\n\n if (!bindings) {\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 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 nativeBindings = {\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(customBindings ?? bindings, false),\n startTurbopackTraceServer: bindings.startTurbopackTraceServer,\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 },\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) {\n return bindings.lockfileTryAcquire(filePath)\n },\n lockfileTryAcquireSync(filePath: string) {\n return bindings.lockfileTryAcquireSync(filePath)\n },\n lockfileUnlock(lockfile: Lockfile) {\n return bindings.lockfileUnlock(lockfile)\n },\n lockfileUnlockSync(lockfile: Lockfile) {\n return bindings.lockfileUnlockSync(lockfile)\n },\n }\n return nativeBindings\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 isWasm(): Promise<boolean> {\n let bindings = await loadBindings()\n return bindings.isWasm\n}\n\nexport async function transform(src: string, options?: any): Promise<any> {\n let bindings = await loadBindings()\n return bindings.transform(src, options)\n}\n\nexport function transformSync(src: string, options?: any): any {\n let bindings = loadBindingsSync()\n return bindings.transformSync(src, options)\n}\n\nexport async function minify(\n src: string,\n options: any\n): Promise<{ code: string; map: any }> {\n let bindings = await loadBindings()\n return bindings.minify(src, options)\n}\n\nexport async function isReactCompilerRequired(\n filename: string\n): Promise<boolean> {\n let bindings = await loadBindings()\n return bindings.reactCompiler.isReactCompilerRequired(filename)\n}\n\nexport async function parse(src: string, options: any): Promise<any> {\n let bindings = await loadBindings()\n let parserOptions = getParserOptions(options)\n return bindings\n .parse(src, parserOptions)\n .then((astStr: any) => JSON.parse(astStr))\n}\n\nexport function getBinaryMetadata() {\n let bindings\n try {\n bindings = loadNative()\n } catch (e) {\n // Suppress exceptions, this fn allows to fail to load native bindings\n }\n\n return {\n target: bindings?.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 let bindings = loadNative()\n swcTraceFlushGuard = bindings.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 let bindings = loadNative()\n if (swcTraceFlushGuard) {\n bindings.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 const bindings = await loadBindings()\n return bindings.rspack.getModuleNamedExports(resourcePath)\n}\n\nexport async function warnForEdgeRuntime(\n source: string,\n isProduction: boolean\n): Promise<NapiSourceDiagnostic[]> {\n const bindings = await loadBindings()\n return bindings.rspack.warnForEdgeRuntime(source, isProduction)\n}\n"],"names":["path","pathToFileURL","arch","platform","platformArchTriples","Log","getParserOptions","eventSwcLoadFailure","patchIncorrectLockfile","downloadNativeNextSwc","downloadWasmSwc","getDefineEnv","nextVersion","ArchName","PlatformName","infoLog","args","process","env","NEXT_PRIVATE_BUILD_WORKER","DEBUG","info","getSupportedArchTriples","darwin","win32","linux","freebsd","android","arm64","ia32","filter","triple","abi","x64","arm","triples","supportedArchTriples","targetTriple","rawTargetTriple","warn","checkVersionMismatch","pkgData","version","knownDefaultWasmFallbackTriples","lastNativeBindingsLoadErrorCode","undefined","pendingBindings","nativeBindings","wasmBindings","downloadWasmPromise","swcTraceFlushGuard","downloadNativeBindingsPromise","lockfilePatchPromise","loadBindings","useWasmBinary","RUST_MIN_STACK","NEXT_TEST_WASM","stdout","_handle","setBlocking","stderr","Promise","resolve","_reject","cur","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","require","map","platformArchABI","push","bindings","loadWasm","wasm","nativeBindingsErrorCode","wasmDirectory","attempt","loadBindingsSync","Error","cause","loggingLoadFailure","triedWasm","then","finally","exit","createDefineEnv","clientRouterFilters","config","dev","distDir","projectPath","fetchCacheKeyPrefix","hasRewrites","middlewareMatchers","rewrites","defineEnv","client","edge","nodejs","variant","Object","keys","rustifyOptionEnv","isClient","isEdgeServer","isNodeServer","rustifyEnv","entries","_","value","name","bindingToApi","binding","_wasm","cancel","Cancel","invariant","never","computeMessage","subscribe","useBuffer","nativeFunction","buffer","waiting","canceled","emitResult","err","reject","item","createIterator","task","length","shift","e","rootTaskDispose","iterator","return","done","rustifyProjectOptions","options","nextConfig","serializeNextConfig","rootPath","rustifyPartialProjectOptions","ProjectImpl","constructor","nativeProject","_nativeProject","update","projectUpdate","writeAllEntrypointsToDisk","appDirOnly","napiEndpoints","projectWriteAllEntrypointsToDisk","napiEntrypointsToRawEntrypoints","issues","diagnostics","entrypointsSubscribe","subscription","callback","projectEntrypointsSubscribe","entrypoints","hmrEvents","identifier","projectHmrEvents","hmrIdentifiersSubscribe","projectHmrIdentifiersSubscribe","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","generateBuildId","exportPathMap","webpack","modularizeImports","fromEntries","mod","transform","images","loaderFile","relative","cacheHandler","isAbsolute","cacheHandlers","key","JSON","stringify","routes","Map","pathname","nativeRoute","route","routeType","type","htmlEndpoint","dataEndpoint","endpoint","pages","page","originalName","rscEndpoint","_exhaustiveCheck","set","napiMiddlewareToMiddleware","middleware","isProxy","napiInstrumentationToInstrumentation","instrumentation","nodeJs","pagesDocumentEndpoint","pagesAppEndpoint","pagesErrorEndpoint","createProject","turboEngineOptions","projectNew","loadWasmRawBindings","importPath","testWasmDir","NEXT_TEST_WASM_DIR","rawBindings","toString","pkg","pkgPath","importedRawBindings","default","code","message","removeUndefined","obj","newObj","k","v","css","lightning","_options","transformStyleAttr","isWasm","src","transformSync","minify","minifySync","parse","getTargetTriple","turbo","_turboEngineOptions","startTurbopackTraceServer","_traceFilePath","_port","mdx","compile","mdxCompile","getMdxOptions","compileSync","mdxCompileSync","reactCompiler","isReactCompilerRequired","_filename","rspack","getModuleNamedExports","_resourcePath","warnForEdgeRuntime","_source","_isProduction","expandNextJsTemplate","content","templatePath","nextPackageDirPath","replacements","injections","imports","lockfileTryAcquire","_filePath","lockfileTryAcquireSync","lockfileUnlock","_lockfile","lockfileUnlockSync","customBindings","NEXT_TEST_NATIVE_DIR","isModule","Buffer","isBuffer","jsc","parser","syntax","toBuffer","from","initCustomTraceSubscriber","teardownTraceSubscriber","transformOptions","lightningCssTransform","transformAttrOptions","lightningCssTransformStyleAttribute","filename","resourcePath","source","isProduction","lockfile","development","jsx","mdxType","t","parserOptions","astStr","getBinaryMetadata","target","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;AACpC,SAASC,gBAAgB,QAAQ,YAAW;AAC5C,SAASC,mBAAmB,Q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oreList":[0]}
|
|
@@ -1610,7 +1610,7 @@ export default async function getBaseWebpackConfig(dir, { buildId, encryptionKey
|
|
|
1610
1610
|
isClient && new CopyFilePlugin({
|
|
1611
1611
|
// file path to build output of `@next/polyfill-nomodule`
|
|
1612
1612
|
filePath: require.resolve('./polyfills/polyfill-nomodule'),
|
|
1613
|
-
cacheKey: "16.0.
|
|
1613
|
+
cacheKey: "16.0.12",
|
|
1614
1614
|
name: `static/chunks/polyfills${dev ? '' : '-[hash]'}.js`,
|
|
1615
1615
|
minimize: false,
|
|
1616
1616
|
info: {
|
|
@@ -1801,7 +1801,7 @@ export default async function getBaseWebpackConfig(dir, { buildId, encryptionKey
|
|
|
1801
1801
|
// - Next.js location on disk (some loaders use absolute paths and some resolve options depend on absolute paths)
|
|
1802
1802
|
// - Next.js version
|
|
1803
1803
|
// - next.config.js keys that affect compilation
|
|
1804
|
-
version: `${__dirname}|${"16.0.
|
|
1804
|
+
version: `${__dirname}|${"16.0.12"}|${configVars}`,
|
|
1805
1805
|
cacheDirectory: path.join(distDir, 'cache', 'webpack'),
|
|
1806
1806
|
// For production builds, it's more efficient to compress all cache files together instead of compression each one individually.
|
|
1807
1807
|
// So we disable compression here and allow the build runner to take care of compressing the cache as a whole.
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* - next/script with `beforeInteractive` strategy
|
|
6
6
|
*/ import { getAssetPrefix } from './asset-prefix';
|
|
7
7
|
import { setAttributesFromProps } from './set-attributes-from-props';
|
|
8
|
-
const version = "16.0.
|
|
8
|
+
const version = "16.0.12";
|
|
9
9
|
window.next = {
|
|
10
10
|
version,
|
|
11
11
|
appDir: true
|
package/dist/esm/client/index.js
CHANGED
|
@@ -25,7 +25,7 @@ import { SearchParamsContext, PathParamsContext } from '../shared/lib/hooks-clie
|
|
|
25
25
|
import { onRecoverableError } from './react-client-callbacks/on-recoverable-error';
|
|
26
26
|
import tracer from './tracing/tracer';
|
|
27
27
|
import { isNextRouterError } from './components/is-next-router-error';
|
|
28
|
-
export const version = "16.0.
|
|
28
|
+
export const version = "16.0.12";
|
|
29
29
|
export let router;
|
|
30
30
|
export const emitter = mitt();
|
|
31
31
|
const looseToArray = (input)=>[].slice.call(input);
|
|
@@ -58,6 +58,14 @@ export async function verifyTypeScriptSetup({ dir, distDir, cacheDir, intentDirs
|
|
|
58
58
|
}
|
|
59
59
|
// Load TypeScript after we're sure it exists:
|
|
60
60
|
const tsPackageJsonPath = deps.resolved.get(join('typescript', 'package.json'));
|
|
61
|
+
// Bun compatibility: handle undefined path
|
|
62
|
+
if (!tsPackageJsonPath) {
|
|
63
|
+
throw Object.defineProperty(new Error('TypeScript package.json not found in resolved dependencies'), "__NEXT_ERROR_CODE", {
|
|
64
|
+
value: "E915",
|
|
65
|
+
enumerable: false,
|
|
66
|
+
configurable: true
|
|
67
|
+
});
|
|
68
|
+
}
|
|
61
69
|
const typescriptPackageJson = require(tsPackageJsonPath);
|
|
62
70
|
const typescriptVersion = typescriptPackageJson.version;
|
|
63
71
|
if (semver.lt(typescriptVersion, '5.1.0')) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../../../src/lib/verify-typescript-setup.ts"],"sourcesContent":["import { bold, cyan, red, yellow } from './picocolors'\nimport path, { join } from 'path'\n\nimport { hasNecessaryDependencies } from './has-necessary-dependencies'\nimport type { NecessaryDependencies } from './has-necessary-dependencies'\nimport semver from 'next/dist/compiled/semver'\nimport { CompileError } from './compile-error'\nimport * as log from '../build/output/log'\n\nimport { getTypeScriptIntent } from './typescript/getTypeScriptIntent'\nimport type { TypeCheckResult } from './typescript/runTypeCheck'\nimport { writeAppTypeDeclarations } from './typescript/writeAppTypeDeclarations'\nimport { writeConfigurationDefaults } from './typescript/writeConfigurationDefaults'\nimport { installDependencies } from './install-dependencies'\nimport { isCI } from '../server/ci-info'\nimport { missingDepsError } from './typescript/missingDependencyError'\n\nconst requiredPackages = [\n {\n file: 'typescript/lib/typescript.js',\n pkg: 'typescript',\n exportsRestrict: true,\n },\n {\n file: '@types/react/index.d.ts',\n pkg: '@types/react',\n exportsRestrict: true,\n },\n {\n file: '@types/node/index.d.ts',\n pkg: '@types/node',\n exportsRestrict: true,\n },\n]\n\nexport async function verifyTypeScriptSetup({\n dir,\n distDir,\n cacheDir,\n intentDirs,\n tsconfigPath,\n typeCheckPreflight,\n disableStaticImages,\n hasAppDir,\n hasPagesDir,\n isolatedDevBuild,\n}: {\n dir: string\n distDir: string\n cacheDir?: string\n tsconfigPath: string | undefined\n intentDirs: string[]\n typeCheckPreflight: boolean\n disableStaticImages: boolean\n hasAppDir: boolean\n hasPagesDir: boolean\n isolatedDevBuild: boolean | undefined\n}): Promise<{ result?: TypeCheckResult; version: string | null }> {\n const tsConfigFileName = tsconfigPath || 'tsconfig.json'\n const resolvedTsConfigPath = path.join(dir, tsConfigFileName)\n\n try {\n // Check if the project uses TypeScript:\n const intent = await getTypeScriptIntent(dir, intentDirs, tsConfigFileName)\n if (!intent) {\n return { version: null }\n }\n\n // Ensure TypeScript and necessary `@types/*` are installed:\n let deps: NecessaryDependencies = hasNecessaryDependencies(\n dir,\n requiredPackages\n )\n\n if (deps.missing?.length > 0) {\n if (isCI) {\n // we don't attempt auto install in CI to avoid side-effects\n // and instead log the error for installing needed packages\n missingDepsError(dir, deps.missing)\n }\n console.log(\n bold(\n yellow(\n `It looks like you're trying to use TypeScript but do not have the required package(s) installed.`\n )\n ) +\n '\\n' +\n 'Installing dependencies' +\n '\\n\\n' +\n bold(\n 'If you are not trying to use TypeScript, please remove the ' +\n cyan('tsconfig.json') +\n ' file from your package root (and any TypeScript files in your app and pages directories).'\n ) +\n '\\n'\n )\n await installDependencies(dir, deps.missing, true).catch((err) => {\n if (err && typeof err === 'object' && 'command' in err) {\n console.error(\n `Failed to install required TypeScript dependencies, please install them manually to continue:\\n` +\n (err as any).command +\n '\\n'\n )\n }\n throw err\n })\n deps = hasNecessaryDependencies(dir, requiredPackages)\n }\n\n // Load TypeScript after we're sure it exists:\n const tsPackageJsonPath = deps.resolved.get(\n join('typescript', 'package.json')\n )!\n const typescriptPackageJson = require(tsPackageJsonPath)\n\n const typescriptVersion = typescriptPackageJson.version\n\n if (semver.lt(typescriptVersion, '5.1.0')) {\n log.warn(\n `Minimum recommended TypeScript version is v5.1.0, older versions can potentially be incompatible with Next.js. Detected: ${typescriptVersion}`\n )\n }\n\n // Reconfigure (or create) the user's `tsconfig.json` for them:\n await writeConfigurationDefaults(\n typescriptVersion,\n resolvedTsConfigPath,\n intent.firstTimeSetup,\n hasAppDir,\n distDir,\n hasPagesDir,\n isolatedDevBuild\n )\n // Write out the necessary `next-env.d.ts` file to correctly register\n // Next.js' types:\n await writeAppTypeDeclarations({\n baseDir: dir,\n distDir,\n imageImportsEnabled: !disableStaticImages,\n hasPagesDir,\n hasAppDir,\n })\n\n let result\n if (typeCheckPreflight) {\n const { runTypeCheck } =\n require('./typescript/runTypeCheck') as typeof import('./typescript/runTypeCheck')\n\n const tsPath = deps.resolved.get('typescript')!\n const typescript = (await Promise.resolve(\n require(tsPath)\n )) as typeof import('typescript')\n\n // Verify the project passes type-checking before we go to webpack phase:\n result = await runTypeCheck(\n typescript,\n dir,\n distDir,\n resolvedTsConfigPath,\n cacheDir,\n hasAppDir\n )\n }\n return { result, version: typescriptVersion }\n } catch (err) {\n // These are special errors that should not show a stack trace:\n if (err instanceof CompileError) {\n console.error(red('Failed to compile.\\n'))\n console.error(err.message)\n process.exit(1)\n }\n\n /**\n * verifyTypeScriptSetup can be either invoked directly in the main thread (during next dev / next lint)\n * or run in a worker (during next build). In the latter case, we need to print the error message, as the\n * parent process will only receive an `Jest worker encountered 1 child process exceptions, exceeding retry limit`.\n */\n\n // we are in a worker, print the error message and exit the process\n if (process.env.IS_NEXT_WORKER) {\n if (err instanceof Error) {\n console.error(err.message)\n } else {\n console.error(err)\n }\n process.exit(1)\n }\n // we are in the main thread, throw the error and it will be handled by the caller\n throw err\n }\n}\n"],"names":["bold","cyan","red","yellow","path","join","hasNecessaryDependencies","semver","CompileError","log","getTypeScriptIntent","writeAppTypeDeclarations","writeConfigurationDefaults","installDependencies","isCI","missingDepsError","requiredPackages","file","pkg","exportsRestrict","verifyTypeScriptSetup","dir","distDir","cacheDir","intentDirs","tsconfigPath","typeCheckPreflight","disableStaticImages","hasAppDir","hasPagesDir","isolatedDevBuild","tsConfigFileName","resolvedTsConfigPath","deps","intent","version","missing","length","console","catch","err","error","command","tsPackageJsonPath","resolved","get","typescriptPackageJson","require","typescriptVersion","lt","warn","firstTimeSetup","baseDir","imageImportsEnabled","result","runTypeCheck","tsPath","typescript","Promise","resolve","message","process","exit","env","IS_NEXT_WORKER","Error"],"mappings":"AAAA,SAASA,IAAI,EAAEC,IAAI,EAAEC,GAAG,EAAEC,MAAM,QAAQ,eAAc;AACtD,OAAOC,QAAQC,IAAI,QAAQ,OAAM;AAEjC,SAASC,wBAAwB,QAAQ,+BAA8B;AAEvE,OAAOC,YAAY,4BAA2B;AAC9C,SAASC,YAAY,QAAQ,kBAAiB;AAC9C,YAAYC,SAAS,sBAAqB;AAE1C,SAASC,mBAAmB,QAAQ,mCAAkC;AAEtE,SAASC,wBAAwB,QAAQ,wCAAuC;AAChF,SAASC,0BAA0B,QAAQ,0CAAyC;AACpF,SAASC,mBAAmB,QAAQ,yBAAwB;AAC5D,SAASC,IAAI,QAAQ,oBAAmB;AACxC,SAASC,gBAAgB,QAAQ,sCAAqC;AAEtE,MAAMC,mBAAmB;IACvB;QACEC,MAAM;QACNC,KAAK;QACLC,iBAAiB;IACnB;IACA;QACEF,MAAM;QACNC,KAAK;QACLC,iBAAiB;IACnB;IACA;QACEF,MAAM;QACNC,KAAK;QACLC,iBAAiB;IACnB;CACD;AAED,OAAO,eAAeC,sBAAsB,EAC1CC,GAAG,EACHC,OAAO,EACPC,QAAQ,EACRC,UAAU,EACVC,YAAY,EACZC,kBAAkB,EAClBC,mBAAmB,EACnBC,SAAS,EACTC,WAAW,EACXC,gBAAgB,EAYjB;IACC,MAAMC,mBAAmBN,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B,MAAMnB,yBAAyB;YAC7ByC,SAAS/B;YACTC;YACA+B,qBAAqB,CAAC1B;YACtBE;YACAD;QACF;QAEA,IAAI0B;QACJ,IAAI5B,oBAAoB;YACtB,MAAM,EAAE6B,YAAY,EAAE,GACpBR,QAAQ;YAEV,MAAMS,SAASvB,KAAKW,QAAQ,CAACC,GAAG,CAAC;YACjC,MAAMY,aAAc,MAAMC,QAAQC,OAAO,CACvCZ,QAAQS;YAGV,yEAAyE;YACzEF,SAAS,MAAMC,aACbE,YACApC,KACAC,SACAU,sBACAT,UACAK;QAEJ;QACA,OAAO;YAAE0B;YAAQnB,SAASa;QAAkB;IAC9C,EAAE,OAAOR,KAAK;QACZ,+DAA+D;QAC/D,IAAIA,eAAehC,cAAc;YAC/B8B,QAAQG,KAAK,CAACvC,IAAI;YAClBoC,QAAQG,KAAK,CAACD,IAAIoB,OAAO;YACzBC,QAAQC,IAAI,CAAC;QACf;QAEA;;;;KAIC,GAED,mEAAmE;QACnE,IAAID,QAAQE,GAAG,CAACC,cAAc,EAAE;YAC9B,IAAIxB,eAAeyB,OAAO;gBACxB3B,QAAQG,KAAK,CAACD,IAAIoB,OAAO;YAC3B,OAAO;gBACLtB,QAAQG,KAAK,CAACD;YAChB;YACAqB,QAAQC,IAAI,CAAC;QACf;QACA,kFAAkF;QAClF,MAAMtB;IACR;AACF","ignoreList":[0]}
|
|
1
|
+
{"version":3,"sources":["../../../src/lib/verify-typescript-setup.ts"],"sourcesContent":["import { bold, cyan, red, yellow } from './picocolors'\nimport path, { join } from 'path'\n\nimport { hasNecessaryDependencies } from './has-necessary-dependencies'\nimport type { NecessaryDependencies } from './has-necessary-dependencies'\nimport semver from 'next/dist/compiled/semver'\nimport { CompileError } from './compile-error'\nimport * as log from '../build/output/log'\n\nimport { getTypeScriptIntent } from './typescript/getTypeScriptIntent'\nimport type { TypeCheckResult } from './typescript/runTypeCheck'\nimport { writeAppTypeDeclarations } from './typescript/writeAppTypeDeclarations'\nimport { writeConfigurationDefaults } from './typescript/writeConfigurationDefaults'\nimport { installDependencies } from './install-dependencies'\nimport { isCI } from '../server/ci-info'\nimport { missingDepsError } from './typescript/missingDependencyError'\n\nconst requiredPackages = [\n {\n file: 'typescript/lib/typescript.js',\n pkg: 'typescript',\n exportsRestrict: true,\n },\n {\n file: '@types/react/index.d.ts',\n pkg: '@types/react',\n exportsRestrict: true,\n },\n {\n file: '@types/node/index.d.ts',\n pkg: '@types/node',\n exportsRestrict: true,\n },\n]\n\nexport async function verifyTypeScriptSetup({\n dir,\n distDir,\n cacheDir,\n intentDirs,\n tsconfigPath,\n typeCheckPreflight,\n disableStaticImages,\n hasAppDir,\n hasPagesDir,\n isolatedDevBuild,\n}: {\n dir: string\n distDir: string\n cacheDir?: string\n tsconfigPath: string | undefined\n intentDirs: string[]\n typeCheckPreflight: boolean\n disableStaticImages: boolean\n hasAppDir: boolean\n hasPagesDir: boolean\n isolatedDevBuild: boolean | undefined\n}): Promise<{ result?: TypeCheckResult; version: string | null }> {\n const tsConfigFileName = tsconfigPath || 'tsconfig.json'\n const resolvedTsConfigPath = path.join(dir, tsConfigFileName)\n\n try {\n // Check if the project uses TypeScript:\n const intent = await getTypeScriptIntent(dir, intentDirs, tsConfigFileName)\n if (!intent) {\n return { version: null }\n }\n\n // Ensure TypeScript and necessary `@types/*` are installed:\n let deps: NecessaryDependencies = hasNecessaryDependencies(\n dir,\n requiredPackages\n )\n\n if (deps.missing?.length > 0) {\n if (isCI) {\n // we don't attempt auto install in CI to avoid side-effects\n // and instead log the error for installing needed packages\n missingDepsError(dir, deps.missing)\n }\n console.log(\n bold(\n yellow(\n `It looks like you're trying to use TypeScript but do not have the required package(s) installed.`\n )\n ) +\n '\\n' +\n 'Installing dependencies' +\n '\\n\\n' +\n bold(\n 'If you are not trying to use TypeScript, please remove the ' +\n cyan('tsconfig.json') +\n ' file from your package root (and any TypeScript files in your app and pages directories).'\n ) +\n '\\n'\n )\n await installDependencies(dir, deps.missing, true).catch((err) => {\n if (err && typeof err === 'object' && 'command' in err) {\n console.error(\n `Failed to install required TypeScript dependencies, please install them manually to continue:\\n` +\n (err as any).command +\n '\\n'\n )\n }\n throw err\n })\n deps = hasNecessaryDependencies(dir, requiredPackages)\n }\n\n // Load TypeScript after we're sure it exists:\n const tsPackageJsonPath = deps.resolved.get(\n join('typescript', 'package.json')\n )\n // Bun compatibility: handle undefined path\n if (!tsPackageJsonPath) {\n throw new Error(\n 'TypeScript package.json not found in resolved dependencies'\n )\n }\n const typescriptPackageJson = require(tsPackageJsonPath)\n\n const typescriptVersion = typescriptPackageJson.version\n\n if (semver.lt(typescriptVersion, '5.1.0')) {\n log.warn(\n `Minimum recommended TypeScript version is v5.1.0, older versions can potentially be incompatible with Next.js. Detected: ${typescriptVersion}`\n )\n }\n\n // Reconfigure (or create) the user's `tsconfig.json` for them:\n await writeConfigurationDefaults(\n typescriptVersion,\n resolvedTsConfigPath,\n intent.firstTimeSetup,\n hasAppDir,\n distDir,\n hasPagesDir,\n isolatedDevBuild\n )\n // Write out the necessary `next-env.d.ts` file to correctly register\n // Next.js' types:\n await writeAppTypeDeclarations({\n baseDir: dir,\n distDir,\n imageImportsEnabled: !disableStaticImages,\n hasPagesDir,\n hasAppDir,\n })\n\n let result\n if (typeCheckPreflight) {\n const { runTypeCheck } =\n require('./typescript/runTypeCheck') as typeof import('./typescript/runTypeCheck')\n\n const tsPath = deps.resolved.get('typescript')!\n const typescript = (await Promise.resolve(\n require(tsPath)\n )) as typeof import('typescript')\n\n // Verify the project passes type-checking before we go to webpack phase:\n result = await runTypeCheck(\n typescript,\n dir,\n distDir,\n resolvedTsConfigPath,\n cacheDir,\n hasAppDir\n )\n }\n return { result, version: typescriptVersion }\n } catch (err) {\n // These are special errors that should not show a stack trace:\n if (err instanceof CompileError) {\n console.error(red('Failed to compile.\\n'))\n console.error(err.message)\n process.exit(1)\n }\n\n /**\n * verifyTypeScriptSetup can be either invoked directly in the main thread (during next dev / next lint)\n * or run in a worker (during next build). In the latter case, we need to print the error message, as the\n * parent process will only receive an `Jest worker encountered 1 child process exceptions, exceeding retry limit`.\n */\n\n // we are in a worker, print the error message and exit the process\n if (process.env.IS_NEXT_WORKER) {\n if (err instanceof Error) {\n console.error(err.message)\n } else {\n console.error(err)\n }\n process.exit(1)\n }\n // we are in the main thread, throw the error and it will be handled by the caller\n throw err\n }\n}\n"],"names":["bold","cyan","red","yellow","path","join","hasNecessaryDependencies","semver","CompileError","log","getTypeScriptIntent","writeAppTypeDeclarations","writeConfigurationDefaults","installDependencies","isCI","missingDepsError","requiredPackages","file","pkg","exportsRestrict","verifyTypeScriptSetup","dir","distDir","cacheDir","intentDirs","tsconfigPath","typeCheckPreflight","disableStaticImages","hasAppDir","hasPagesDir","isolatedDevBuild","tsConfigFileName","resolvedTsConfigPath","deps","intent","version","missing","length","console","catch","err","error","command","tsPackageJsonPath","resolved","get","Error","typescriptPackageJson","require","typescriptVersion","lt","warn","firstTimeSetup","baseDir","imageImportsEnabled","result","runTypeCheck","tsPath","typescript","Promise","resolve","message","process","exit","env","IS_NEXT_WORKER"],"mappings":"AAAA,SAASA,IAAI,EAAEC,IAAI,EAAEC,GAAG,EAAEC,MAAM,QAAQ,eAAc;AACtD,OAAOC,QAAQC,IAAI,QAAQ,OAAM;AAEjC,SAASC,wBAAwB,QAAQ,+BAA8B;AAEvE,OAAOC,YAAY,4BAA2B;AAC9C,SAASC,YAAY,QAAQ,kBAAiB;AAC9C,YAAYC,SAAS,sBAAqB;AAE1C,SAASC,mBAAmB,QAAQ,mCAAkC;AAEtE,SAASC,wBAAwB,QAAQ,wCAAuC;AAChF,SAASC,0BAA0B,QAAQ,0CAAyC;AACpF,SAASC,mBAAmB,QAAQ,yBAAwB;AAC5D,SAASC,IAAI,QAAQ,oBAAmB;AACxC,SAASC,gBAAgB,QAAQ,sCAAqC;AAEtE,MAAMC,mBAAmB;IACvB;QACEC,MAAM;QACNC,KAAK;QACLC,iBAAiB;IACnB;IACA;QACEF,MAAM;QACNC,KAAK;QACLC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|
@@ -163,7 +163,7 @@ export default class HotReloaderWebpack {
|
|
|
163
163
|
this.previewProps = previewProps;
|
|
164
164
|
this.rewrites = rewrites;
|
|
165
165
|
this.hotReloaderSpan = trace('hot-reloader', undefined, {
|
|
166
|
-
version: "16.0.
|
|
166
|
+
version: "16.0.12"
|
|
167
167
|
});
|
|
168
168
|
// Ensure the hotReloaderSpan is flushed immediately as it's the parentSpan for all processing
|
|
169
169
|
// of the current `next dev` invocation.
|
|
@@ -20,7 +20,7 @@ export function logStartInfo({ networkUrl, appUrl, envInfo, experimentalFeatures
|
|
|
20
20
|
if (parts.length > 0) {
|
|
21
21
|
versionSuffix = ` (${parts.join(', ')})`;
|
|
22
22
|
}
|
|
23
|
-
Log.bootstrap(`${bold(purple(`${Log.prefixes.ready} Next.js ${"16.0.
|
|
23
|
+
Log.bootstrap(`${bold(purple(`${Log.prefixes.ready} Next.js ${"16.0.12"}`))}${versionSuffix}`);
|
|
24
24
|
if (appUrl) {
|
|
25
25
|
Log.bootstrap(`- Local: ${appUrl}`);
|
|
26
26
|
}
|
|
@@ -110,7 +110,7 @@ export async function getRequestHandlers({ dir, port, isDev, onDevServerCleanup,
|
|
|
110
110
|
export async function startServer(serverOptions) {
|
|
111
111
|
const { dir, isDev, hostname, minimalMode, allowRetry, keepAliveTimeout, selfSignedCertificate } = serverOptions;
|
|
112
112
|
let { port } = serverOptions;
|
|
113
|
-
process.title = `next-server (v${"16.0.
|
|
113
|
+
process.title = `next-server (v${"16.0.12"})`;
|
|
114
114
|
let handlersReady = ()=>{};
|
|
115
115
|
let handlersError = ()=>{};
|
|
116
116
|
let handlersPromise = new Promise((resolve, reject)=>{
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export function isStableBuild() {
|
|
2
|
-
return !"16.0.
|
|
2
|
+
return !"16.0.12"?.includes('canary') && !process.env.__NEXT_TEST_MODE && !process.env.NEXT_PRIVATE_LOCAL_DEV;
|
|
3
3
|
}
|
|
4
4
|
export class CanaryOnlyConfigError extends Error {
|
|
5
5
|
constructor(arg){
|
|
@@ -114,6 +114,14 @@ async function verifyTypeScriptSetup({ dir, distDir, cacheDir, intentDirs, tscon
|
|
|
114
114
|
}
|
|
115
115
|
// Load TypeScript after we're sure it exists:
|
|
116
116
|
const tsPackageJsonPath = deps.resolved.get((0, _path.join)('typescript', 'package.json'));
|
|
117
|
+
// Bun compatibility: handle undefined path
|
|
118
|
+
if (!tsPackageJsonPath) {
|
|
119
|
+
throw Object.defineProperty(new Error('TypeScript package.json not found in resolved dependencies'), "__NEXT_ERROR_CODE", {
|
|
120
|
+
value: "E915",
|
|
121
|
+
enumerable: false,
|
|
122
|
+
configurable: true
|
|
123
|
+
});
|
|
124
|
+
}
|
|
117
125
|
const typescriptPackageJson = require(tsPackageJsonPath);
|
|
118
126
|
const typescriptVersion = typescriptPackageJson.version;
|
|
119
127
|
if (_semver.default.lt(typescriptVersion, '5.1.0')) {
|