rnx-kit/packages/third-party-notices
React Native SDK Bot 756ddeba67
RELEASING: Releasing 44 package(s) (#3342)
Releases:
  @rnx-kit/third-party-notices@2.0.0
  @rnx-kit/cli@0.18.0
  @rnx-kit/metro-plugin-cyclic-dependencies-detector@2.0.0
  @rnx-kit/react-native-error-trace-decorator@2.0.0
  @rnx-kit/esbuild-plugin-import-path-remapper@3.0.0
  @rnx-kit/babel-plugin-import-path-remapper@2.0.0
  @rnx-kit/babel-preset-metro-react-native@2.0.0
  @rnx-kit/metro-plugin-duplicates-checker@3.0.0
  @rnx-kit/react-native-test-app-msal@4.0.0
  @rnx-kit/react-native-lazy-index@4.0.0
  @rnx-kit/tools-react-native@2.0.0
  @rnx-kit/typescript-service@2.0.0
  @rnx-kit/commitlint-lite@2.0.0
  @rnx-kit/metro-serializer@2.0.0
  @rnx-kit/tools-language@3.0.0
  @rnx-kit/metro-service@4.0.0
  @rnx-kit/metro-config@2.0.0
  @rnx-kit/bundle-diff@2.0.0
  @rnx-kit/align-deps@3.0.0
  @rnx-kit/tools-node@3.0.0
  @rnx-kit/tsconfig@2.0.0
  @rnx-kit/console@2.0.0
  @react-native-webapis/battery-status@0.2.0
  @react-native-webapis/web-storage@0.3.0
  @rnx-kit/esbuild-bundle-analyzer@0.3.0
  @rnx-kit/metro-serializer-esbuild@0.2.0
  @rnx-kit/rn-changelog-generator@0.5.0
  @rnx-kit/metro-plugin-typescript@0.5.0
  @rnx-kit/metro-resolver-symlinks@0.2.0
  @rnx-kit/react-native-auth@0.3.0
  @rnx-kit/react-native-host@0.5.0
  @rnx-kit/patcher-rnmacos@0.2.0
  @rnx-kit/tools-filesystem@0.1.0
  @rnx-kit/tools-workspaces@0.2.0
  @rnx-kit/eslint-plugin@0.8.0
  @rnx-kit/tools-android@0.2.0
  @rnx-kit/tools-windows@0.2.0
  @rnx-kit/jest-preset@0.2.0
  @rnx-kit/tools-apple@0.2.0
  @rnx-kit/tools-shell@0.2.0
  @rnx-kit/polyfills@0.2.0
  @rnx-kit/config@0.7.0
  @rnx-kit/build@0.7.1
  @rnx-kit/eslint-config@0.0.4

Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
2024-09-11 08:59:50 +02:00
..
src fix(third-party-notices): move Commander config from `rnx-cli` (#3337) 2024-09-10 18:14:03 +00:00
test fix(third-party-notices): display author information (#3185) 2024-06-11 15:19:05 +02:00
CHANGELOG.md RELEASING: Releasing 44 package(s) (#3342) 2024-09-11 08:59:50 +02:00
README.md feat(third-party-notices): add full license info (#3165) 2024-05-30 08:41:22 +02:00
eslint.config.js chore: migrate to ESLint flat config (#2782) 2023-11-03 14:02:18 +01:00
package.json RELEASING: Releasing 44 package(s) (#3342) 2024-09-11 08:59:50 +02:00
tsconfig.json feat(tsconfig): base TypeScript configs for working with Node (#2886) 2023-12-18 12:05:07 +01:00

README.md

@rnx-kit/third-party-notices

Build npm version

@rnx-kit/third-party-notices provides a helper library to create a third-party-notices text file based on a output bundle. It also provides a cli interface to the library for integration into build steps like just-scripts

This function will read the sourcemap file and tries to find all files that are referenced in the sourcemap by assuming that all dependencies are represented as node_modules\moduleName or node_modules\@scope\moduleName It will then look in the package.json file to see if it finds a licence claration or it will look for the file called LICENCE in the root. And aggregate all ese files in the output file.

This package works for npm, yarn and pnpm package layouts formats.

Usage

Commandline

npx @rnx-kit/third-party-notices \
    --rootPath <myPackage> \
    --sourceMapFile <myPackage/dist/myPackage.js.map>
Options:
  --help             Show help                                         [boolean]
  --version          Show version number                               [boolean]
  --rootPath         The root of the repo where to start resolving modules from.
                                                             [string] [required]
  --sourceMapFile    The sourceMap file to generate license contents for.
                                                             [string] [required]
  --json             Output license information as a JSON
                                                      [boolean] [default: false]
  --outputFile       The output file to write the license file to.      [string]
  --ignoreScopes     Npm scopes to ignore and not emit license information for
                                                                         [array]
  --ignoreModules    Modules (js packages) to not emit license information for
                                                                         [array]
  --preambleText     A list of lines to prepend at the start of the generated
                     license file.                                       [array]
  --additionalText   A list of lines to append at the end of the generated
                     license file.                                       [array]
  --fullLicenseText  Include full license text in the JSON output
                                                      [boolean] [default: false]

As a library

import { writeThirdPartyNotices } from "@rnx-kit/third-party-notices";

writeThirdPartyNotices({
  rootPath: ".",
  sourceMapFile: "./dist/myPackage.js.map",
});

As a plugin

Import and add the plugin to ThirdPartyNotices in your metro.config.js, and optionally configure it to your liking:

 const { makeMetroConfig } = require("@rnx-kit/metro-config");
+const { ThirdPartyNotices } = require("@rnx-kit/third-party-notices");
+const { MetroSerializer } = require("@rnx-kit/metro-serializer");

 module.exports = makeMetroConfig({
   serializer: {
+    customSerializer: MetroSerializer([
+      ThirdPartyNotices(),
+    ]),
   },
 });