Next.js website for Rocky Mountain Vending company featuring: - Product catalog with Stripe integration - Service areas and parts pages - Admin dashboard with Clerk authentication - SEO optimized pages with JSON-LD structured data Co-authored-by: Cursor <cursoragent@cursor.com>
1 line
No EOL
13 KiB
Text
1 line
No EOL
13 KiB
Text
{"version":3,"sources":["../../../../src/build/webpack/plugins/slow-module-detection-plugin.ts"],"sourcesContent":["import type { Compiler, Module, Compilation } from 'webpack'\nimport type { CompilerNameValues } from '../../../shared/lib/constants'\nimport { yellow, green, blue } from '../../../lib/picocolors'\n\nconst PLUGIN_NAME = 'SlowModuleDetectionPlugin'\n\nconst TreeSymbols = {\n VERTICAL_LINE: '│ ',\n BRANCH: '├─ ',\n} as const\n\nconst PATH_TRUNCATION_LENGTH = 120\n\n// Matches node_modules paths, including pnpm-style paths\nconst NODE_MODULES_PATH_PATTERN = /node_modules(?:\\/\\.pnpm)?\\/(.*)/\n\ninterface ModuleBuildTimeAnalyzerOptions {\n compilerType: CompilerNameValues\n buildTimeThresholdMs: number\n}\n\nconst getModuleIdentifier = (module: Module): string => {\n const debugId = module.debugId\n return String(debugId)\n}\n\nconst getModuleDisplayName = (module: Module): string | undefined => {\n const resourcePath =\n 'resource' in module && typeof module.resource === 'string'\n ? module.resource\n : undefined\n\n if (!resourcePath) {\n return undefined\n }\n\n let displayPath = resourcePath.replace(process.cwd(), '.')\n\n const nodeModulesMatch = displayPath.match(NODE_MODULES_PATH_PATTERN)\n if (nodeModulesMatch) {\n return nodeModulesMatch[1]\n }\n\n return displayPath\n}\n\n/**\n * Truncates a path to a maximum length. If the path exceeds this length,\n * it will be truncated in the middle and replaced with '...'.\n */\nfunction truncatePath(path: string, maxLength: number): string {\n // If the path length is within the limit, return it as is\n if (path.length <= maxLength) return path\n\n // Calculate the available length for the start and end segments after accounting for '...'\n const availableLength = maxLength - 3\n const startSegmentLength = Math.ceil(availableLength / 2)\n const endSegmentLength = Math.floor(availableLength / 2)\n\n // Extract the start and end segments of the path\n const startSegment = path.slice(0, startSegmentLength)\n const endSegment = path.slice(-endSegmentLength)\n\n // Return the truncated path with '...' in the middle\n return `${startSegment}...${endSegment}`\n}\n\nclass ModuleBuildTimeAnalyzer {\n private pendingModules: Module[] = []\n private modules = new Map<string, Module>()\n private moduleParents = new Map<Module, Module>()\n private moduleChildren = new Map<Module, Map<string, Module>>()\n private isFinalized = false\n private buildTimeThresholdMs: number\n private moduleBuildTimes = new WeakMap<Module, number>()\n\n constructor(private options: ModuleBuildTimeAnalyzerOptions) {\n this.buildTimeThresholdMs = options.buildTimeThresholdMs\n }\n\n recordModuleBuildTime(module: Module, duration: number) {\n // Webpack guarantees that no more modules will be built after finishModules hook is called,\n // where we generate the report. This check is just a defensive measure.\n if (this.isFinalized) {\n throw new Error(\n `Invariant (SlowModuleDetectionPlugin): Module is recorded after the report is generated. This is a Next.js internal bug.`\n )\n }\n\n if (duration < this.buildTimeThresholdMs) {\n return // Skip fast modules\n }\n\n this.moduleBuildTimes.set(module, duration)\n this.pendingModules.push(module)\n }\n\n /**\n * For each slow module, traverses up the dependency chain to find all ancestor modules.\n * Builds a directed graph where:\n * 1. Each slow module and its ancestors become nodes\n * 2. Edges represent \"imported by\" relationships\n * 3. Root nodes are entry points with no parents\n *\n * The resulting graph allows us to visualize the import chains that led to slow builds.\n */\n private prepareReport(compilation: Compilation) {\n for (const module of this.pendingModules) {\n const chain = new Set<Module>()\n\n // Walk up the module graph until we hit a root module (no issuer) to populate the chain\n {\n let currentModule = module\n chain.add(currentModule)\n while (true) {\n const issuerModule = compilation.moduleGraph.getIssuer(currentModule)\n if (!issuerModule) break\n if (chain.has(issuerModule)) {\n throw new Error(\n `Invariant (SlowModuleDetectionPlugin): Circular dependency detected in module graph. This is a Next.js internal bug.`\n )\n }\n chain.add(issuerModule)\n currentModule = issuerModule\n }\n }\n\n // Add all visited modules to our graph and create parent-child relationships\n let previousModule: Module | null = null\n for (const currentModule of chain) {\n const moduleId = getModuleIdentifier(currentModule)\n if (!this.modules.has(moduleId)) {\n this.modules.set(moduleId, currentModule)\n }\n\n if (previousModule) {\n this.moduleParents.set(previousModule, currentModule)\n\n let parentChildren = this.moduleChildren.get(currentModule)\n if (!parentChildren) {\n parentChildren = new Map()\n this.moduleChildren.set(currentModule, parentChildren)\n }\n parentChildren.set(\n getModuleIdentifier(previousModule),\n previousModule\n )\n }\n\n previousModule = currentModule\n }\n }\n this.isFinalized = true\n }\n\n generateReport(compilation: Compilation) {\n if (!this.isFinalized) {\n this.prepareReport(compilation)\n }\n\n // Find root modules (those with no parents)\n const rootModules = [...this.modules.values()].filter(\n (node) => !this.moduleParents.has(node)\n )\n\n const formatModuleNode = (node: Module, depth: number): string => {\n const moduleName = getModuleDisplayName(node) || ''\n\n if (!moduleName) {\n return formatChildModules(node, depth)\n }\n\n const prefix =\n ' ' + TreeSymbols.VERTICAL_LINE.repeat(depth) + TreeSymbols.BRANCH\n\n const moduleText = blue(\n truncatePath(moduleName, PATH_TRUNCATION_LENGTH - prefix.length)\n )\n\n const buildTimeMs = this.moduleBuildTimes.get(node)\n const duration = buildTimeMs\n ? yellow(` (${Math.ceil(buildTimeMs)}ms)`)\n : ''\n\n return (\n prefix +\n moduleText +\n duration +\n '\\n' +\n formatChildModules(node, depth + 1)\n )\n }\n\n const formatChildModules = (node: Module, depth: number): string => {\n const children = this.moduleChildren.get(node)\n if (!children) return ''\n\n return [...children]\n .map(([_, child]) => formatModuleNode(child, depth))\n .join('')\n }\n\n const report = rootModules.map((root) => formatModuleNode(root, 0)).join('')\n\n if (report) {\n console.log(\n green(\n `🐌 Detected slow modules while compiling ${this.options.compilerType}:`\n ) +\n '\\n' +\n report\n )\n }\n }\n}\n\nexport default class SlowModuleDetectionPlugin {\n constructor(private options: ModuleBuildTimeAnalyzerOptions) {}\n\n apply = (compiler: Compiler) => {\n compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => {\n const analyzer = new ModuleBuildTimeAnalyzer(this.options)\n const moduleBuildStartTimes = new WeakMap<Module, number>()\n\n compilation.hooks.buildModule.tap(PLUGIN_NAME, (module) => {\n moduleBuildStartTimes.set(module, performance.now())\n })\n\n compilation.hooks.succeedModule.tap(PLUGIN_NAME, (module) => {\n const startTime = moduleBuildStartTimes.get(module)\n if (!startTime) {\n throw new Error(\n `Invariant (SlowModuleDetectionPlugin): Unable to find the start time for a module build. This is a Next.js internal bug.`\n )\n }\n analyzer.recordModuleBuildTime(module, performance.now() - startTime)\n })\n\n compilation.hooks.finishModules.tap(PLUGIN_NAME, () => {\n analyzer.generateReport(compilation)\n })\n })\n }\n}\n"],"names":["yellow","green","blue","PLUGIN_NAME","TreeSymbols","VERTICAL_LINE","BRANCH","PATH_TRUNCATION_LENGTH","NODE_MODULES_PATH_PATTERN","getModuleIdentifier","module","debugId","String","getModuleDisplayName","resourcePath","resource","undefined","displayPath","replace","process","cwd","nodeModulesMatch","match","truncatePath","path","maxLength","length","availableLength","startSegmentLength","Math","ceil","endSegmentLength","floor","startSegment","slice","endSegment","ModuleBuildTimeAnalyzer","constructor","options","pendingModules","modules","Map","moduleParents","moduleChildren","isFinalized","moduleBuildTimes","WeakMap","buildTimeThresholdMs","recordModuleBuildTime","duration","Error","set","push","prepareReport","compilation","chain","Set","currentModule","add","issuerModule","moduleGraph","getIssuer","has","previousModule","moduleId","parentChildren","get","generateReport","rootModules","values","filter","node","formatModuleNode","depth","moduleName","formatChildModules","prefix","repeat","moduleText","buildTimeMs","children","map","_","child","join","report","root","console","log","compilerType","SlowModuleDetectionPlugin","apply","compiler","hooks","tap","analyzer","moduleBuildStartTimes","buildModule","performance","now","succeedModule","startTime","finishModules"],"mappings":"AAEA,SAASA,MAAM,EAAEC,KAAK,EAAEC,IAAI,QAAQ,0BAAyB;AAE7D,MAAMC,cAAc;AAEpB,MAAMC,cAAc;IAClBC,eAAe;IACfC,QAAQ;AACV;AAEA,MAAMC,yBAAyB;AAE/B,yDAAyD;AACzD,MAAMC,4BAA4B;AAOlC,MAAMC,sBAAsB,CAACC;IAC3B,MAAMC,UAAUD,OAAOC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