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

dts-module-filter

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dts-module-filter

convert module-dts to namespace-dts

  • 1.0.0
  • unpublished
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
Maintainers
1
Weekly downloads
 
Created
Source

dts-module-filter

Description

  • Convert module-dts to namespace-dts
  • Remove unnecessary imports from module-dts

usage

  • Definition
/**
 *convert module-dts to namespace-dts
 *
 * @export
 * @param {{
 *   src: string; // Source file path
 *   dest?: string; // Path of output file
 *   removeImport?:RegExp; // Conditions of import removal
 *   namespace?: string; // Name of the namespace
 * }} params
 */
export function DtsModuleFilter(params: {
  src: string;
  dest?: string;
  removeImport?:RegExp;
  namespace?: string;
})
  • call

When removing only a specific impot

filter.DtsModuleFilter({
  src: path.resolve(__dirname, "jwf.d.ts"),
  dest: path.resolve(__dirname, "temp.d.ts"), // Default is overwrite
  removeImport:/\.(scss|css)$/
});

When converting to namespace

filter.DtsModuleFilter({
  src: path.resolve(__dirname, "jwf.d.ts"),
  dest: path.resolve(__dirname, "temp.d.ts"), // Default is overwrite
  namespace:"JWF"
});

When using from WebPack

This is the description method for converting to namespace by dts-module-filter after combining files using dts-bundle

webpack.config.js

class DtsBundlePlugin {
  constructor(params) {
    this.params = params;
  }
  apply(compiler) {
    compiler.hooks.afterEmit.tap("DtsBundlePlugin", () => {
      const params = this.params;
      require("dts-bundle").bundle(params);
      require("dts-module-filter").DtsModuleFilter({
        src: params.out,
        namespace: params.name
      });
    });
  }
}

module.exports = {
  plugins: [
    new DtsBundlePlugin({
      name: "JWF",
      main: path.resolve(__dirname, "SRC-DTS"),
      out: path.resolve(__dirname, "DEST-DTS")
    })
  ]
};

License

  • MIT License

FAQs

Package last updated on 25 Jul 2019

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