Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
759 commits
Select commit Hold shift + click to select a range
985052e
chore(release): v3.2.2
jdalton Nov 3, 2025
5bbce2d
chore(dependabot): add robot emoji prefix to dependency updates
jdalton Nov 3, 2025
b04105e
feat(build): add stub system for external dependencies
jdalton Nov 3, 2025
3c3e2f8
refactor(build): rename index.mjs to orchestrator.mjs
jdalton Nov 3, 2025
da1b0d2
chore(release): v3.2.3
jdalton Nov 3, 2025
20032f2
fix(build): remove source file copying from external bundling
jdalton Nov 4, 2025
dd0b110
build(config): disable sourcemap generation in production builds
jdalton Nov 4, 2025
7bf43d4
fix(build): bundle libnpmexec from npm instead of using vendored version
jdalton Nov 4, 2025
7f1a024
refactor(external): replace vendored libnpmexec code with require
jdalton Nov 4, 2025
51a4e24
fix(build): use src/external files as bundle entry points
jdalton Nov 4, 2025
a191355
refactor(build): use pluralize utility for package count
jdalton Nov 4, 2025
09f3d8e
refactor(build): mark unused srcExternalDir variable
jdalton Nov 4, 2025
4a5574b
style(external): remove unnecessary 'use strict' directive
jdalton Nov 4, 2025
28cec8c
feat(logger): add time() method to Logger class
jdalton Nov 4, 2025
12b526a
fix(build): bundle @npmcli/package-json with subpath exports
jdalton Nov 4, 2025
7ee79c1
fix(effects): add trailing space to star spinner frames
jdalton Nov 4, 2025
961d832
fix(build): add 'use strict' to all CJS files
jdalton Nov 4, 2025
6cbb7eb
fix(build): prevent circular dependencies in external bundling
jdalton Nov 4, 2025
11ed499
chore(release): v3.2.4
jdalton Nov 4, 2025
a669f74
chore(deps): update @socketsecurity/lib-stable to 3.2.4
jdalton Nov 4, 2025
5e6c696
docs(readme): update theme names and module counts
jdalton Nov 4, 2025
1966971
test(logger): add comprehensive test suite for Logger class
jdalton Nov 4, 2025
404a070
test(packages,validation): add tests for licenses and json-parser
jdalton Nov 4, 2025
7627b5f
test(performance,dlx-manifest): add test coverage for utilities
jdalton Nov 4, 2025
870babd
test(stdio,argv,themes): add comprehensive test suites
jdalton Nov 4, 2025
027f9fd
test(logger,argv,themes): add advanced test coverage for core modules
jdalton Nov 4, 2025
99e3a64
docs(tests): enhance test file documentation with comprehensive descr…
jdalton Nov 4, 2025
84426ca
docs(tests): enhance headers for core utilities and fs/path tests (9 …
jdalton Nov 4, 2025
2fbb2b1
docs(tests): enhance headers for env utilities tests (22 files)
jdalton Nov 4, 2025
c64ff92
docs(tests): enhance headers for constants tests (14 files)
jdalton Nov 4, 2025
fe7ab75
docs(tests): enhance headers for packages/stdio/effects tests (11 files)
jdalton Nov 4, 2025
2b4d642
docs(tests): enhance headers for logger/spinner/git/versions tests (7…
jdalton Nov 4, 2025
68e6c05
docs(tests): enhance headers for process/signal utilities (6 files)
jdalton Nov 4, 2025
52df4d2
docs(tests): enhance headers for cache/async/HTTP utilities (8 files)
jdalton Nov 4, 2025
7d7f229
docs(tests): enhance headers for data processing utilities (6 files)
jdalton Nov 4, 2025
43052d9
docs(tests): enhance headers for text/validation/security utilities (…
jdalton Nov 4, 2025
9804dc3
docs(tests): enhance headers for CLI/build/theme utilities (6 files)
jdalton Nov 4, 2025
41e2b08
docs(tests): enhance headers for DLX/agent/GitHub utilities (5 files)
jdalton Nov 4, 2025
5fbf8e4
fix(lint): update Biome config and apply formatting fixes
jdalton Nov 4, 2025
b31ec18
fix(tests): prevent state sharing in logger-advanced tests
jdalton Nov 4, 2025
2881457
fix(tests): add retry logic for flaky performance timing test
jdalton Nov 4, 2025
34ca7a3
fix(tests): apply linter formatting and use optional chaining
jdalton Nov 4, 2025
b35bd98
chore(workflows): align provenance emoji with socket-cli
jdalton Nov 4, 2025
b10c11f
feat(scripts): add AST-based dependency validator
jdalton Nov 5, 2025
a08c169
refactor(scripts): replace regex validator with AST-based one
jdalton Nov 5, 2025
32d284b
fix(constants): correct require paths and remove fallback logic
jdalton Nov 5, 2025
1fca535
feat(constants): add missing module implementations
jdalton Nov 5, 2025
4b3f58e
docs: add coverage badges, onboarding guide, and subdirectory READMEs
jdalton Nov 5, 2025
4059bf0
chore(scripts): align CDN validator with socket-cli implementation
jdalton Nov 5, 2025
45ce097
chore(scripts): remove shebang from CDN validator
jdalton Nov 5, 2025
38ce45b
fix(scripts): use path alias for logger import in CDN validator
jdalton Nov 5, 2025
1dbc903
docs: consolidate getting started documentation
jdalton Nov 5, 2025
bfed3f0
docs: update structure doc to reflect current documentation state
jdalton Nov 5, 2025
556c441
docs: add documentation references to subfolder READMEs
jdalton Nov 5, 2025
6931087
feat(scripts): add path alias resolution script
jdalton Nov 5, 2025
ae9a5eb
feat(build): integrate path alias resolution into build pipeline
jdalton Nov 5, 2025
a14e901
refactor(src): standardize to path aliases for internal imports
jdalton Nov 5, 2025
4c00cf0
test: improve type safety and conditional method testing
jdalton Nov 5, 2025
c1e7659
chore(release): bump version to 3.2.5
jdalton Nov 5, 2025
8b11c58
fix(logger,prompts): replace yoctocolors-cjs rgb() with manual ANSI c…
jdalton Nov 5, 2025
f2a2095
chore(release): bump version to 3.2.6
jdalton Nov 5, 2025
45447df
fix(build-externals): disable minification to preserve exports
jdalton Nov 5, 2025
5658dff
fix(build): re-enable CommonJS export fixes in build pipeline
jdalton Nov 5, 2025
f688434
feat(build): enhance CommonJS export fixes with AST transformations
jdalton Nov 5, 2025
cd3942b
chore: remove obsolete packages README from incorrect location
jdalton Nov 5, 2025
3dd82f8
docs(packages): move README to correct location
jdalton Nov 5, 2025
0afbc2c
chore(release): bump version to 3.2.7
jdalton Nov 5, 2025
7cac037
fix(build): fix CommonJS export script edge cases
jdalton Nov 5, 2025
6568a61
fix(src): remove .default accessor from require calls
jdalton Nov 5, 2025
44c2a14
fix(build): remove module2.module.exports from external bundles
jdalton Nov 5, 2025
3f55a5a
chore(build): add verbose logging for module2.module.exports fix
jdalton Nov 5, 2025
77fb126
fix(build): prevent module2.module.exports generation
jdalton Nov 5, 2025
c79abe6
chore(release): bump version to 3.2.8
jdalton Nov 5, 2025
3a2e2f9
docs: reduce docs
jdalton Nov 6, 2025
3699c6a
chore: add .node-version to .gitignore
jdalton Nov 6, 2025
6b59b91
feat(build): add validation for CommonJS exports
jdalton Nov 6, 2025
6ce67a6
refactor: remove .default references from external imports
jdalton Nov 6, 2025
4c575c1
refactor(build): remove dead code from fix-commonjs-exports
jdalton Nov 6, 2025
63e0a10
chore: remove redundant vitest config
jdalton Nov 6, 2025
a6fe3fd
chore: remove dead package.json scripts
jdalton Nov 6, 2025
27fab9b
docs: simplify README
jdalton Nov 6, 2025
e919a44
chore: reorganize .gitignore
jdalton Nov 6, 2025
19db04e
fix(types): add missing 'release' to versionDiff return type
jdalton Nov 6, 2025
b293fe7
refactor(constants): use vendored pacote import
jdalton Nov 6, 2025
fd96af6
fix(env): use globalThis singleton for test overrides in coverage mode
jdalton Nov 6, 2025
a12fd48
docs(vitest): document rewire globalThis singleton pattern
jdalton Nov 6, 2025
7c6525b
refactor(utils): remove default export from getIpc
jdalton Nov 6, 2025
8bfc013
fix(test): simplify cache-with-ttl getAll test to avoid race condition
jdalton Nov 6, 2025
fed881f
style(env): fix line length formatting in rewire.ts
jdalton Nov 6, 2025
1d28ebd
feat(logger): add reason symbol and method for working/thinking output
jdalton Nov 7, 2025
ea88b5f
feat(spinner): add reason() and reasonAndStop() methods
jdalton Nov 7, 2025
9fba1e9
test: add unit tests for reason() methods and fix regex
jdalton Nov 7, 2025
296d65c
refactor(spinner): normalize text in reasonAndStop like other methods
jdalton Nov 7, 2025
9372270
docs(spinner): add implementation comments for reasonAndStop
jdalton Nov 7, 2025
90237e1
refactor(spinner,logger): organize methods in alphanumeric order
jdalton Nov 7, 2025
f81e71b
refactor: extract color utilities to dedicated module
jdalton Nov 7, 2025
9d0701c
chore: remove unused alias-loader.mjs script
jdalton Nov 7, 2025
4bf2ce7
test: expand test coverage for core modules
jdalton Nov 7, 2025
76d4e68
feat(coverage): track TypeScript source files instead of compiled dist
jdalton Nov 7, 2025
c6809eb
refactor(test): reorganize tests into unit and integration directories
jdalton Nov 7, 2025
17a7900
feat(config): add source map support for coverage tracking
jdalton Nov 7, 2025
c1309c1
test(spinner): add getCliSpinners and stream handling tests
jdalton Nov 7, 2025
bf7f6e3
test(integration): add comprehensive integration test suite
jdalton Nov 7, 2025
a2675cc
docs(readme): update coverage badge to reflect accurate measurement
jdalton Nov 7, 2025
4cb5b6d
test(validation): add comprehensive json-parser tests
jdalton Nov 7, 2025
bdb7716
feat(coverage): filter dist and external files from coverage reports
jdalton Nov 7, 2025
dfca1ad
feat(coverage): add c8 ignore comments for external API calls
jdalton Nov 7, 2025
12d70a7
feat(coverage): report src/ directory coverage to exclude external bu…
jdalton Nov 7, 2025
18227a2
feat(coverage): increase thresholds and update badges to reflect actu…
jdalton Nov 7, 2025
f7aba95
docs(readme): consolidate coverage badges into single metric
jdalton Nov 7, 2025
1898e6b
refactor(scripts): organize scripts into subdirectories
jdalton Nov 7, 2025
25dc642
fix(constants): access .default for all ESM default exports
jdalton Nov 7, 2025
afedc09
feat(esm): add Node.js ESM/CJS interop support
jdalton Nov 7, 2025
899ccf6
test(cache): add vitest retry to wildcard pattern test
jdalton Nov 7, 2025
9315485
fix(test): support Windows paths in spawn working directory test
jdalton Nov 7, 2025
78fba72
release: v3.3.0
jdalton Nov 7, 2025
3a50b71
chore(deps): update @socketsecurity/lib-stable to 3.3.0
jdalton Nov 7, 2025
55a08e2
fix(hooks): add -e flag to echo for ANSI color support
jdalton Nov 7, 2025
8876919
fix(hooks): use printf instead of echo for ANSI colors
jdalton Nov 7, 2025
9873dc5
chore(scripts): remove get-local-package-aliases utility
jdalton Nov 8, 2025
41f3684
fix(build): remove get-local-package-aliases from esbuild config
jdalton Nov 8, 2025
ce6bde6
chore: add *.tmp pattern to .gitignore
jdalton Nov 8, 2025
5c16aea
docs(claude): align CLAUDE.md with canonical standards
jdalton Nov 8, 2025
960bb42
fix(exports): convert 5 modules from default to named exports
jdalton Nov 9, 2025
2f69bdc
fix(constants/node): update import to use named export
jdalton Nov 9, 2025
e52e259
fix(constants/packages): update remaining .default imports to named e…
jdalton Nov 9, 2025
d7fa36e
test: update maintained-node-versions test to use named import
jdalton Nov 9, 2025
43854d2
feat(build): enable validation scripts and improve robustness
jdalton Nov 9, 2025
2e6c8ff
feat(lint): enforce named exports only via Biome
jdalton Nov 9, 2025
47ed0f0
docs(claude): document named export patterns and enforcement
jdalton Nov 9, 2025
4bf6e09
docs(security): add path traversal warning to normalizePath()
jdalton Nov 9, 2025
3cbca55
configuration directories at any depth.
jdalton Nov 9, 2025
3f780e2
fix(constants): improve line formatting in node.ts
jdalton Nov 9, 2025
4ceb3a5
refactor(plugins): convert babel plugins to named exports
jdalton Nov 9, 2025
615a2d7
refactor(config): add named exports to config files
jdalton Nov 9, 2025
3602fb6
chore(lint): allow default exports in config files
jdalton Nov 9, 2025
dddd927
chore: ignore docs/archive directories
jdalton Nov 9, 2025
8fec609
chore(package): lower Node.js version requirement to >=18
jdalton Nov 9, 2025
512f629
fix(hooks): replace echo with printf for consistent output
jdalton Nov 9, 2025
a1a7fa3
refactor: reorganize .gitignore with clear sections and alphabetical …
jdalton Nov 10, 2025
171875e
feat(constants): add SOCKET_DOCS_CONTACT_URL constant
jdalton Nov 10, 2025
f08d890
feat(validation): add external-exports validator for bundled dependen…
jdalton Nov 10, 2025
63b98b8
refactor(validation): use logger instead of console.log/console.error
jdalton Nov 10, 2025
8b29531
refactor(scripts): use logger instead of console throughout scripts/
jdalton Nov 10, 2025
a6c4f0a
style: apply biome formatting fixes
jdalton Nov 10, 2025
fa04338
refactor(claude): split logger.log(colors...) into separate lines
jdalton Nov 10, 2025
a743384
fix(build): unwrap default-only exports in @inquirer modules
jdalton Nov 10, 2025
c074bbd
feat(validation): add comprehensive ESM/CJS validator for external mo…
jdalton Nov 10, 2025
20943ef
refactor(validation): use normalizePath from @socketsecurity/lib
jdalton Nov 10, 2025
82938f1
fix(test): resolve test runner issues and type errors
jdalton Nov 10, 2025
3b50de8
chore(workflows): update socket-registry SHA references
jdalton Nov 11, 2025
767cb44
fix(workflows): remove pnpm version from ci.yml
jdalton Nov 11, 2025
d9cd899
fix(workflows): remove empty with blocks from ci.yml
jdalton Nov 11, 2025
4c19957
fix(build): remove uninstalled inquirer packages from bundle config
jdalton Nov 11, 2025
b509432
docs(readme): add Bluesky badge and link Socket.dev
jdalton Nov 11, 2025
7eb7406
feat(prompts): add @inquirer/checkbox support
jdalton Nov 11, 2025
49a781e
refactor(prompts): simplify external requires and add checkbox
jdalton Nov 11, 2025
9678a72
test(prompts): expand coverage to 100%
jdalton Nov 11, 2025
dfbb0b2
test: add coverage for package default constants
jdalton Nov 11, 2025
848eba4
test: add coverage for lifecycle scripts and types
jdalton Nov 11, 2025
287e8c2
test(dlx): fix flaky test and update coverage badge
jdalton Nov 11, 2025
14e8986
test(dlx): isolate tests using os.tmpdir()
jdalton Nov 11, 2025
799c57a
fix(test): resolve lint issues in dlx tests
jdalton Nov 11, 2025
15f15d2
test: add comprehensive tests for packages/specs and fix TypeScript i…
jdalton Nov 11, 2025
f1e18ff
chore: align packageManager and engines fields across repos
jdalton Nov 11, 2025
66b8d04
chore(release): bump version to 3.3.1
jdalton Nov 10, 2025
3da5273
chore: normalize package.json property order
jdalton Nov 11, 2025
f6baf3e
chore: update @socketsecurity/lib-stable to 3.3.1
jdalton Nov 11, 2025
adeee86
refactor(scripts): standardize logger method usage in validation scripts
jdalton Nov 11, 2025
408bd6b
Add pnpm trustPolicy to prevent downgrade attacks
jdalton Nov 12, 2025
7d17119
docs: add SECURITY.md with vulnerability reporting guidelines
jdalton Nov 12, 2025
3141904
fix(hooks): improve AI attribution detection in pre-push hook
jdalton Nov 13, 2025
02875b3
refactor(logger): add progress symbol with theme.colors.step
jdalton Nov 12, 2025
3bfb64e
refactor: remove incorrect @__NO_SIDE_EFFECTS__ annotations
jdalton Nov 13, 2025
76b0af4
chore: consolidate pnpm config to .npmrc
jdalton Nov 13, 2025
3f57d39
feat(dlx): add @npmcli/arborist for dependency installation
jdalton Nov 13, 2025
567e8cd
perf(external): cherry-pick imports to reduce bundle sizes
jdalton Nov 13, 2025
875247b
test: update arborist test for thin wrapper architecture
jdalton Nov 13, 2025
550f93b
chore(release): v3.3.2
jdalton Nov 13, 2025
65c5ebc
chore(deps): update @socketsecurity/lib-stable to 3.3.2
jdalton Nov 13, 2025
3cb88fb
chore: update pnpm engine requirement to >=10.22.0
jdalton Nov 13, 2025
de2c6c2
fix(build): break node-gyp string to prevent bundler issues
jdalton Nov 13, 2025
044122b
chore(ci): update socket-registry workflow SHAs to latest
jdalton Nov 13, 2025
3e4e7b7
refactor(build): simplify node-gyp string replacement regex
jdalton Nov 13, 2025
72760d0
chore(release): v3.3.3
jdalton Nov 13, 2025
d95c34b
chore(deps): update @socketsecurity/lib-stable to v3.3.3
jdalton Nov 13, 2025
7f9602e
fix(deps): sync lockfile with package.json
jdalton Nov 13, 2025
08cdbe8
fix(build): mark node-gyp as external in npm-pack bundle
jdalton Nov 14, 2025
93c32e4
chore: bump version to 3.3.4
jdalton Nov 14, 2025
668385b
fix(build): add patches to prevent node-gyp bundling issues
jdalton Nov 14, 2025
5309bea
chore(deps): update @socketsecurity/lib to 3.3.5
jdalton Nov 14, 2025
a312de3
chore(deps): consolidate package versions with pnpm overrides
jdalton Nov 14, 2025
5ee922f
refactor: add .js extensions to external require calls
jdalton Nov 14, 2025
becb7a2
chore: bump version to 3.3.7
jdalton Nov 14, 2025
0e4d1ac
chore(deps): update @socketsecurity/lib-stable to 3.3.7
jdalton Nov 14, 2025
1482b40
refactor(scripts): use single-line @babel/traverse imports
jdalton Nov 14, 2025
b31f463
fix(spinner): clear remaining artifacts after withSpinner stops
jdalton Nov 14, 2025
d9c8543
chore(release): bump version to 3.3.8
jdalton Nov 14, 2025
14e7cef
fix(deps): add strip-ansi override for bundling compatibility
jdalton Nov 14, 2025
bd234fe
fix(deps): add string-width and wrap-ansi overrides for bundling comp…
jdalton Nov 14, 2025
de38207
test(ansi): add comprehensive tests for ANSI utilities
jdalton Nov 14, 2025
78411bd
chore(deps): add @dotenvx/dotenvx as dev dependency
jdalton Nov 14, 2025
57d06c0
fix(test): update ansi tests to import from dist/ instead of src/
jdalton Nov 14, 2025
61586cd
fix(stdio): handle inquirer modules with multiple exports
jdalton Nov 14, 2025
b3bf06c
chore(release): bump version to 3.3.11
jdalton Nov 14, 2025
6737d82
feat(logger,spinner): add skip() methods with cyan ↻ symbol
jdalton Nov 14, 2025
b90d558
chore(release): bump version to 3.4.0
jdalton Nov 14, 2025
a60df11
refactor(scripts): replace \u2234 with logger.progress() in claude.mjs
jdalton Nov 15, 2025
3bedf25
feat(argv): add posixQuote and win32Quote for shell argument quoting
jdalton Nov 15, 2025
2b0dc96
fix(scripts): improve @babel/traverse import pattern for CommonJS/ESM…
jdalton Nov 15, 2025
04bd50d
chore(deps): bump @socketsecurity/lib-stable to 3.4.0
jdalton Nov 15, 2025
1c2df27
chore(release): bump version to 3.5.0
jdalton Nov 15, 2025
ffdc1d7
chore(deps): bump @socketsecurity/lib-stable to 3.5.0
jdalton Nov 15, 2025
8e1fee7
refactor: remove unused logger and spinner methods and quote utilities
jdalton Nov 15, 2025
8fa9d5d
refactor: convert lazy requires to ES6 static imports
jdalton Nov 15, 2025
0277420
test: add comprehensive test coverage for logger, spinner, paths, fs,…
jdalton Nov 16, 2025
dadd4e3
docs: update coverage badge to 83.95%
jdalton Nov 16, 2025
a4005db
refactor(test): use crypto.randomUUID for temp directories
jdalton Nov 16, 2025
c25804a
fix(test): disable cache in git-extended real operations tests
jdalton Nov 16, 2025
381dd76
refactor: sort interface/type properties alphabetically
jdalton Nov 16, 2025
4acc9ca
feat(paths): add toUnixPath for Git Bash compatibility
jdalton Nov 16, 2025
36cb932
fix(test): fix Windows platform test failures
jdalton Nov 16, 2025
324b567
docs(spawn): document windowsVerbatimArguments option
jdalton Nov 17, 2025
f5aadef
docs(readme): alphabetize and simplify What's Inside section
jdalton Nov 17, 2025
dc52cac
chore(release): bump version to 4.0.0
jdalton Nov 16, 2025
cb3810e
chore(deps): update @socketsecurity/lib-stable to v4.0.0
jdalton Nov 17, 2025
7ab7b45
refactor: remove # path imports and replace with relative paths
jdalton Nov 17, 2025
1f1ee4a
chore(release): bump version to 4.0.1
jdalton Nov 17, 2025
7cb81b4
chore(deps): update @socketsecurity/lib-stable to v4.0.1
jdalton Nov 17, 2025
1a3cc47
refactor(constants): improve Node.js version detection and flag manag…
jdalton Nov 17, 2025
3a9bdc9
chore(release): bump version to 4.1.0
jdalton Nov 17, 2025
ae3cd44
chore(deps): update @socketsecurity/lib-stable to v4.1.0
jdalton Nov 17, 2025
6b35b1f
refactor: move const declarations below static imports
jdalton Nov 18, 2025
1882c46
refactor: replace getSpinner with getDefaultSpinner
jdalton Nov 18, 2025
4d000a7
refactor(spawn): improve ChildProcess type definition
jdalton Nov 18, 2025
9d8e44a
chore(release): bump version to 4.2.0
jdalton Nov 18, 2025
7d9e13b
refactor(ci): migrate to reusable workflow from socket-registry
jdalton Nov 19, 2025
548fd10
chore(workflows): update socket-registry workflow references to lates…
jdalton Nov 19, 2025
23281d2
feat(check): delegate linting to lint command for consistency
jdalton Nov 19, 2025
4e155d1
feat(globs): expose glob and globSync wrappers for fast-glob
jdalton Nov 21, 2025
57d6c13
chore(test): improve code coverage with c8 ignores and additional tests
jdalton Nov 21, 2025
15705df
chore(release): bump version to 4.3.0
jdalton Nov 21, 2025
1c7291a
chore(deps): update @socketsecurity/lib-stable to 4.3.0
jdalton Nov 21, 2025
418ff97
fix(fs): improve safeReadFile type signatures with proper encoding ov…
jdalton Nov 25, 2025
3c3fd8d
feat(fs): add Node.js normalizeEncoding for robust encoding handling
jdalton Nov 25, 2025
c7f84fc
refactor: organize exported functions alphabetically across lib files
jdalton Nov 26, 2025
5763085
fix(suppress-warnings): properly restore state in withSuppressedWarnings
jdalton Nov 26, 2025
ff6cfd5
test: add 229 tests across 11 modules to increase coverage to 83.78%
jdalton Nov 26, 2025
7c2aa7d
chore(release): bump version to 4.4.0
jdalton Nov 26, 2025
4f910bb
🤖 Dep Updates: bump lint-staged from 15.2.11 to 16.2.7
dependabot[bot] Dec 1, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
313 changes: 313 additions & 0 deletions .config/esbuild.config.mjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,313 @@
/**
* @fileoverview esbuild configuration for socket-lib
* Fast JS compilation with esbuild, declarations with tsgo
*/

import path from 'node:path'
import { fileURLToPath } from 'node:url'
import fg from 'fast-glob'

import { envAsBoolean } from '@socketsecurity/lib-stable/env/helpers'

const __dirname = path.dirname(fileURLToPath(import.meta.url))
const rootPath = path.join(__dirname, '..')
const srcPath = path.join(rootPath, 'src')
const distPath = path.join(rootPath, 'dist')

// Find all TypeScript source files
const entryPoints = fg.sync('**/*.{ts,mts,cts}', {
cwd: srcPath,
absolute: true,
// Skip declaration files.
ignore: ['**/*.d.ts', '**/types/**', '**/external/**'],
})

/**
* Plugin to shorten module paths in bundled output with conflict detection.
* Uses @babel/parser and magic-string for precise AST-based modifications.
*/
function createPathShorteningPlugin() {
return {
name: 'shorten-module-paths',
setup(build) {
build.onEnd(async result => {
if (!result.outputFiles && result.metafile) {
// Dynamic imports to avoid adding to production dependencies
const fs = await import('node:fs/promises')
const { parse } = await import('@babel/parser')
const MagicString = (await import('magic-string')).default

const outputs = Object.keys(result.metafile.outputs).filter(f =>
f.endsWith('.js'),
)

for (const outputPath of outputs) {
// eslint-disable-next-line no-await-in-loop
const content = await fs.readFile(outputPath, 'utf8')
const magicString = new MagicString(content)

// Track module paths and their shortened versions
// Map<originalPath, shortenedPath>
const pathMap = new Map()
// Track shortened paths to detect conflicts
// Map<shortenedPath, originalPath>
const conflictDetector = new Map()

/**
* Shorten a module path and detect conflicts.
*/
// eslint-disable-next-line unicorn/consistent-function-scoping
const shortenPath = longPath => {
if (pathMap.has(longPath)) {
return pathMap.get(longPath)
}

let shortPath = longPath

// Handle pnpm scoped packages
// node_modules/.pnpm/@scope+pkg@version/node_modules/@scope/pkg/dist/file.js
// -> @scope/pkg/dist/file.js
const scopedPnpmMatch = longPath.match(
/node_modules\/\.pnpm\/@([^+/]+)\+([^@/]+)@[^/]+\/node_modules\/(@[^/]+\/[^/]+)\/(.+)/,
)
if (scopedPnpmMatch) {
const [, _scope, _pkg, packageName, subpath] = scopedPnpmMatch
shortPath = `${packageName}/${subpath}`
} else {
// Handle pnpm non-scoped packages
// node_modules/.pnpm/pkg@version/node_modules/pkg/dist/file.js
// -> pkg/dist/file.js
const pnpmMatch = longPath.match(
/node_modules\/\.pnpm\/([^@/]+)@[^/]+\/node_modules\/([^/]+)\/(.+)/,
)
if (pnpmMatch) {
const [, _pkgName, packageName, subpath] = pnpmMatch
shortPath = `${packageName}/${subpath}`
}
}

// Detect conflicts
if (conflictDetector.has(shortPath)) {
const existingPath = conflictDetector.get(shortPath)
if (existingPath !== longPath) {
// Conflict detected - keep original path
console.warn(
`⚠ Path conflict detected:\n "${shortPath}"\n Maps to: "${existingPath}"\n Also from: "${longPath}"\n Keeping original paths to avoid conflict.`,
)
shortPath = longPath
}
} else {
conflictDetector.set(shortPath, longPath)
}

pathMap.set(longPath, shortPath)
return shortPath
}

// Parse AST to find all string literals containing module paths
try {
const ast = parse(content, {
sourceType: 'module',
plugins: [],
})

// Walk through all comments (esbuild puts module paths in comments)
for (const comment of ast.comments || []) {
if (
comment.type === 'CommentLine' &&
comment.value.includes('node_modules')
) {
const originalPath = comment.value.trim()
const shortPath = shortenPath(originalPath)

if (shortPath !== originalPath) {
// Replace in comment
const commentStart = comment.start
const commentEnd = comment.end
magicString.overwrite(
commentStart,
commentEnd,
`// ${shortPath}`,
)
}
}
}

// Walk through all string literals in __commonJS calls
const walk = node => {
if (!node || typeof node !== 'object') {
return
}

// Check for string literals containing node_modules paths
if (
node.type === 'StringLiteral' &&
node.value &&
node.value.includes('node_modules')
) {
const originalPath = node.value
const shortPath = shortenPath(originalPath)

if (shortPath !== originalPath) {
// Replace the string content (keep quotes)
magicString.overwrite(
node.start + 1,
node.end - 1,
shortPath,
)
}
}

// Recursively walk all properties
for (const key of Object.keys(node)) {
if (key === 'start' || key === 'end' || key === 'loc') {
continue
}
const value = node[key]
if (Array.isArray(value)) {
for (const item of value) {
walk(item)
}
} else {
walk(value)
}
}
}

walk(ast.program)

// Write the modified content
// eslint-disable-next-line no-await-in-loop
await fs.writeFile(outputPath, magicString.toString(), 'utf8')
} catch (error) {
console.error(
`Failed to shorten paths in ${outputPath}:`,
error.message,
)
// Continue without failing the build
}
}
}
})
},
}
}

/**
* Plugin to resolve internal path aliases (#lib/*, #constants/*, etc.) to relative paths
*/
function createPathAliasPlugin() {
return {
name: 'internal-path-aliases',
setup(build) {
// Map of path aliases to their actual directories
const pathAliases = {
'#lib/': srcPath,
'#constants/': path.join(srcPath, 'constants'),
'#env/': path.join(srcPath, 'env'),
'#packages/': path.join(srcPath, 'packages'),
'#utils/': path.join(srcPath, 'utils'),
'#types': path.join(srcPath, 'types'),
}

// Intercept imports for path aliases
for (const [alias, basePath] of Object.entries(pathAliases)) {
const isExact = !alias.endsWith('/')
const filter = isExact
? new RegExp(`^${alias.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}$`)
: new RegExp(`^${alias.replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`)

build.onResolve({ filter }, args => {
// Calculate the subpath after the alias
const subpath = isExact ? '' : args.path.slice(alias.length)
const targetPath = subpath ? path.join(basePath, subpath) : basePath

// Calculate relative path from the importing file to the target
const importer = args.importer || srcPath
const importerDir = path.dirname(importer)
let relativePath = path.relative(importerDir, targetPath)

// Ensure relative paths start with ./ or ../
if (!relativePath.startsWith('.')) {
relativePath = `./${relativePath}`
}

// Normalize to forward slashes for consistency
relativePath = relativePath.replace(/\\/g, '/')

return { path: relativePath, external: true }
})
}
},
}
}

// Build configuration for CommonJS output
export const buildConfig = {
entryPoints,
outdir: distPath,
outbase: srcPath,
// Don't bundle - library pattern (each file separate).
bundle: false,
format: 'cjs',
platform: 'node',
target: 'node18',
// Enable source maps for coverage (set COVERAGE=true env var)
sourcemap: envAsBoolean(process.env.COVERAGE),
// Don't minify - this is a library and minification breaks ESM/CJS interop.
minify: false,
// Tree-shaking optimization.
treeShaking: true,
metafile: true,
logLevel: 'info',

// Use plugins for path shortening and aliases
plugins: [createPathShorteningPlugin(), createPathAliasPlugin()].filter(
Boolean,
),

// Note: Cannot use "external" with bundle: false.
// esbuild automatically treats all imports as external when not bundling.

// Define constants for optimization
define: {
'process.env.NODE_ENV': JSON.stringify(
process.env.NODE_ENV || 'production',
),
},

// Banner for generated code
banner: {
js: '"use strict";\n/* Socket Lib - Built with esbuild */',
},
}

// Watch configuration for development with incremental builds
export const watchConfig = {
...buildConfig,
minify: false,
sourcemap: 'inline',
logLevel: 'debug',
}

/**
* Analyze build output for size information
*/
export function analyzeMetafile(metafile) {
const outputs = Object.keys(metafile.outputs)
let totalSize = 0

const files = outputs.map(file => {
const output = metafile.outputs[file]
totalSize += output.bytes
return {
name: path.relative(rootPath, file),
size: `${(output.bytes / 1024).toFixed(2)} KB`,
}
})

return {
files,
totalSize: `${(totalSize / 1024).toFixed(2)} KB`,
}
}
Loading