npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@component-controls/follow-imports

v4.0.3

Published

follow module imports until finding the file exporting the keyword

Downloads

14

Readme

Table of contents

Overview

follow file imports using pabel ast parsing to find the file where an imported keyword was exported from (and is defined in).

Installation

$ npm install @component-controls/follow-imports --save-dev

API

defaultParserOptions

interface

defined in @component-controls/follow-imports/misc/follow-imports/src/consts.ts

properties

| Name | Type | Parent | Default | Description | | -------------------------------- | ------------------------------------------- | --------------- | ---------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | allowImportExportEverywhere | boolean | ParserOptions | | By default, import and export declarations can only appear at a program's top level. Setting this option to true allows them anywhere where a statement is allowed. | | allowAwaitOutsideFunction | boolean | ParserOptions | | By default, await use is not allowed outside of an async function. Set this to true to accept such code. | | allowReturnOutsideFunction | boolean | ParserOptions | | By default, a return statement at the top level raises an error. Set this to true to accept such code. | | allowSuperOutsideMethod | boolean | ParserOptions | | | | allowUndeclaredExports | boolean | ParserOptions | | By default, exported identifiers must refer to a declared variable. Set this to true to allow export statements to reference undeclared variables. | | attachComment | boolean | ParserOptions | | By default, Babel attaches comments to adjacent AST nodes. When this option is set to false, comments are not attached. It can provide up to 30% performance improvement when the input code has many comments. | | errorRecovery | boolean | ParserOptions | | By default, Babel always throws an error when it finds some invalid code. When this option is set to true, it will store the parsing error and try to continue parsing the invalid input file. | | sourceType | "script" | "module" | "unambiguous" | ParserOptions | "module" | Indicate the mode the code should be parsed in. Can be one of "script", "module", or "unambiguous". Defaults to "script". "unambiguous" will make @babel/parser attempt to guess, based on the presence of ES6 import or export statements. Files with ES6 imports and exports are considered "module" and are otherwise "script". | | sourceFilename | string | ParserOptions | | Correlate output AST nodes with their source filename. Useful when generating code and source maps from the ASTs of multiple input files. | | startLine | number | ParserOptions | | By default, the first line of code parsed is treated as line 1. You can provide a line number to alternatively start with. Useful for integration with other source tools. | | plugins | ParserPlugin[] | ParserOptions | | Array containing the plugins that you want to enable. | | strictMode | boolean | ParserOptions | | Should the parser work in strict mode. Defaults to true if sourceType === 'module'. Otherwise, false. | | ranges | boolean | ParserOptions | | Adds a ranges property to each node: [node.start, node.end] | | tokens | boolean | ParserOptions | | Adds all parsed tokens to a tokens property on the File node. | | createParenthesizedExpressions | boolean | ParserOptions | | By default, the parser adds information about parentheses by setting extra.parenthesized to true as needed. When this option is true the parser creates ParenthesizedExpression AST nodes instead of using the extra property. |

defaultResolveOptions

interface

defined in @component-controls/follow-imports/misc/follow-imports/src/consts.ts

extends

Opts

properties

