0.1.2 • Published 4 years ago

ubborg-cjsbundle-depscan-helper-pmb v0.1.2

Weekly downloads
1
License
ISC
Repository
github
Last release
4 years ago

ubborg-cjsbundle-depscan-helper-pmb

Express CJS bundle dependencies in a way that can be picked up by naive dependency scanners.

API

This module exports one function:

relateCjsBundles(bun, fakeCode, opt)

Declares relations (see kind below) of ubborg bundle bun to CJS bundles. The IDs of the related CJS bundles are obtained from fakeCode using an algorithm equivalent to:

  1. Split fakeCode into lines.
  2. Discard outer whitespace from each line.
  3. Discard lines that start with # or //.
  4. Discard lines that contain less than two quote characters.
  5. In each line, discard the first quote character and anything in front.
  6. In each line, discard the last quote character and anything behind it.
  7. Discard lines that are (now) empty.
  8. Treat remaining lines as CJS module IDs.

Returns a Promise for an array of all related resource plans.

opt is an optional options object that supports these keys:

  • kind: The kind of relation. Should be a string. Defaults to 'needs'.
  • nMin: The minimum number of module IDs that are expected to be found in fakeCode. Default: 1

opt may also be a non-empty string, in which case it is used as the kind.

Usage

see usage_example.mjs.

Known issues

  • Needs more/better tests and docs.

 

License

ISC

0.1.2

4 years ago

0.1.1

4 years ago

0.1.0

4 years ago