0.3.41 • Published 3 days ago

@rushstack/trace-import v0.3.41

Weekly downloads
-
License
MIT
Repository
github
Last release
3 days ago

@rushstack/trace-import

🚨 EARLY PREVIEW RELEASE 🚨

Not all features are implemented yet. To provide suggestions, please create a GitHub issue. If you have questions, see the Rush Stack Help page for support resources.

The trace-import command line tool helps you:

  • Analyze import/require() statements to understand why they aren't resolving correctly
  • Understand the relationships between package folders in your node_modules tree
  • Ensure that package.json files correctly export their .js and .d.ts entry points

Usage

It's recommended to install this package globally:

# Install the NPM package
npm install -g @rushstack/trace-import

# View the command-line help
trace-import --help

Command line

usage: trace-import [-h] [-d] -p IMPORT_PATH [-b FOLDER_PATH] [-t {cjs,es,ts}]

This tool analyzes import module paths, to determine the resolved target
folder. For example, if the "semver" NPM package is installed, "trace-import
--path semver/index" will print output equivalent to the Node.js require.
resolve() API. If "@types/semver" is installed, then "trace-import
--resolution-type ts --path semver/index" will print the .d.ts file path that
would be resolved by a TypeScript import statement.

Optional arguments:
  -h, --help            Show this help message and exit.
  -d, --debug           Show the full call stack if an error occurs while
                        executing the tool
  -p IMPORT_PATH, --path IMPORT_PATH
                        The import module path to be analyzed. For example,
                        "example" in expressions such as: require("example");
                        require.resolve("example"); import { Thing } from
                        "example";
  -b FOLDER_PATH, --base-folder FOLDER_PATH
                        The "--path" string will be resolved as if the import
                        statement appeared in a script located in this folder.
                         If omitted, the current working directory is used.
  -t {cjs,es,ts}, --resolution-type {cjs,es,ts}
                        The type of module resolution to perform: "cjs" for
                        CommonJS, "es" for ES modules, or "ts" for TypeScript
                        typings. The default value is "cjs".

Sample outputs

These commands were invoked in the C:\Git\rushstack\apps\trace-import folder where trace-import is developed.

Resolving a CommonJS main index

trace-import --path semver

Sample output:

Base folder:             C:\Git\rushstack\apps\trace-import
Package name:            semver
Package subpath:         (not specified)

Resolving...

Package folder:          C:\Git\rushstack\common\temp\node_modules\.pnpm\semver@7.3.8\node_modules\semver
package.json:            semver (7.3.8)
Main index:              "main": "index.js"

Target path:             C:\Git\rushstack\common\temp\node_modules\.pnpm\semver@7.3.8\node_modules\semver\index.js

Resolving a CommonJS package subpath

trace-import --path typescript/bin/tsc

Sample output:

Base folder:             C:\Git\rushstack\apps\trace-import
Package name:            typescript
Package subpath:         bin/tsc

Resolving...

Package folder:          C:\Git\rushstack\common\temp\node_modules\.pnpm\typescript@4.8.4\node_modules\typescript
package.json:            typescript (4.8.4)

Target path:             C:\Git\rushstack\common\temp\node_modules\.pnpm\typescript@4.8.4\node_modules\typescript\bin\tsc

Resolving a TypeScript declaration

trace-import --resolution-type ts --path semver

Sample output:

Base folder:             C:\Git\rushstack\apps\trace-import
Package name:            semver
Package subpath:         (not specified)

Resolving...

Package folder:          C:\Git\rushstack\common\temp\node_modules\.pnpm\semver@7.3.8\node_modules\semver
package.json:            semver (7.3.8)
@types folder:           C:\Git\rushstack\common\temp\node_modules\.pnpm\@types+semver@7.3.5\node_modules\@types\semver
@types package.json:     @types/semver (7.3.5)
@types main index:       "types": "index.d.ts"

Target path:             C:\Git\rushstack\common\temp\node_modules\.pnpm\@types+semver@7.3.5\node_modules\@types\semver\index.d.ts

Resolving a relative path

trace-import --path ./config/rig.json

Sample output:

Base folder:             C:\Git\rushstack\apps\trace-import
Import path:             ./config/rig.json

The import path does not appear to reference an NPM package.
Resolving...

Target path:             C:\Git\rushstack\apps\trace-import\config\rig.json

Links

The trace-import tool is part of the Rush Stack family of projects.

0.3.41

3 days ago

0.3.40

29 days ago

0.3.39

2 months ago

0.3.38

2 months ago

0.3.37

2 months ago

0.3.36

2 months ago

0.3.35

2 months ago

0.3.34

2 months ago

0.3.33

2 months ago

0.3.32

2 months ago

0.3.31

2 months ago

0.3.30

3 months ago

0.3.29

3 months ago

0.3.28

3 months ago

0.3.27

3 months ago

0.3.25

3 months ago

0.3.24

3 months ago

0.3.23

3 months ago

0.3.22

3 months ago

0.3.21

3 months ago

0.3.20

4 months ago

0.3.19

4 months ago

0.3.18

4 months ago

0.3.17

4 months ago

0.3.16

4 months ago

0.3.15

5 months ago

0.3.14

5 months ago

0.3.13

5 months ago

0.2.27

9 months ago

0.2.26

9 months ago

0.2.25

10 months ago

0.2.24

10 months ago

0.2.23

10 months ago

0.2.22

10 months ago

0.2.21

10 months ago

0.2.20

10 months ago

0.2.19

10 months ago

0.2.18

10 months ago

0.2.17

10 months ago

0.2.16

10 months ago

0.3.0

8 months ago

0.3.6

8 months ago

0.3.5

8 months ago

0.3.8

7 months ago

0.3.7

7 months ago

0.3.2

8 months ago

0.3.1

8 months ago

0.3.4

8 months ago

0.3.3

8 months ago

0.3.9

7 months ago

0.3.12

6 months ago

0.3.11

6 months ago

0.3.10

6 months ago

0.2.15

11 months ago

0.2.14

11 months ago

0.2.13

11 months ago

0.2.12

11 months ago

0.2.11

11 months ago

0.2.10

11 months ago

0.2.1

12 months ago

0.2.0

12 months ago

0.2.7

11 months ago

0.1.16

1 year ago

0.2.6

11 months ago

0.1.17

1 year ago

0.2.9

11 months ago

0.1.18

12 months ago

0.2.8

11 months ago

0.2.3

11 months ago

0.2.2

11 months ago

0.2.5

11 months ago

0.2.4

11 months ago

0.1.12

1 year ago

0.1.13

1 year ago

0.1.14

1 year ago

0.1.15

1 year ago

0.1.10

1 year ago

0.1.11

1 year ago

0.1.8

1 year ago

0.1.7

1 year ago

0.1.9

1 year ago

0.1.6

1 year ago

0.1.5

1 year ago

0.1.4

1 year ago

0.1.3

1 year ago

0.1.2

1 year ago

0.1.1

1 year ago

0.1.0

1 year ago

0.0.0

1 year ago