Gathering detailed insights and metrics for pkg-to-jsr
Gathering detailed insights and metrics for pkg-to-jsr
Gathering detailed insights and metrics for pkg-to-jsr
Gathering detailed insights and metrics for pkg-to-jsr
Zero-config tool that generates jsr.json from package.json
npm install pkg-to-jsr
Typescript
Module System
Node Version
NPM Version
59
Supply Chain
97.9
Quality
84.1
Maintenance
100
Vulnerability
99.6
License
TypeScript (86.9%)
JavaScript (13.1%)
Total Downloads
1,870
Last Day
1
Last Week
10
Last Month
63
Last Year
1,870
22 Stars
259 Commits
1 Watching
11 Branches
1 Contributors
Latest Version
1.2.6
Package Id
pkg-to-jsr@1.2.6
Unpacked Size
29.08 kB
Size
9.78 kB
File Count
14
NPM Version
10.8.2
Node Version
20.17.0
Publised On
31 Aug 2024
Cumulative downloads
Total Downloads
Last day
-66.7%
1
Compared to previous day
Last week
-37.5%
10
Compared to previous week
Last month
-21.3%
63
Compared to previous month
Last year
0%
1,870
Compared to previous year
pkg-to-jsr is a zero-config generator that creates a jsr.json
file from your existing package.json
.
It simplifies the process of preparing your package for publication on JSR.
jsr.json
from package.json
exports
configurations with easeinclude
and exclude
options for precise publishing controlYou can use pkg-to-jsr without installation using npx:
1npx pkg-to-jsr
Alternatively, you can use other package managers:
1# Using Yarn 2yarn dlx pkg-to-jsr 3 4# Using pnpm 5pnpm dlx pkg-to-jsr 6 7# Using Bun 8bunx pkg-to-jsr
For global installation:
1npm install -g pkg-to-jsr
Run the following command in your project directory:
1npx pkg-to-jsr
This will generate a jsr.json
file based on your package.json
.
--root <path>
: Specify the root directory containing the package.json
file (default: current working directory)Here are some examples of how pkg-to-jsr transforms your package.json
into jsr.json
:
package.json:
1{ 2 "name": "package", 3 "jsrName": "@scope/package", 4 "version": "1.0.0", 5 "exports": "./index.js" 6}
Generated jsr.json:
1{ 2 "name": "@scope/package", 3 "version": "1.0.0", 4 "exports": { 5 ".": "./index.js" 6 } 7}
package.json:
1{ 2 "name": "package", 3 "author": "ryoppippi", 4 "version": "1.0.0", 5 "exports": { 6 ".": { 7 "jsr": "./src/index.ts", 8 "import": "./dist/index.js", 9 "types": "./dist/index.d.ts" 10 }, 11 "./utils": { 12 "jsr": "./src/utils.ts", 13 "import": "./dist/utils.js", 14 "types": "./dist/utils.d.ts" 15 } 16 }, 17 "files": [ 18 "dist", 19 "!dist/**/*.test.js" 20 ], 21 "jsrInclude": [ 22 "src" 23 ], 24 "jsrExclude": [ 25 "src/**/*.test.ts" 26 ] 27}
Generated jsr.json:
1{ 2 "name": "@ryoppippi/package", 3 "version": "1.0.0", 4 "exports": { 5 ".": "./src/index.ts", 6 "./utils": "./src/utils.ts" 7 }, 8 "publish": { 9 "include": ["dist", "src"], 10 "exclude": ["dist/**/*.test.js", "src/**/*.test.ts"] 11 } 12}
pkg-to-jsr performs the following steps:
package.json
filename
, version
, and exports
jsr.json
file with the correct structure for JSRMore details on implementation can be found in the source code.
You can see example projects in the tests.
pkg-to-jsr determines the package name for jsr.json
using the following logic:
jsrName
field exists in package.json
and is correctly formatted (@scope/package-name
), it is used.jsrName
is not present, it checks the name
field in package.json
. If this is correctly formatted for JSR, it is used.name
is not in JSR format, it combines the name
and author
fields. For example, if name
is "package" and author
is "ryoppippi", it generates @ryoppippi/package
.This approach allows maximum flexibility while ensuring compliance with JSR naming conventions.
The tool intelligently handles various exports
configurations:
jsr
, import
, and other conditions are handledjsr
field is specified in the exports, it takes priority over other fieldspkg-to-jsr generates the publish.include
and publish.exclude
fields in jsr.json
by merging and filtering information from multiple sources:
jsrInclude
array in package.json
: All entries are considered for inclusionjsrExclude
array in package.json
: All entries are considered for exclusionfiles
array in package.json
:
!
are considered for inclusion!
are considered for exclusion (with the !
removed)The final include
and exclude
lists in jsr.json
are the result of merging and filtering these sources:
include
list combines unique entries from both jsrInclude
and the positive entries in files
, excluding any paths that are in jsrExclude
exclude
list combines unique entries from both jsrExclude
and the negative entries in files
(with !
removed), excluding any paths that are in jsrInclude
This approach provides fine-grained control over what gets published to JSR while maintaining compatibility with existing files
configurations and allowing for explicit inclusion and exclusion rules.
Example:
package.json:
1{ 2 "files": [ 3 "dist", 4 "src", 5 "!dist/**/*.test.js" 6 ], 7 "jsrInclude": [ 8 "src", 9 "types" 10 ], 11 "jsrExclude": [ 12 "src/**/*.test.ts", 13 "dist" 14 ] 15}
Generated jsr.json:
1{ 2 "publish": { 3 "include": ["src", "types"], 4 "exclude": ["dist/**/*.test.js", "src/**/*.test.ts"] 5 } 6}
In this example:
src
is included because it's in both files
and jsrInclude
types
is included because it's in jsrInclude
dist
is excluded because it's in jsrExclude
, overriding its presence in files
dist
and src
are excludedThis merged and filtered configuration ensures that all necessary files are included while respecting explicit inclusion and exclusion rules, providing precise control over the package contents for JSR publication.
Contributions are welcome! Please feel free to submit a Pull Request.
No vulnerabilities found.
No security vulnerabilities found.