From ace213e45415b892e7ff6ec8f96dd156498e7ab9 Mon Sep 17 00:00:00 2001 From: "alexander.akait" Date: Tue, 16 Apr 2024 16:49:46 +0300 Subject: [PATCH] fix: types --- src/loader.js | 2 +- test/HMR.test.js | 2 +- types/loader.d.ts | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 37 insertions(+), 2 deletions(-) diff --git a/src/loader.js b/src/loader.js index f551e7a5..e6f7475e 100644 --- a/src/loader.js +++ b/src/loader.js @@ -563,4 +563,4 @@ function loader(content) { module.exports = loader; module.exports.pitch = pitch; -module.exports.hotLoaderForTest = hotLoader; +module.exports.hotLoader = hotLoader; diff --git a/test/HMR.test.js b/test/HMR.test.js index 6a37ce04..1c781d9b 100644 --- a/test/HMR.test.js +++ b/test/HMR.test.js @@ -5,7 +5,7 @@ /* eslint-disable no-console */ import hotModuleReplacement from "../src/hmr/hotModuleReplacement"; -import { hotLoaderForTest as hotLoader } from "../src/loader"; +import { hotLoader } from "../src/loader"; function getLoadEvent() { const event = document.createEvent("Event"); diff --git a/types/loader.d.ts b/types/loader.d.ts index a007af71..64ba61f4 100644 --- a/types/loader.d.ts +++ b/types/loader.d.ts @@ -10,6 +10,7 @@ declare function loader( declare namespace loader { export { pitch, + hotLoader, Schema, Compiler, Compilation, @@ -33,6 +34,40 @@ declare function pitch( this: import("webpack").LoaderContext, request: string ): void; +/** @typedef {import("schema-utils/declarations/validate").Schema} Schema */ +/** @typedef {import("webpack").Compiler} Compiler */ +/** @typedef {import("webpack").Compilation} Compilation */ +/** @typedef {import("webpack").Chunk} Chunk */ +/** @typedef {import("webpack").Module} Module */ +/** @typedef {import("webpack").sources.Source} Source */ +/** @typedef {import("webpack").AssetInfo} AssetInfo */ +/** @typedef {import("webpack").NormalModule} NormalModule */ +/** @typedef {import("./index.js").LoaderOptions} LoaderOptions */ +/** @typedef {{ [key: string]: string | function }} Locals */ +/** @typedef {any} TODO */ +/** + * @typedef {Object} Dependency + * @property {string} identifier + * @property {string | null} context + * @property {Buffer} content + * @property {string} media + * @property {string} [supports] + * @property {string} [layer] + * @property {Buffer} [sourceMap] + */ +/** + * @param {string} content + * @param {{ loaderContext: import("webpack").LoaderContext, options: LoaderOptions, locals: Locals | undefined }} context + * @returns {string} + */ +declare function hotLoader( + content: string, + context: { + loaderContext: import("webpack").LoaderContext; + options: LoaderOptions; + locals: Locals | undefined; + } +): string; type Schema = import("schema-utils/declarations/validate").Schema; type Compiler = import("webpack").Compiler; type Compilation = import("webpack").Compilation;