MCPcopy
hub / github.com/rollup/plugins / getPackageName

Function getPackageName

packages/node-resolve/src/util.js:8–24  ·  view source on GitHub ↗
(id)

Source from the content-addressed store, hash-verified

6
7// returns the imported package name for bare module imports
8export function getPackageName(id) {
9 if (id.startsWith('.') || id.startsWith('/')) {
10 return null;
11 }
12
13 const split = id.split('/');
14
15 // @my-scope/my-package/foo.js -> @my-scope/my-package
16 // @my-scope/my-package -> @my-scope/my-package
17 if (split[0][0] === '@') {
18 return `${split[0]}/${split[1]}`;
19 }
20
21 // my-package/foo.js -> my-package
22 // my-package -> my-package
23 return split[0];
24}
25
26export function getMainFields(options) {
27 let mainFields;

Callers 2

nodeResolveFunction · 0.90
resolveWithExportMapFunction · 0.90

Calls

no outgoing calls

Tested by

no test coverage detected