Skip to content

Commit fde4a3a

Browse files
committed
Add @socketsecurity/lib support to build tooling
Add support for resolving @socketsecurity/lib package from local socket-lib repository during development: - Update alias-loader to check lib/ subdirectory for module resolution - Add @socketsecurity/lib to package alias mappings - Configure ESLint to ignore @socketsecurity/lib imports - Add TypeScript path mappings for @socketsecurity/lib types This enables using local socket-lib package during development while falling back to published version in CI/production.
1 parent e524559 commit fde4a3a

File tree

4 files changed

+18
-5
lines changed

4 files changed

+18
-5
lines changed

.config/eslint.config.mjs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -113,8 +113,8 @@ export default [
113113
'error',
114114
{
115115
commonjs: true,
116-
// Ignore @socketsecurity/registry subpaths - resolved by runtime loader
117-
ignore: ['^@socketsecurity/registry/'],
116+
// Ignore @socketsecurity/registry and @socketsecurity/lib subpaths - resolved by runtime loader
117+
ignore: ['^@socketsecurity/registry/', '^@socketsecurity/lib/'],
118118
},
119119
],
120120
'import-x/order': [
@@ -141,11 +141,11 @@ export default [
141141
},
142142
],
143143
'n/exports-style': ['error', 'module.exports'],
144-
// Ignore @socketsecurity/registry subpaths - resolved by runtime loader
144+
// Ignore @socketsecurity/registry and @socketsecurity/lib subpaths - resolved by runtime loader
145145
'n/no-missing-import': [
146146
'error',
147147
{
148-
allowModules: ['@socketsecurity/registry'],
148+
allowModules: ['@socketsecurity/registry', '@socketsecurity/lib'],
149149
},
150150
],
151151
// The n/no-unpublished-bin rule does does not support non-trivial glob

.config/tsconfig.check.json

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@
66
"noEmit": true,
77
"noPropertyAccessFromIndexSignature": false,
88
"noUncheckedIndexedAccess": false,
9+
"paths": {
10+
"@socketsecurity/lib": ["../../socket-lib/dist/index.d.ts"],
11+
"@socketsecurity/lib/*": ["../../socket-lib/dist/*"]
12+
},
913
"skipLibCheck": true,
1014
"types": ["vitest/globals", "node"],
1115
"verbatimModuleSyntax": false

scripts/utils/alias-loader.mjs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,9 @@ export function resolve(specifier, context, nextResolve) {
3333
path.join(localPath, subpath),
3434
path.join(localPath, `${subpath}.mjs`),
3535
path.join(localPath, `${subpath}.js`),
36+
path.join(localPath, 'lib', subpath),
37+
path.join(localPath, 'lib', `${subpath}.mjs`),
38+
path.join(localPath, 'lib', `${subpath}.js`),
3639
path.join(localPath, 'dist', subpath),
3740
path.join(localPath, 'dist', `${subpath}.mjs`),
3841
path.join(localPath, 'dist', `${subpath}.js`),

scripts/utils/get-local-package-aliases.mjs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,13 @@ export function getLocalPackageAliases(rootDir) {
2121
// If no rootDir provided, try to infer from stack trace or use process.cwd().
2222
const baseDir = rootDir || process.cwd()
2323

24-
// Check for ../socket-registry/registry/dist.
24+
// Check for ../socket-lib/dist for @socketsecurity/lib.
25+
const libPath = path.join(baseDir, '..', 'socket-lib', 'dist')
26+
if (existsSync(path.join(libPath, '../package.json'))) {
27+
aliases['@socketsecurity/lib'] = libPath
28+
}
29+
30+
// Check for ../socket-registry/registry/dist for @socketsecurity/registry.
2531
const registryPath = path.join(baseDir, '..', 'socket-registry', 'registry', 'dist')
2632
if (existsSync(path.join(registryPath, '../package.json'))) {
2733
aliases['@socketsecurity/registry'] = registryPath

0 commit comments

Comments
 (0)