@@ -6,8 +6,6 @@ import { builtinModules } from 'node:module'
66import path from 'node:path'
77import { fileURLToPath } from 'node:url'
88
9- import { getLocalPackageAliases } from '../scripts/utils/get-local-package-aliases.mjs'
10-
119const __dirname = path . dirname ( fileURLToPath ( import . meta. url ) )
1210const rootPath = path . join ( __dirname , '..' )
1311const srcPath = path . join ( rootPath , 'src' )
@@ -181,59 +179,6 @@ function createPathShorteningPlugin() {
181179 }
182180}
183181
184- /**
185- * Plugin to handle local package aliases.
186- * Provides consistent alias resolution across all Socket repos.
187- * Note: Does not externalize @socketsecurity/lib - that should be bundled.
188- */
189- function createAliasPlugin ( ) {
190- const aliases = getLocalPackageAliases ( rootPath )
191-
192- // Only create plugin if we have local aliases
193- if ( Object . keys ( aliases ) . length === 0 ) {
194- return null
195- }
196-
197- // Packages that should always be bundled (even when using local aliases)
198- const ALWAYS_BUNDLED = new Set ( [ '@socketsecurity/lib' ] )
199-
200- return {
201- name : 'local-package-aliases' ,
202- setup ( build ) {
203- // Intercept imports for aliased packages (except @socketsecurity/lib which should be bundled)
204- for ( const [ packageName , _aliasPath ] of Object . entries ( aliases ) ) {
205- // Skip packages that should always be bundled - let esbuild bundle them naturally
206- if ( ALWAYS_BUNDLED . has ( packageName ) ) {
207- continue
208- }
209-
210- // Match both exact package name and subpath imports
211- build . onResolve (
212- { filter : new RegExp ( `^${ packageName } (/|$)` ) } ,
213- args => {
214- // Mark as external using the original package name to avoid absolute paths in output.
215- // This ensures require('@socketsecurity/lib') instead of require('/absolute/path/to/socket-lib/dist').
216- return { path : args . path , external : true }
217- } ,
218- )
219- }
220- } ,
221- }
222- }
223-
224- // Get local package aliases for bundled packages
225- function getBundledPackageAliases ( ) {
226- const aliases = getLocalPackageAliases ( rootPath )
227- const bundledAliases = { }
228-
229- // @socketsecurity /lib should always be bundled (not external)
230- if ( aliases [ '@socketsecurity/lib' ] ) {
231- bundledAliases [ '@socketsecurity/lib' ] = aliases [ '@socketsecurity/lib' ]
232- }
233-
234- return bundledAliases
235- }
236-
237182// Build configuration for CommonJS output
238183export const buildConfig = {
239184 entryPoints : [ `${ srcPath } /index.ts` ] ,
@@ -254,11 +199,8 @@ export const buildConfig = {
254199 // Preserve module structure for better tree-shaking
255200 splitting : false ,
256201
257- // Alias local packages that should be bundled (not external)
258- alias : getBundledPackageAliases ( ) ,
259-
260- // Use plugins for local package aliases and path shortening
261- plugins : [ createPathShorteningPlugin ( ) , createAliasPlugin ( ) ] . filter ( Boolean ) ,
202+ // Use plugins for path shortening
203+ plugins : [ createPathShorteningPlugin ( ) ] ,
262204
263205 // External dependencies
264206 external : [
0 commit comments