1.3.4 • Published 9 months ago

@rnx-kit/third-party-notices v1.3.4

Weekly downloads
-
License
MIT
Repository
github
Last release
9 months ago

@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.

At the moment this package only supports webpack based bundles, there is nothing preventing adding metro support, the current customers of this module are basedon webpack at the moment.

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 licence contents for.
                                                             [string] [required]
  --outputFile      The output file to write the licence file to.       [string]
  --json            Output license information as a JSON
                                                      [boolean] [default: false]
  --ignoreScopes    Npm scopes to ignore and not emit licence information for
                                                                         [array]
  --ignoreModules   Modules (js packages) to not emit licence information for
                                                                         [array]
  --preambleText    A list of lines to prepend at the start of the generated
                    licence file.                                        [array]
  --additionalText  A list of lines to append at the end of the generated
                    licence file.                                        [array]

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(),
+    ]),
   },
 });
1.3.4

9 months ago

1.3.3

1 year ago

1.3.2

1 year ago

1.3.1

1 year ago

1.3.0

1 year ago

1.2.16

2 years ago

1.2.14

2 years ago

1.2.15

2 years ago

1.2.12

2 years ago

1.2.13

2 years ago

1.2.11

3 years ago

1.2.8

3 years ago

1.2.9

3 years ago

1.2.10

3 years ago

1.2.7

3 years ago

1.2.6

3 years ago

1.2.5

3 years ago

1.2.4

3 years ago

1.2.3

3 years ago

1.2.2

3 years ago

1.2.0

3 years ago

1.1.4

3 years ago

1.1.3

3 years ago

1.2.1

3 years ago

1.1.2

3 years ago

1.1.1

3 years ago

1.1.0

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago