🚀 Big News:Socket Has Acquired Secure Annex.Learn More →
Socket
Book a DemoSign in
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
Package was removed
Sorry, it seems this package was removed from the registry

dts-module-filter

convert module-dts to namespace-dts

unpublished
latest
Source
npmnpm
Version
1.0.0
Version published
Maintainers
1
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