Skip to content

Skip package.json without name in js-license-ranger - #297

Merged
longsleep merged 1 commit into
libregraph:masterfrom
longsleep-io:longsleep-fix-i18next-license-ranger
Nov 10, 2026
Merged

longsleep merged 1 commit into
libregraph:masterfrom
longsleep-io:longsleep-fix-i18next-license-ranger

Conversation

@longsleep

Copy link
Copy Markdown
Collaborator

The script reads the sourcemaps of the identifier build, walks up from each bundled source to the nearest package.json and takes the license from there. make dist puts its output into the 3rdparty-LICENSES.md of the release tarball.

react-i18next ships dist/es/package.json, a file without a name which only sets the module type of that directory. findLicense special-cased such a file only when it held nothing but type and version, and then returned no entry. With react-i18next 17.0.16, whose file is {"type":"module","version":"17.0.16"}, the package was therefore skipped silently: the license document of master has 43 entries and lacks react-i18next, although it ships in the bundle under MIT.

react-i18next 17.1.x adds sideEffects to that file. The special case no longer matches, the script looks for a license in dist/es, finds none and throws "no license found: ./node_modules/react-i18next/dist/es", which fails make licenses in the build of Dependabot PR #293.

A package.json without a name is not a package root, Node uses such files only to scope the module type. findModuleViaPackageJSON now skips them and keeps walking up. Such files are common, for example in tiny-invariant/dist/esm, @emotion/styled/base and lru-cache/dist/*. This makes the type module case in findLicense and the popping of a trailing esm directory obsolete, so both are removed. The revision record goes to 20261110-1.

With the dependencies of master the output is identical but for the new react-i18next entry with its MIT license, 44 entries in all. @emotion/styled/base now resolves to @emotion/styled, which is already listed with the same license. With react-i18next 17.1.13 the script exits 0, lists react-i18next and skips no package.

The script reads the sourcemaps of the identifier build, walks up from
each bundled source to the nearest package.json and takes the license
from there. make dist puts its output into the 3rdparty-LICENSES.md of
the release tarball.

react-i18next ships dist/es/package.json, a file without a name which
only sets the module type of that directory. findLicense special-cased
such a file only when it held nothing but type and version, and then
returned no entry. With react-i18next 17.0.16, whose file is
{"type":"module","version":"17.0.16"}, the package was therefore
skipped silently: the license document of master has 43 entries and
lacks react-i18next, although it ships in the bundle under MIT.

react-i18next 17.1.x adds sideEffects to that file. The special case no
longer matches, the script looks for a license in dist/es, finds none
and throws "no license found: ./node_modules/react-i18next/dist/es",
which fails make licenses in the build of Dependabot PR libregraph#293.

A package.json without a name is not a package root, Node uses such
files only to scope the module type. findModuleViaPackageJSON now skips
them and keeps walking up. Such files are common, for example in
tiny-invariant/dist/esm, @emotion/styled/base and lru-cache/dist/*.
This makes the type module case in findLicense and the popping of a
trailing esm directory obsolete, so both are removed. The revision
record goes to 20261110-1.

With the dependencies of master the output is identical but for the
new react-i18next entry with its MIT license, 44 entries in all.
@emotion/styled/base now resolves to @emotion/styled, which is already
listed with the same license. With react-i18next 17.1.13 the script
exits 0, lists react-i18next and skips no package.
@longsleep
longsleep merged commit c0b2e61 into libregraph:master Nov 10, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant