Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions types/webpack-react-component-name/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
*
!**/*.d.ts
!**/*.d.cts
!**/*.d.mts
!**/*.d.*.ts
41 changes: 41 additions & 0 deletions types/webpack-react-component-name/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import { Compiler, WebpackPluginInstance } from "webpack";

declare namespace WebpackReactComponentNamePlugin {
/**
* If the item is a string, it will use standard glob syntax. If the item is a Regular Expression, the path will be tested against it.
* If the item is a function, the path will be passed into it for testing.
*/
type PathMatch = string | RegExp | ((path: string) => boolean);

interface Options {
/**
* If set true, the plugin will name the components exported from node_modules
* @defaultValue false
*/
parseDependencies?: boolean;

/**
* If the path matches any of the elements in this array, it will be included if it isn't explicitly excluded
* @defaultValue []
*/
include?: readonly PathMatch[];

/**
* If the path matches any of the elements in this array, it will be excluded
* @defaultValue []
*/
exclude?: readonly PathMatch[];
}
}

/** Normally React component names are minified during compilation. This plugin makes these component names available through the `displayName` property in production bundles */
declare class WebpackReactComponentNamePlugin implements WebpackPluginInstance {
constructor(options?: WebpackReactComponentNamePlugin.Options);

/**
* The run point of the plugin, required method.
*/
apply: (compiler: Compiler) => void;
}

export = WebpackReactComponentNamePlugin;
20 changes: 20 additions & 0 deletions types/webpack-react-component-name/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"private": true,
"name": "@types/webpack-react-component-name",
"version": "5.0.9999",
"projects": [
"https://github.com/runreflect/webpack-react-component-name#readme"
],
"devDependencies": {
"@types/webpack-react-component-name": "workspace:."
},
"owners": [
{
"name": "Dorian Latchague",
"githubUsername": "DorianLatchague"
}
],
"dependencies": {
"webpack": "^5"
}
}
19 changes: 19 additions & 0 deletions types/webpack-react-component-name/tsconfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
{
"compilerOptions": {
"module": "node16",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictFunctionTypes": true,
"strictNullChecks": true,
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"webpack-react-component-name-tests.ts"
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
import { Configuration, WebpackPluginInstance } from "webpack";
import WebpackReactComponentNamePlugin, { type Options, type PathMatch } from "webpack-react-component-name";

const plugin: WebpackPluginInstance = new WebpackReactComponentNamePlugin();

const plugin2: WebpackPluginInstance = new WebpackReactComponentNamePlugin(undefined);

const plugin3: WebpackPluginInstance = new WebpackReactComponentNamePlugin({});

const manyOptions: Options[] = [{}, {
parseDependencies: undefined,
include: undefined,
exclude: undefined,
}, {
parseDependencies: false,
}, {
parseDependencies: true,
}, {
include: [],
}, {
exclude: [],
}];

const pathMatches: PathMatch[] = ["test", /test/, (path: string) => path === "test"];

const configuration: Configuration = {
plugins: [plugin],
};