Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

parse-imports-ts

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

parse-imports-ts

## Detects top level imports

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

Identifies the packages imported form a TypeScript file

Detects top level imports

import { parse } from "parse-imports-ts";

const input = `
    import "import _ from "lodash";"
    import 'core-js';
`;
const output = parse(input);
console.log(JSON.stringify(output));
//[
//  { name: "lodash", type: 0},
//  { name: "core-js", type: 0}
//]

Detects dynamic imports

import { parse } from "parse-imports-ts";

const input = `
    export function myFunction() {
        return import("my-package");
    }
`;
const output = parse(input);
console.log(JSON.stringify(output));
//[
//  { name: "my-package", type: 0}
//]

Detects type imports

import { parse } from "parse-imports-ts";

const input = `
    import type { MyType } from "my-pacakge";
`;
const output = parse(input);
console.log(JSON.stringify(output));
//[
//  { name: "my-package", type: 1}
//]

FAQs

Package last updated on 21 Jan 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc