Skip to main content

Module dependent_version_imports

Module dependent_version_imports 

Source
Expand description

Whether source text imports a package. What: Decide whether source text imports a package or one of its subpaths. Why: A development dependency is bundled, and so carries a bump, only when non-test source imports it. This is the incumbent’s specifier scan (source-imports.ts:59-264): a quoted specifier equal to the name, or starting with the name and /, directly after from, import, import( or require(. Every character it inspects is ASCII, so scanning UTF-8 bytes decides exactly what scanning UTF-16 units decides.

In TS you’d write (pseudocode):

// importsPackage({ sourceText, packageName });

Functions§

imports_package
What: Whether source text imports the package or one of its subpaths. .match_indices(...) yields each non-overlapping occurrence from the left, the same occurrences the incumbent’s indexOf loop visits. Why: The character before an occurrence must open a quote, the one after must close it or start a subpath, and the literal must be in specifier position. Gotcha: For an empty name the incumbent’s loop never advances and does not terminate; here every position is an occurrence, so the stated rule applies to it too.