| Name | Type | Parent | Default | Description | | ------------------ | ------------------------------------------------------------------------------------------------------------- | ---------- | --------------------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | readFileSync | function (file*: stringcharset*: string) => string | Buffer | SyncOpts | | how to read files synchronously (defaults to fs.readFileSync) | | isFile | function (file*: string) => boolean | SyncOpts | | function to synchronously test whether a file exists | | basedir | string | Opts | | directory to begin resolving from (defaults to __dirname) | | package | any | Opts | | package.json data applicable to the module being loaded | | extensions | string | ReadonlyArray<string> | Opts | [object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object],[object Object] | array of file extensions to search in order (defaults to ['.js']) | | packageFilter | function (pkg*: anypkgfile*: string) => any | Opts | | transform the parsed package.json contents before looking at the "main" field | | pathFilter | function (pkg*: anypath*: stringrelativePath*: string) => string | Opts | | transform a path within a package | | paths | string | ReadonlyArray<string> | Opts | | require.paths array to use if nothing is found on the normal node_modules recursive walk (probably don't use this) | | moduleDirectory | string | ReadonlyArray<string> | Opts | | directory (or directories) in which to recursively look for modules. (default to 'node_modules') | | preserveSymlinks | boolean | Opts | | if true, doesn't resolve basedir to real path before resolving. This is the way Node resolves dependencies when executed with the --preserve-symlinks flag. Note: this property is currently true by default but it will be changed to false in the next major version because Node's resolution algorithm does not preserve symlinks by default. |

ExportType

interface

defined in @component-controls/follow-imports/misc/follow-imports/src/consts.ts

properties

| Name | Type | Description | | --------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------------------------------------------------------------- | | name* | string | | | internalName* | string | | | loc | SourceLocationstart*line*: numbercolumn*: numberend*line*: numbercolumn*: number | | | from | string | in case of export { Button } from './button-named-export'; specifies the import from statememnt | | node | any | | | path | any | |

parseFile

function

defined in @component-controls/follow-imports/misc/follow-imports/src/ast_store.ts

parameters

| Name | Type | Default | | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ------- | | filePath* | string | | | options | parser.ParserOptionsallowImportExportEverywhere: booleanallowAwaitOutsideFunction: booleanallowReturnOutsideFunction: booleanallowSuperOutsideMethod: booleanallowUndeclaredExports: booleanattachComment: booleanerrorRecovery: booleansourceType: "script" | "module" | "unambiguous"sourceFilename: stringstartLine: numberplugins: ParserPlugin[]strictMode: booleanranges: booleantokens: booleancreateParenthesizedExpressions: boolean | | | sourceCode | string | | | cache* | boolean | true | | returns | CachePropsast*type*: stringprogram*type*: stringbody*: Statement[]directives*: Directive[]sourceType*: "script" | "module"interpreter: InterpreterDirective | nullsourceFile*: stringleadingComments*: ReadonlyArray<Comment> | nullinnerComments*: ReadonlyArray<Comment> | nulltrailingComments*: ReadonlyArray<Comment> | nullstart*: number | nullend*: number | nullloc*: SourceLocation | nullrange: [number, number]extra: Record<string, unknown>comments: ((CommentBlock, CommentLine))[] | nulltokens: any[] | nullleadingComments*: ReadonlyArray<Comment> | nullinnerComments*: ReadonlyArray<Comment> | nulltrailingComments*: ReadonlyArray<Comment> | nullstart*: number | nullend*: number | nullloc*: SourceLocation | nullrange: [number, number]extra: Record<string, unknown>source*: stringimports: ImportTypesexports: ExportTypesimportAliases: Record<string, string> | |

extractImports

function

defined in @component-controls/follow-imports/misc/follow-imports/src/extract-imports.ts

parameters

| Name | Type | | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | fileName* | string | | options* | ParserOptionsallowImportExportEverywhere: booleanallowAwaitOutsideFunction: booleanallowReturnOutsideFunction: booleanallowSuperOutsideMethod: booleanallowUndeclaredExports: booleanattachComment: booleanerrorRecovery: booleansourceType: "script" | "module" | "unambiguous"sourceFilename: stringstartLine: numberplugins: ParserPlugin[]strictMode: booleanranges: booleantokens: booleancreateParenthesizedExpressions: boolean | | returns | ImportTypes |

extractExports

function

defined in @component-controls/follow-imports/misc/follow-imports/src/extract-exports.ts

parameters

| Name | Type | | ----------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | fileName* | string | | options* | ParserOptionsallowImportExportEverywhere: booleanallowAwaitOutsideFunction: booleanallowReturnOutsideFunction: booleanallowSuperOutsideMethod: booleanallowUndeclaredExports: booleanattachComment: booleanerrorRecovery: booleansourceType: "script" | "module" | "unambiguous"sourceFilename: stringstartLine: numberplugins: ParserPlugin[]strictMode: booleanranges: booleantokens: booleancreateParenthesizedExpressions: boolean | | returns | ExportTypes |

sourceLocation

function

defined in @component-controls/follow-imports/misc/follow-imports/src/source-location.ts

parameters

| Name | Type | | --------- | ------------------------------- | | loc* | SourceLocation | null | | returns | SourceLocation | undefined |

getASTSource

function

defined in @component-controls/follow-imports/misc/follow-imports/src/source.ts

parameters

| Name | Type | | --------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | source | string | | loc | SourceLocationstart*line*: numbercolumn*: numberend*line*: numbercolumn*: number | | returns | string | undefined |

FollowImportType

interface

defined in @component-controls/follow-imports/misc/follow-imports/src/index.ts

properties

| Name | Type | | -------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | exportedAs | string | | internalName | string | | from | string | | filePath | string | | importedName | string | | loc | SourceLocationstart*line*: numbercolumn*: numberend*line*: numbercolumn*: number | | source | string | | imported | string | | imports | ImportTypes | | node | any | | path | any |

EXPORT_ALL

string = "*"

defined in @component-controls/follow-imports/misc/follow-imports/src/consts.ts

EXPORT_DEFAULT

string = "default"

defined in @component-controls/follow-imports/misc/follow-imports/src/consts.ts

IMPORT_NAMESPACE

string = "namespace"

defined in @component-controls/follow-imports/misc/follow-imports/src/consts.ts

NamedExportTypes

interface

defined in @component-controls/follow-imports/misc/follow-imports/src/consts.ts

properties

| Name | Type | | ------ | ---------------------------------------------- | | key* | [string]: ExportType |

ExportTypes

interface

defined in @component-controls/follow-imports/misc/follow-imports/src/consts.ts

properties

| Name | Type | | ---------- | --------------------------------------- | | default* | NamedExportTypes | | named* | NamedExportTypes |

followImports

function

defined in @component-controls/follow-imports/misc/follow-imports/src/index.ts

parameters

| Name | Type | | ------------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | | importName* | string | | filePath* | string | | options | typeparserallowImportExportEverywhere: booleanallowAwaitOutsideFunction: booleanallowReturnOutsideFunction: booleanallowSuperOutsideMethod: booleanallowUndeclaredExports: booleanattachComment: booleanerrorRecovery: booleansourceType: "script" | "module" | "unambiguous"sourceFilename: stringstartLine: numberplugins: ParserPlugin[]strictMode: booleanranges: booleantokens: booleancreateParenthesizedExpressions: booleanresolverreadFileSync: function (file*: stringcharset*: string) => string | BufferisFile: function (file*: string) => booleanbasedir: stringpackage: anyextensions: string | ReadonlyArray<string>packageFilter: function (pkg*: anypkgfile*: string) => anypathFilter: function (pkg*: anypath*: stringrelativePath*: string) => stringpaths: string | ReadonlyArray<string>moduleDirectory: string | ReadonlyArray<string>preserveSymlinks: booleanresolveFile: function (importName*: stringfilePath*: string) => string | undefined | | returns | FollowImportType | undefined |

ImportType

interface

defined in @component-controls/follow-imports/misc/follow-imports/src/consts.ts

properties

| Name | Type | Description | | --------------- | -------- | --------------------------------------------------------------------------------- | | name* | string | component name | | importedName* | string | importedName - the original named import that was aliased | | from* | string | imported from | | typesFile | string | imported from alias file name ie '/component-controls/core/store/dist/index.d.ts' | | componentKey | string | key into components table |

ImportTypes

interface

defined in @component-controls/follow-imports/misc/follow-imports/src/consts.ts

properties

| Name | Type | | ------ | ---------------------------------------------- | | key* | [string]: ImportType |