@davidwells/extract-deps 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude/settings.local.json +2 -1
- package/examples/verify-basic.js +0 -2
- package/package.json +1 -1
- package/src/dep-graph.js +46 -20
- package/src/index.js +14 -1
- package/src/verify-package-entries.js +4 -3
- package/tests/dep-graph.test.js +97 -41
- package/types/dep-graph.d.ts +10 -3
- package/types/dep-graph.d.ts.map +1 -1
- package/types/get-cjs-exports.d.ts +10 -0
- package/types/get-cjs-exports.d.ts.map +1 -1
- package/types/get-imports.d.ts +1 -0
- package/types/get-imports.d.ts.map +1 -1
- package/types/vendor/inspect-parameters-declaration.d.ts +4 -0
- package/types/vendor/inspect-parameters-declaration.d.ts.map +1 -0
- package/types/verify-package-entries.d.ts +30 -0
- package/types/verify-package-entries.d.ts.map +1 -0
package/examples/verify-basic.js
CHANGED
package/package.json
CHANGED
package/src/dep-graph.js
CHANGED
|
@@ -132,16 +132,18 @@ function verifyImportedValuesExist(dep, targetDeps, targetPath, sourcePath, erro
|
|
|
132
132
|
* @param {boolean} throwOnFirstError - Whether to throw immediately on first error
|
|
133
133
|
* @param {boolean} verify - Whether to verify imports/exports
|
|
134
134
|
* @param {boolean} verifyNodeModules - Whether to verify node_modules can be resolved
|
|
135
|
+
* @param {boolean} includeNodeModules - Whether to include node_modules in the graph
|
|
135
136
|
* @param {Map<string, string[]>|null} graph - Optional map to collect dependency graph
|
|
136
137
|
* @param {Set} visited - Set of already-visited file paths to avoid cycles
|
|
137
138
|
*/
|
|
138
139
|
function buildGraphRecursively(
|
|
139
|
-
filePath,
|
|
140
|
-
errors,
|
|
141
|
-
throwOnFirstError,
|
|
142
|
-
verify,
|
|
143
|
-
verifyNodeModules,
|
|
144
|
-
|
|
140
|
+
filePath,
|
|
141
|
+
errors,
|
|
142
|
+
throwOnFirstError,
|
|
143
|
+
verify,
|
|
144
|
+
verifyNodeModules,
|
|
145
|
+
includeNodeModules,
|
|
146
|
+
graph = null,
|
|
145
147
|
visited = new Set(),
|
|
146
148
|
) {
|
|
147
149
|
// Avoid infinite loops
|
|
@@ -171,7 +173,7 @@ function buildGraphRecursively(
|
|
|
171
173
|
|
|
172
174
|
// Collect all non-relative dependencies (node_modules)
|
|
173
175
|
const nodeModuleDeps = []
|
|
174
|
-
if (verifyNodeModules) {
|
|
176
|
+
if (verifyNodeModules || includeNodeModules) {
|
|
175
177
|
if (deps.requires && deps.requires.length > 0) {
|
|
176
178
|
nodeModuleDeps.push(...deps.requires.filter(req => !req.isRelative))
|
|
177
179
|
}
|
|
@@ -217,7 +219,14 @@ function buildGraphRecursively(
|
|
|
217
219
|
}
|
|
218
220
|
|
|
219
221
|
// Recursively process the imported file
|
|
220
|
-
buildGraphRecursively(resolvedPath, errors, throwOnFirstError, verify, verifyNodeModules, graph, visited)
|
|
222
|
+
buildGraphRecursively(resolvedPath, errors, throwOnFirstError, verify, verifyNodeModules, includeNodeModules, graph, visited)
|
|
223
|
+
}
|
|
224
|
+
|
|
225
|
+
// Add node_modules to graph if enabled
|
|
226
|
+
if (includeNodeModules && graph !== null) {
|
|
227
|
+
for (const dep of nodeModuleDeps) {
|
|
228
|
+
graph.get(normalizedPath).push(dep.from)
|
|
229
|
+
}
|
|
221
230
|
}
|
|
222
231
|
|
|
223
232
|
// Verify node_modules dependencies if enabled
|
|
@@ -255,20 +264,22 @@ function buildGraphRecursively(
|
|
|
255
264
|
* @param {boolean} [options.buildGraph] - If true, build and return dependency graph. Default: true
|
|
256
265
|
* @param {boolean} [options.verifyGraph] - If true, verify imports/exports. Default: true
|
|
257
266
|
* @param {boolean} [options.verifyNodeModules] - If true, verify node_modules packages can be resolved. Default: false
|
|
267
|
+
* @param {boolean} [options.includeNodeModules] - If true, include node_modules package names in the graph. Default: false
|
|
258
268
|
* @param {boolean} [options.throwOnFirstError] - If true, throw immediately on first error. Default: false
|
|
259
|
-
* @returns {Map<string, string[]>|undefined} - Dependency graph where keys are file paths and values are arrays of dependency paths. Returns undefined if buildGraph is false.
|
|
269
|
+
* @returns {Map<string, string[]>|undefined} - Dependency graph where keys are file paths and values are arrays of dependency paths (or package names if includeNodeModules). Returns undefined if buildGraph is false.
|
|
260
270
|
*/
|
|
261
271
|
function depGraph(filePath, options = {}) {
|
|
262
|
-
const {
|
|
263
|
-
buildGraph = true,
|
|
264
|
-
verifyGraph = true,
|
|
265
|
-
verifyNodeModules = false,
|
|
272
|
+
const {
|
|
273
|
+
buildGraph = true,
|
|
274
|
+
verifyGraph = true,
|
|
275
|
+
verifyNodeModules = false,
|
|
276
|
+
includeNodeModules = false,
|
|
266
277
|
throwOnFirstError = false,
|
|
267
278
|
} = options
|
|
268
279
|
const errors = []
|
|
269
280
|
const graph = buildGraph ? new Map() : null
|
|
270
281
|
|
|
271
|
-
buildGraphRecursively(filePath, errors, throwOnFirstError, verifyGraph, verifyNodeModules, graph)
|
|
282
|
+
buildGraphRecursively(filePath, errors, throwOnFirstError, verifyGraph, verifyNodeModules, includeNodeModules, graph)
|
|
272
283
|
|
|
273
284
|
if (errors.length > 0) {
|
|
274
285
|
const errorMessage = errors.map((err, idx) => `Dep graph error:\n ${err.message}`).join('\n')
|
|
@@ -287,15 +298,27 @@ function depGraph(filePath, options = {}) {
|
|
|
287
298
|
* Get all dependency file paths in build order (dependencies first), deduplicated
|
|
288
299
|
* @param {string} filePath - Entry file path
|
|
289
300
|
* @param {object} options - Options to pass to depGraph
|
|
290
|
-
* @returns {string[]
|
|
301
|
+
* @returns {{ files: string[], nodeModules: string[] }} - Object with files in topological order and unique node_modules
|
|
291
302
|
*/
|
|
292
303
|
function resolveDepPaths(filePath, options = {}) {
|
|
293
|
-
const graph = depGraph(filePath, options)
|
|
304
|
+
const graph = depGraph(filePath, { ...options, includeNodeModules: true })
|
|
305
|
+
|
|
306
|
+
// Collect node_modules (non-path strings in dependency arrays)
|
|
307
|
+
const nodeModulesSet = new Set()
|
|
308
|
+
for (const deps of graph.values()) {
|
|
309
|
+
for (const dep of deps) {
|
|
310
|
+
if (!dep.startsWith('/')) {
|
|
311
|
+
nodeModulesSet.add(dep)
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
}
|
|
294
315
|
|
|
295
|
-
// Calculate in-degree (number of dependencies) for each file
|
|
316
|
+
// Calculate in-degree (number of file dependencies) for each file
|
|
296
317
|
const inDegree = new Map()
|
|
297
318
|
for (const [file, deps] of graph) {
|
|
298
|
-
|
|
319
|
+
// Only count file deps, not node_modules
|
|
320
|
+
const fileDeps = deps.filter(d => d.startsWith('/'))
|
|
321
|
+
inDegree.set(file, fileDeps.length)
|
|
299
322
|
}
|
|
300
323
|
|
|
301
324
|
// Queue of files with no dependencies (can be processed first)
|
|
@@ -324,14 +347,17 @@ function resolveDepPaths(filePath, options = {}) {
|
|
|
324
347
|
}
|
|
325
348
|
}
|
|
326
349
|
|
|
327
|
-
return
|
|
350
|
+
return {
|
|
351
|
+
files: buildOrder,
|
|
352
|
+
nodeModules: Array.from(nodeModulesSet)
|
|
353
|
+
}
|
|
328
354
|
}
|
|
329
355
|
|
|
330
356
|
|
|
331
357
|
if (require.main === module) {
|
|
332
358
|
const entry = path.resolve(__dirname, '../tests/fixtures/cjs-deep-example/index.js')
|
|
333
359
|
const graph = depGraph(entry, {
|
|
334
|
-
|
|
360
|
+
includeNodeModules: true,
|
|
335
361
|
throwOnFirstError: true
|
|
336
362
|
})
|
|
337
363
|
console.log('graph', graph)
|
package/src/index.js
CHANGED
|
@@ -50,6 +50,19 @@ if (require.main === module) {
|
|
|
50
50
|
}
|
|
51
51
|
`
|
|
52
52
|
|
|
53
|
+
const code2 = `
|
|
54
|
+
// Get users Lambda handler
|
|
55
|
+
import _ from 'lodash'
|
|
56
|
+
|
|
57
|
+
export async function handler(event, context) {
|
|
58
|
+
const data = { message: 'get function called' }
|
|
59
|
+
return {
|
|
60
|
+
statusCode: 200,
|
|
61
|
+
body: JSON.stringify(_.omit(data, [])),
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
`
|
|
65
|
+
|
|
53
66
|
const failCase = `
|
|
54
67
|
const { test } = require('uvu')
|
|
55
68
|
const assert = require('uvu/assert')
|
|
@@ -65,7 +78,7 @@ const config = await import('./config.js')
|
|
|
65
78
|
const lerna = require('lerna')
|
|
66
79
|
const { execSync, spawnSync } = require('child_process')
|
|
67
80
|
`
|
|
68
|
-
const result = extractDeps(
|
|
81
|
+
const result = extractDeps(code2)
|
|
69
82
|
|
|
70
83
|
const { imports, requires } = result
|
|
71
84
|
|
|
@@ -149,11 +149,12 @@ function verifyPackageEntries(packagePath, options = {}) {
|
|
|
149
149
|
|
|
150
150
|
if (collectDeps) {
|
|
151
151
|
// Collect dependencies using resolveDepPaths
|
|
152
|
-
const
|
|
153
|
-
result.sourceFiles =
|
|
152
|
+
const { files, nodeModules } = resolveDepPaths(entryPoint.resolvedPath, { verifyGraph, verifyNodeModules: true })
|
|
153
|
+
result.sourceFiles = files
|
|
154
|
+
result.nodeModules = nodeModules
|
|
154
155
|
|
|
155
156
|
// Add to sourceFiles set
|
|
156
|
-
|
|
157
|
+
files.forEach(dep => sourceFilesSet.add(dep))
|
|
157
158
|
} else if (verifyGraph) {
|
|
158
159
|
// Just verify without collecting deps
|
|
159
160
|
depGraph(entryPoint.resolvedPath, { buildGraph: false, verifyGraph: true })
|
package/tests/dep-graph.test.js
CHANGED
|
@@ -117,38 +117,39 @@ test('should work with all options combined', () => {
|
|
|
117
117
|
})
|
|
118
118
|
|
|
119
119
|
// resolveDepPaths tests
|
|
120
|
-
test('resolveDepPaths should return
|
|
121
|
-
const
|
|
122
|
-
assert.ok(Array.isArray(
|
|
120
|
+
test('resolveDepPaths should return object with files and nodeModules', () => {
|
|
121
|
+
const result = resolveDepPaths(CJS_FIXTURE_PATH)
|
|
122
|
+
assert.ok(Array.isArray(result.files), 'files should be an array')
|
|
123
|
+
assert.ok(Array.isArray(result.nodeModules), 'nodeModules should be an array')
|
|
123
124
|
})
|
|
124
125
|
|
|
125
126
|
test('resolveDepPaths should return deduplicated paths', () => {
|
|
126
|
-
const
|
|
127
|
-
const uniqueDeps = [...new Set(
|
|
127
|
+
const { files } = resolveDepPaths(CJS_DEEP_FIXTURE_PATH)
|
|
128
|
+
const uniqueDeps = [...new Set(files)]
|
|
128
129
|
|
|
129
|
-
assert.is(
|
|
130
|
+
assert.is(files.length, uniqueDeps.length, 'Should not have duplicate paths')
|
|
130
131
|
})
|
|
131
132
|
|
|
132
133
|
test('resolveDepPaths should include all files from graph', () => {
|
|
133
134
|
const graph = depGraph(CJS_FIXTURE_PATH)
|
|
134
|
-
const
|
|
135
|
+
const { files } = resolveDepPaths(CJS_FIXTURE_PATH)
|
|
135
136
|
|
|
136
|
-
assert.is(
|
|
137
|
+
assert.is(files.length, graph.size, 'Should have same number of files as graph')
|
|
137
138
|
|
|
138
|
-
// All graph keys should be in
|
|
139
|
+
// All graph keys should be in files
|
|
139
140
|
for (const key of graph.keys()) {
|
|
140
|
-
assert.ok(
|
|
141
|
+
assert.ok(files.includes(key), `Should include ${path.basename(key)}`)
|
|
141
142
|
}
|
|
142
143
|
})
|
|
143
144
|
|
|
144
145
|
test('resolveDepPaths should return paths in topological order (dependencies first)', () => {
|
|
145
|
-
const
|
|
146
|
+
const { files } = resolveDepPaths(CJS_FIXTURE_PATH)
|
|
146
147
|
|
|
147
148
|
// Find indices
|
|
148
|
-
const threeIdx =
|
|
149
|
-
const twoIdx =
|
|
150
|
-
const oneIdx =
|
|
151
|
-
const indexIdx =
|
|
149
|
+
const threeIdx = files.findIndex(p => p.includes('three.js'))
|
|
150
|
+
const twoIdx = files.findIndex(p => p.includes('two.js'))
|
|
151
|
+
const oneIdx = files.findIndex(p => p.includes('one.js'))
|
|
152
|
+
const indexIdx = files.findIndex(p => p.includes('index.js'))
|
|
152
153
|
|
|
153
154
|
// three.js has no dependencies, should come first
|
|
154
155
|
assert.ok(threeIdx < twoIdx, 'three.js should come before two.js')
|
|
@@ -157,45 +158,45 @@ test('resolveDepPaths should return paths in topological order (dependencies fir
|
|
|
157
158
|
})
|
|
158
159
|
|
|
159
160
|
test('resolveDepPaths should work with ESM fixtures', () => {
|
|
160
|
-
const
|
|
161
|
+
const { files } = resolveDepPaths(ESM_FIXTURE_PATH)
|
|
161
162
|
|
|
162
|
-
assert.ok(Array.isArray(
|
|
163
|
-
assert.ok(
|
|
163
|
+
assert.ok(Array.isArray(files), 'Should return an array')
|
|
164
|
+
assert.ok(files.length > 0, 'Should have dependencies')
|
|
164
165
|
|
|
165
166
|
// Check files are included
|
|
166
|
-
assert.ok(
|
|
167
|
-
assert.ok(
|
|
168
|
-
assert.ok(
|
|
169
|
-
assert.ok(
|
|
167
|
+
assert.ok(files.some(p => p.includes('index.js')), 'Should include index.js')
|
|
168
|
+
assert.ok(files.some(p => p.includes('one.js')), 'Should include one.js')
|
|
169
|
+
assert.ok(files.some(p => p.includes('two.js')), 'Should include two.js')
|
|
170
|
+
assert.ok(files.some(p => p.includes('three.js')), 'Should include three.js')
|
|
170
171
|
})
|
|
171
172
|
|
|
172
173
|
test('resolveDepPaths should have entry point last', () => {
|
|
173
|
-
const
|
|
174
|
-
const lastFile =
|
|
174
|
+
const { files } = resolveDepPaths(CJS_FIXTURE_PATH)
|
|
175
|
+
const lastFile = files[files.length - 1]
|
|
175
176
|
|
|
176
177
|
assert.ok(lastFile.includes('index.js'), 'Entry point (index.js) should be last')
|
|
177
178
|
})
|
|
178
179
|
|
|
179
180
|
test('resolveDepPaths should have leaf nodes first', () => {
|
|
180
|
-
const
|
|
181
|
-
const firstFile =
|
|
181
|
+
const { files } = resolveDepPaths(CJS_FIXTURE_PATH)
|
|
182
|
+
const firstFile = files[0]
|
|
182
183
|
|
|
183
184
|
// three.js has no dependencies - it's a leaf node
|
|
184
185
|
assert.ok(firstFile.includes('three.js'), 'Leaf node (three.js) should be first')
|
|
185
186
|
})
|
|
186
187
|
|
|
187
188
|
test('resolveDepPaths should handle complex graphs with shared dependencies', () => {
|
|
188
|
-
const
|
|
189
|
+
const { files } = resolveDepPaths(CJS_DEEP_FIXTURE_PATH)
|
|
189
190
|
|
|
190
191
|
// Should be deduplicated
|
|
191
|
-
const uniqueDeps = [...new Set(
|
|
192
|
-
assert.is(
|
|
192
|
+
const uniqueDeps = [...new Set(files)]
|
|
193
|
+
assert.is(files.length, uniqueDeps.length, 'Should deduplicate shared dependencies')
|
|
193
194
|
|
|
194
195
|
// Find d-three.js which is shared by d-two.js, d-two-a.js, d-two-b.js
|
|
195
|
-
const threeIdx =
|
|
196
|
-
const twoIdx =
|
|
197
|
-
const twoAIdx =
|
|
198
|
-
const twoBIdx =
|
|
196
|
+
const threeIdx = files.findIndex(p => p.includes('d-three.js'))
|
|
197
|
+
const twoIdx = files.findIndex(p => p.includes('d-two.js'))
|
|
198
|
+
const twoAIdx = files.findIndex(p => p.includes('d-two-a.js'))
|
|
199
|
+
const twoBIdx = files.findIndex(p => p.includes('d-two-b.js'))
|
|
199
200
|
|
|
200
201
|
// d-three.js should come before all files that depend on it
|
|
201
202
|
assert.ok(threeIdx < twoIdx, 'd-three.js should come before d-two.js')
|
|
@@ -204,10 +205,10 @@ test('resolveDepPaths should handle complex graphs with shared dependencies', ()
|
|
|
204
205
|
})
|
|
205
206
|
|
|
206
207
|
test('resolveDepPaths should pass options to depGraph', () => {
|
|
207
|
-
const
|
|
208
|
+
const { files } = resolveDepPaths(CJS_FIXTURE_PATH, { verifyGraph: false })
|
|
208
209
|
|
|
209
|
-
assert.ok(Array.isArray(
|
|
210
|
-
assert.ok(
|
|
210
|
+
assert.ok(Array.isArray(files), 'Should work with options')
|
|
211
|
+
assert.ok(files.length > 0, 'Should return dependencies')
|
|
211
212
|
})
|
|
212
213
|
|
|
213
214
|
// verifyNodeModules tests
|
|
@@ -373,13 +374,68 @@ test('should resolve directory import to index.js', () => {
|
|
|
373
374
|
})
|
|
374
375
|
|
|
375
376
|
test('resolveDepPaths should work with directory imports', () => {
|
|
376
|
-
const
|
|
377
|
+
const { files } = resolveDepPaths(DIR_INDEX_FIXTURE_PATH)
|
|
377
378
|
|
|
378
|
-
assert.ok(Array.isArray(
|
|
379
|
-
assert.is(
|
|
379
|
+
assert.ok(Array.isArray(files), 'Should return an array')
|
|
380
|
+
assert.is(files.length, 2, 'Should have 2 files')
|
|
380
381
|
|
|
381
|
-
assert.ok(
|
|
382
|
-
assert.ok(
|
|
382
|
+
assert.ok(files.some(p => p.includes('shared-pkg/index.js')), 'Should include resolved index.js')
|
|
383
|
+
assert.ok(files.some(p => p.includes('entry.js')), 'Should include entry.js')
|
|
384
|
+
})
|
|
385
|
+
|
|
386
|
+
test('resolveDepPaths should return nodeModules', () => {
|
|
387
|
+
const { nodeModules } = resolveDepPaths(CJS_DEEP_FIXTURE_PATH)
|
|
388
|
+
|
|
389
|
+
assert.ok(Array.isArray(nodeModules), 'nodeModules should be an array')
|
|
390
|
+
assert.ok(nodeModules.includes('lodash'), 'Should include lodash')
|
|
391
|
+
})
|
|
392
|
+
|
|
393
|
+
// includeNodeModules tests
|
|
394
|
+
test('includeNodeModules should default to false', () => {
|
|
395
|
+
const graph = depGraph(CJS_DEEP_FIXTURE_PATH)
|
|
396
|
+
|
|
397
|
+
// Check that no dependency array contains 'lodash'
|
|
398
|
+
for (const deps of graph.values()) {
|
|
399
|
+
assert.ok(!deps.includes('lodash'), 'Should not include node_modules by default')
|
|
400
|
+
}
|
|
401
|
+
})
|
|
402
|
+
|
|
403
|
+
test('includeNodeModules: true should add package names to graph', () => {
|
|
404
|
+
const graph = depGraph(CJS_DEEP_FIXTURE_PATH, { includeNodeModules: true })
|
|
405
|
+
|
|
406
|
+
// Find index.js which requires lodash
|
|
407
|
+
const indexPath = Array.from(graph.keys()).find(key => key.includes('cjs-deep-example/index.js'))
|
|
408
|
+
assert.ok(indexPath, 'Should have index.js in graph')
|
|
409
|
+
|
|
410
|
+
const indexDeps = graph.get(indexPath)
|
|
411
|
+
assert.ok(indexDeps.includes('lodash'), 'Should include lodash in dependencies')
|
|
412
|
+
})
|
|
413
|
+
|
|
414
|
+
test('includeNodeModules: true should mix package names with file paths', () => {
|
|
415
|
+
const graph = depGraph(CJS_DEEP_FIXTURE_PATH, { includeNodeModules: true })
|
|
416
|
+
|
|
417
|
+
const indexPath = Array.from(graph.keys()).find(key => key.includes('cjs-deep-example/index.js'))
|
|
418
|
+
const indexDeps = graph.get(indexPath)
|
|
419
|
+
|
|
420
|
+
// Should have both relative dep (d-one.js) and node_module (lodash)
|
|
421
|
+
const hasRelativeDep = indexDeps.some(dep => dep.includes('d-one.js'))
|
|
422
|
+
const hasNodeModule = indexDeps.includes('lodash')
|
|
423
|
+
|
|
424
|
+
assert.ok(hasRelativeDep, 'Should have relative dependency')
|
|
425
|
+
assert.ok(hasNodeModule, 'Should have node_module dependency')
|
|
426
|
+
})
|
|
427
|
+
|
|
428
|
+
test('includeNodeModules works independently of verifyNodeModules', () => {
|
|
429
|
+
// Include but don't verify
|
|
430
|
+
const graph = depGraph(CJS_DEEP_FIXTURE_PATH, {
|
|
431
|
+
includeNodeModules: true,
|
|
432
|
+
verifyNodeModules: false
|
|
433
|
+
})
|
|
434
|
+
|
|
435
|
+
const indexPath = Array.from(graph.keys()).find(key => key.includes('cjs-deep-example/index.js'))
|
|
436
|
+
const indexDeps = graph.get(indexPath)
|
|
437
|
+
|
|
438
|
+
assert.ok(indexDeps.includes('lodash'), 'Should include lodash without verification')
|
|
383
439
|
})
|
|
384
440
|
|
|
385
441
|
test.run()
|
package/types/dep-graph.d.ts
CHANGED
|
@@ -4,19 +4,26 @@
|
|
|
4
4
|
* @param {object} options - Options
|
|
5
5
|
* @param {boolean} [options.buildGraph] - If true, build and return dependency graph. Default: true
|
|
6
6
|
* @param {boolean} [options.verifyGraph] - If true, verify imports/exports. Default: true
|
|
7
|
+
* @param {boolean} [options.verifyNodeModules] - If true, verify node_modules packages can be resolved. Default: false
|
|
8
|
+
* @param {boolean} [options.includeNodeModules] - If true, include node_modules package names in the graph. Default: false
|
|
7
9
|
* @param {boolean} [options.throwOnFirstError] - If true, throw immediately on first error. Default: false
|
|
8
|
-
* @returns {Map<string, string[]>|undefined} - Dependency graph where keys are file paths and values are arrays of dependency paths. Returns undefined if buildGraph is false.
|
|
10
|
+
* @returns {Map<string, string[]>|undefined} - Dependency graph where keys are file paths and values are arrays of dependency paths (or package names if includeNodeModules). Returns undefined if buildGraph is false.
|
|
9
11
|
*/
|
|
10
12
|
export function depGraph(filePath: string, options?: {
|
|
11
13
|
buildGraph?: boolean;
|
|
12
14
|
verifyGraph?: boolean;
|
|
15
|
+
verifyNodeModules?: boolean;
|
|
16
|
+
includeNodeModules?: boolean;
|
|
13
17
|
throwOnFirstError?: boolean;
|
|
14
18
|
}): Map<string, string[]> | undefined;
|
|
15
19
|
/**
|
|
16
20
|
* Get all dependency file paths in build order (dependencies first), deduplicated
|
|
17
21
|
* @param {string} filePath - Entry file path
|
|
18
22
|
* @param {object} options - Options to pass to depGraph
|
|
19
|
-
* @returns {string[]
|
|
23
|
+
* @returns {{ files: string[], nodeModules: string[] }} - Object with files in topological order and unique node_modules
|
|
20
24
|
*/
|
|
21
|
-
export function resolveDepPaths(filePath: string, options?: object):
|
|
25
|
+
export function resolveDepPaths(filePath: string, options?: object): {
|
|
26
|
+
files: string[];
|
|
27
|
+
nodeModules: string[];
|
|
28
|
+
};
|
|
22
29
|
//# sourceMappingURL=dep-graph.d.ts.map
|
package/types/dep-graph.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"dep-graph.d.ts","sourceRoot":"","sources":["../src/dep-graph.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"dep-graph.d.ts","sourceRoot":"","sources":["../src/dep-graph.js"],"names":[],"mappings":"AAmQA;;;;;;;;;;GAUG;AACH,mCATW,MAAM,YAEd;IAA0B,UAAU,GAA5B,OAAO;IACW,WAAW,GAA7B,OAAO;IACW,iBAAiB,GAAnC,OAAO;IACW,kBAAkB,GAApC,OAAO;IACW,iBAAiB,GAAnC,OAAO;CACf,GAAU,GAAG,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,GAAC,SAAS,CAyB3C;AAGD;;;;;GAKG;AACH,0CAJW,MAAM,YACN,MAAM,GACJ;IAAE,KAAK,EAAE,MAAM,EAAE,CAAC;IAAC,WAAW,EAAE,MAAM,EAAE,CAAA;CAAE,CAqDtD"}
|
|
@@ -32,4 +32,14 @@ export function getObjectAssignExports(originalText?: string, sanitizedText?: st
|
|
|
32
32
|
index: number;
|
|
33
33
|
isExport: boolean;
|
|
34
34
|
}[];
|
|
35
|
+
export function getDefinePropertyExports(originalText?: string, sanitizedText?: string): {
|
|
36
|
+
line: string;
|
|
37
|
+
exportType: string;
|
|
38
|
+
exportName: string;
|
|
39
|
+
exportValue: string;
|
|
40
|
+
exportDefinitionName: string;
|
|
41
|
+
index: number;
|
|
42
|
+
isExport: boolean;
|
|
43
|
+
isDefineProperty: boolean;
|
|
44
|
+
}[];
|
|
35
45
|
//# sourceMappingURL=get-cjs-exports.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-cjs-exports.d.ts","sourceRoot":"","sources":["../src/get-cjs-exports.js"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"get-cjs-exports.d.ts","sourceRoot":"","sources":["../src/get-cjs-exports.js"],"names":[],"mappings":"AAoCA,gDAiCC;AA+BD;;;;;;;;IAqGC;AAED;;;;;;;IAqBC;AAED;;;;;;;IAqBC;AAED;;;;;;;IAiDC;AAED;;;;;;;;;IAwEC"}
|
package/types/get-imports.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"get-imports.d.ts","sourceRoot":"","sources":["../src/get-imports.js"],"names":[],"mappings":"AAWA;;;;;;;;;IAQC;AAGD;;;;;;;;;IAkBC;AAED
|
|
1
|
+
{"version":3,"file":"get-imports.d.ts","sourceRoot":"","sources":["../src/get-imports.js"],"names":[],"mappings":"AAWA;;;;;;;;;IAQC;AAGD;;;;;;;;;IAkBC;AAED;;;;;;;;IAiBC;AAED;;;;;;;;;;IAoBC;AAED;;;;;;;;;;;;IAwBC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"inspect-parameters-declaration.d.ts","sourceRoot":"","sources":["../../src/vendor/inspect-parameters-declaration.js"],"names":[],"mappings":"AA0QA,oDAaC;AAtBD,qDAGC;AAED,gFAEC"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Extract all entry points from package.json
|
|
3
|
+
* @param {string} packageJsonPath - Path to package.json
|
|
4
|
+
* @returns {Array<{field: string, path: string, resolvedPath: string}>} - Array of entry point objects
|
|
5
|
+
*/
|
|
6
|
+
export function getPackageEntryPoints(packageJsonPath: string): Array<{
|
|
7
|
+
field: string;
|
|
8
|
+
path: string;
|
|
9
|
+
resolvedPath: string;
|
|
10
|
+
}>;
|
|
11
|
+
/**
|
|
12
|
+
* Verify all package.json entry points and collect dependencies
|
|
13
|
+
* @param {string} packagePath - Path to package.json
|
|
14
|
+
* @param {object} options - Options
|
|
15
|
+
* @param {boolean} [options.collectDeps] - If true, collect dependency paths for each entry point. Default: true
|
|
16
|
+
* @param {boolean} [options.verifyGraph] - If true, verify imports/exports. Default: true
|
|
17
|
+
* @param {boolean} [options.throwIfErrors] - If true, throw an error if there are any errors. Default: false
|
|
18
|
+
* @returns {{entryPoints: Array, sourceFiles: Set, errors: Array}} - Verification results
|
|
19
|
+
*/
|
|
20
|
+
export function verifyPackageEntries(packagePath: string, options?: {
|
|
21
|
+
collectDeps?: boolean;
|
|
22
|
+
verifyGraph?: boolean;
|
|
23
|
+
throwIfErrors?: boolean;
|
|
24
|
+
}): {
|
|
25
|
+
entryPoints: any[];
|
|
26
|
+
sourceFiles: Set<any>;
|
|
27
|
+
errors: any[];
|
|
28
|
+
};
|
|
29
|
+
export function collectEntryPoints(packageJson: any, packageDir: any): any[];
|
|
30
|
+
//# sourceMappingURL=verify-package-entries.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify-package-entries.d.ts","sourceRoot":"","sources":["../src/verify-package-entries.js"],"names":[],"mappings":"AAKA;;;;GAIG;AACH,uDAHW,MAAM,GACJ,KAAK,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,IAAI,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,CAAA;CAAC,CAAC,CAOtE;AAmGD;;;;;;;;GAQG;AACH,kDAPW,MAAM,YAEd;IAA0B,WAAW,GAA7B,OAAO;IACW,WAAW,GAA7B,OAAO;IACW,aAAa,GAA/B,OAAO;CACf,GAAU;IAAC,WAAW,QAAQ;IAAC,WAAW,WAAM;IAAC,MAAM,QAAO;CAAC,CAoEjE;AA5KD,6EA8DC"}
|