From 1a11419bc0286e824b90b4081ac03d6a60103d42 Mon Sep 17 00:00:00 2001 From: Patrick Lu Date: Sat, 29 Nov 2025 11:44:05 -0800 Subject: [PATCH] refactor: Move fs/path to top-level imports in webpack plugin MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Move dynamic require() calls for 'fs' and 'path' from inside the getAliasMap method to top-level ES6 imports. This follows conventional Node.js/TypeScript patterns and prevents potential issues with dynamic requires. Changes: - Added top-level imports: import fs from "fs" and import path from "path" - Removed dynamic require() calls from getAliasMap method 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- src/webpack-plugin.ts | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/webpack-plugin.ts b/src/webpack-plugin.ts index f445b36..98e6ce6 100644 --- a/src/webpack-plugin.ts +++ b/src/webpack-plugin.ts @@ -22,6 +22,8 @@ import type { Compilation, Compiler, Module as WebpackModule } from "webpack"; import { sources } from "webpack"; +import fs from "fs"; +import path from "path"; interface Asset { name: string; @@ -108,9 +110,6 @@ export default class CodePressWebpackPlugin { // Always try to read @ alias from tsconfig.json if not already present // resolve.alias usually has Next.js internals but not the @ path alias - const fs = require("fs"); - const path = require("path"); - if (!aliases.has("@")) { const tsconfigPath = path.join(compiler.context, "tsconfig.json"); console.log("[CodePress] Looking for @ alias in tsconfig:", tsconfigPath);