Skip to content

Commit 226f181

Browse files
committed
chore: release v3.0.2
1 parent f6e791f commit 226f181

File tree

5 files changed

+24
-8
lines changed

5 files changed

+24
-8
lines changed

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,17 @@ All notable changes to this project will be documented in this file.
55
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
66
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
77

8+
## [3.0.2](https://github.com/SocketDev/socket-lib/releases/tag/v3.0.2) - 2025-11-01
9+
10+
### Fixed
11+
12+
- **Critical: Node.js ESM named imports from CommonJS**: Fixed build output to ensure Node.js ESM can properly detect named exports from CommonJS modules
13+
- Previously, esbuild's minified export pattern placed `module.exports` before variable definitions, causing "Cannot access before initialization" errors
14+
- Build script now uses `@babel/parser` + `magic-string` for safe AST parsing and transformation
15+
- Exports are now correctly placed at end of files after all variable definitions
16+
- Enables proper ESM named imports: `import { getDefaultLogger, Logger } from '@socketsecurity/lib/logger'`
17+
- Fixes socket-cli issue where named imports were failing with obscure initialization errors
18+
819
## [3.0.1](https://github.com/SocketDev/socket-lib/releases/tag/v3.0.1) - 2025-11-01
920

1021
### Added

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@socketsecurity/lib",
3-
"version": "3.0.1",
3+
"version": "3.0.2",
44
"license": "MIT",
55
"description": "Core utilities and infrastructure for Socket.dev security tools",
66
"keywords": [

src/dlx.ts

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,10 +178,11 @@ export function isInSocketDlx(filePath: string): boolean {
178178

179179
const path = getPath()
180180
const dlxDir = getSocketDlxDir()
181-
const absolutePath = path.resolve(filePath)
181+
const absolutePath = normalizePath(path.resolve(filePath))
182182

183183
// Check if the absolute path starts with the DLX directory.
184-
return absolutePath.startsWith(dlxDir + path.sep)
184+
// Both paths are normalized to use forward slashes for consistent comparison.
185+
return absolutePath.startsWith(dlxDir + '/')
185186
}
186187

187188
/**

test/dlx.test.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import {
2828
} from '@socketsecurity/lib/dlx'
2929
import { getSocketDlxDir } from '@socketsecurity/lib/paths'
3030

31-
describe('dlx', () => {
31+
describe.sequential('dlx', () => {
3232
const testPackageName = 'test-package'
3333
const dlxDir = getSocketDlxDir()
3434

@@ -83,9 +83,11 @@ describe('dlx', () => {
8383
})
8484

8585
it('async version should return false when directory does not exist', async () => {
86-
// Ensure it doesn't exist
87-
if (fs.existsSync(dlxDir)) {
88-
fs.rmSync(dlxDir, { recursive: true, force: true })
86+
// Ensure it doesn't exist (use async version for consistency)
87+
try {
88+
await fs.promises.rm(dlxDir, { recursive: true, force: true })
89+
} catch {
90+
// Directory might not exist, which is fine
8991
}
9092
expect(await dlxDirExistsAsync()).toBe(false)
9193
})

test/effects/ultra.test.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,9 @@ describe('effects/ultra', () => {
153153
expect(gradient).toHaveLength(1000)
154154
// Spot check some positions
155155
expect(gradient[0]).toEqual(RAINBOW_GRADIENT[0])
156-
expect(gradient[999]).toEqual(RAINBOW_GRADIENT[999 % RAINBOW_GRADIENT.length])
156+
expect(gradient[999]).toEqual(
157+
RAINBOW_GRADIENT[999 % RAINBOW_GRADIENT.length],
158+
)
157159
})
158160

159161
it('should generate consistent results for same input', () => {

0 commit comments

Comments
 (0)