Code Monkey home page Code Monkey logo

dts-bundle-webpack's Introduction

DTS plugin for WebPack

License: MIT

Inspired by this blog post.

This is wrapper for dts-bundle plugin to use inside WebPack build. Generates bundle from the .d.ts declaration files generated by a TypeSript compiler.

Installation

npm i dts-bundle-webpack --save-dev

Usage

const DtsBundleWebpack = require('dts-bundle-webpack')

// webpack config
{
  plugins: [
    new DtsBundleWebpack({options})
  ]
}

List of possible options are the same as for dts-bundle plugin:

Example of all options:

var opts = {

    // Required

    // name of module like in package.json
    // - used to declare module & import/require
    name: 'cool-project',
    // path to entry-point (generated .d.ts file for main module)
    // if you want to load all .d.ts files from a path recursively you can use "path/project/**/*.d.ts"
    //  ^ *** Experimental, TEST NEEDED, see "All .d.ts files" section 
    // - either relative or absolute
    main: 'build/index.d.ts',

    // Optional

    // base directory to be used for discovering type declarations (i.e. from this project itself)
    // - default: dirname of main
    baseDir: 'build',
    // path of output file. Is relative from baseDir but you can use absolute paths. 
    // if starts with "~/" then is relative to current path. See https://github.com/TypeStrong/dts-bundle/issues/26
    //  ^ *** Experimental, TEST NEEDED    
    // - default: "<baseDir>/<name>.d.ts"
    out: 'dist/cool-project.d.ts',
    // include typings outside of the 'baseDir' (i.e. like node.d.ts)
    // - default: false
    externals: false,
    // reference external modules as <reference path="..." /> tags *** Experimental, TEST NEEDED
    // - default: false
    referenceExternals: false,
    // filter to exclude typings, either a RegExp or a callback. match path relative to opts.baseDir
    // - RegExp: a match excludes the file
    // - function: (file:String, external:Boolean) return true to exclude, false to allow
    // - always use forward-slashes (even on Windows)
    // - default: *pass*
    exclude: /^defs\/$/,
    // delete all source typings (i.e. "<baseDir>/**/*.d.ts")
    // - default: false
    removeSource: false,
    // newline to use in output file
    newline: os.EOL,
    // indentation to use in output file
    // - default 4 spaces
    indent: '    ',
    // prefix for rewriting module names
    // - default ''
    prefix: '__',
    // separator for rewriting module 'path' names
    // - default: forward slash (like sub-modules)
    separator: '/',
    // enable verbose mode, prints detailed info about all references and includes/excludes
    // - default: false
    verbose: false,
    // emit although included files not found. See "Files not found" section. 
    // *** Experimental, TEST NEEDED
    // - default: false 
    emitOnIncludedFileNotFound: false,
    // emit although no included files not found. See "Files not found" section. 
    // *** Experimental, TEST NEEDED
    // - default: false     
    emitOnNoIncludedFileNotFound: false,    
    // output d.ts as designed for module folder. (no declare modules)
    outputAsModuleFolder: false,
    // path to file that contains the header
    // // insert a header in output file. i.e.: http://definitelytyped.org/guides/contributing.html#header
    // - default: null
    headerPath: "path/to/header/file",
    // text of the the header
    // doesn't work with headerPath
    // // insert a header in output file. i.e.: http://definitelytyped.org/guides/contributing.html#header
    // - default: ''
    headerTex: "" 
};

References

For all other information, please, go to original dts-bundle plugin.

dts-bundle-webpack's People

Contributors

appius avatar kube avatar vladyslav-ushakov-epamcom avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

dts-bundle-webpack's Issues

vulnerabilities with minimist dependency

npm audit report

minimist <=1.2.5
Severity: critical
Prototype Pollution in minimist - GHSA-xvch-5gv4-984h
Prototype Pollution in minimist - GHSA-vh95-rmgr-6w4m
No fix available
node_modules/minimist
detect-indent 0.2.0
Depends on vulnerable versions of minimist
node_modules/detect-indent
dts-bundle >=0.2.0
Depends on vulnerable versions of detect-indent
node_modules/dts-bundle
dts-bundle-webpack *
Depends on vulnerable versions of dts-bundle
node_modules/dts-bundle-webpack

4 vulnerabilities (3 moderate, 1 critical)

Is this project dead?

The latest commit is 3 years ago and there are a lot of dependencies that could just be updated...

1.0.1 release: TypeError: Cannot read property 'done' of undefined

The latest 1.0.1 release gives the following error:

C:\git\MyApp\Packages\mypackage\node_modules\webpack\bin\webpack.js:348
                        throw err;
                        ^

TypeError: Cannot read property 'done' of undefined
    at DtsBundlePlugin.apply (C:\git\MyApp\Packages\mypackage\node_modules\dts-bundle-webpack\index.js:13:24)
    at Compiler.apply (C:\git\MyApp\Packages\mypackage\node_modules\tapable\lib\Tapable.js:375:16)
    at webpack (C:\git\MyApp\Packages\mypackage\node_modules\webpack\lib\webpack.js:33:19)
    at processOptions (C:\git\MyApp\Packages\mypackage\node_modules\webpack\bin\webpack.js:335:15)
    at yargs.parse (C:\git\MyApp\Packages\mypackage\node_modules\webpack\bin\webpack.js:397:2)
    at Object.Yargs.self.parse (C:\git\MyApp\Packages\mypackage\node_modules\yargs\yargs.js:533:18)
    at Object.<anonymous> (C:\git\MyApp\Packages\mypackage\node_modules\webpack\bin\webpack.js:152:7)
    at Module._compile (internal/modules/cjs/loader.js:689:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10)
    at Module.load (internal/modules/cjs/loader.js:599:32)
    at tryModuleLoad (internal/modules/cjs/loader.js:538:12)
    at Function.Module._load (internal/modules/cjs/loader.js:530:3)
    at Function.Module.runMain (internal/modules/cjs/loader.js:742:12)
    at startup (internal/bootstrap/node.js:279:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:696:3)

Configuration:

  plugins: [
    new CleanWebpackPlugin([outputPathName]),
    new DtsBundleWebpack({
      name: packageName.replace('/','-'),
      main: outputPathName + "/**/*.d.ts",
      removeSource: true,
      out: "index.d.ts",
      outputAsModuleFolder: true
    }),
    new webpack.optimize.UglifyJsPlugin({})
  ]

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.