feat(name-all-modules-plugin): new type definition (#44217)

Minimal defintion file for small but useful webpack plugin.

https://www.npmjs.com/package/name-all-modules-plugin
https://github.com/timse/name-all-modules-plugin

Thanks!
This commit is contained in:
Piotr Błażejewicz (Peter Blazejewicz) 2020-04-27 13:59:39 +02:00 committed by GitHub
parent ca14596212
commit b3bf6a93a3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 77 additions and 0 deletions

View File

@ -0,0 +1,17 @@
// Type definitions for name-all-modules-plugin 1.0
// Project: https://github.com/timse/name-all-modules-plugin#readme
// Definitions by: Piotr Błażejewicz <https://github.com/peterblazejewicz>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Plugin } from 'webpack';
/**
* Names all remaining modules that do not get named via NamedModulesPlugin
*/
declare class NameAllModulesPlugin extends Plugin {}
/**
* Names all remaining modules that do not get named via NamedModulesPlugin
* {@link https://github.com/timse/name-all-modules-plugin}
*/
export = NameAllModulesPlugin;

View File

@ -0,0 +1,36 @@
/// <reference types="node" />
import path = require('path');
import { NamedModulesPlugin, NamedChunksPlugin } from 'webpack';
import NameAllModulesPlugin = require('name-all-modules-plugin');
module.exports = {
entry: {
main: './src/foo',
other: './src/foo-two',
vendor: ['preact'],
},
output: {
path: path.join(__dirname, 'dist'),
filename: '[name].[chunkhash].js',
},
externals: {
jquery: 'jQuery',
},
plugins: [
new NamedModulesPlugin(),
new NamedChunksPlugin(chunk => {
if (chunk.name) {
return chunk.name;
}
return chunk.modules.map((m: any) => path.relative(m.context, m.request)).join('_');
}),
// some other declaration
// ....
// and then
new NameAllModulesPlugin(),
],
};
NameAllModulesPlugin; // $ExpectType typeof NameAllModulesPlugin
new NameAllModulesPlugin(); // $ExpectType NameAllModulesPlugin

View File

@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"name-all-modules-plugin-tests.ts"
]
}

View File

@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }