@@ -18,8 +18,6 @@ const schema = require("./options.json");
18
18
/** @typedef {import("webpack").Stats } Stats */
19
19
/** @typedef {import("webpack").MultiStats } MultiStats */
20
20
/** @typedef {import("os").NetworkInterfaceInfo } NetworkInterfaceInfo */
21
- /** @typedef {import("express").Request } Request */
22
- /** @typedef {import("express").Response } Response */
23
21
/** @typedef {import("express").NextFunction } NextFunction */
24
22
/** @typedef {import("express").RequestHandler } ExpressRequestHandler */
25
23
/** @typedef {import("express").ErrorRequestHandler } ExpressErrorRequestHandler */
@@ -42,14 +40,19 @@ const schema = require("./options.json");
42
40
43
41
/** @typedef {import("https").ServerOptions & { spdy?: { plain?: boolean | undefined, ssl?: boolean | undefined, 'x-forwarded-for'?: string | undefined, protocol?: string | undefined, protocols?: string[] | undefined }} } ServerOptions */
44
42
43
+ /** @typedef {import("express").Request } Request */
44
+ /** @typedef {import("express").Response } Response */
45
+
45
46
/**
46
- * @template Request, Response
47
- * @typedef {import("webpack-dev-middleware").Options<IncomingMessage, ServerResponse> } DevMiddlewareOptions
47
+ * @template {Request} T
48
+ * @template {Response} U
49
+ * @typedef {import("webpack-dev-middleware").Options<T, U> } DevMiddlewareOptions
48
50
*/
49
51
50
52
/**
51
- * @template Request, Response
52
- * @typedef {import("webpack-dev-middleware").Context<IncomingMessage, ServerResponse> } DevMiddlewareContext
53
+ * @template {Request} T
54
+ * @template {Response} U
55
+ * @typedef {import("webpack-dev-middleware").Context<T, U> } DevMiddlewareContext
53
56
*/
54
57
55
58
/**
@@ -1841,36 +1844,20 @@ class Server {
1841
1844
const { app, middleware } = this ;
1842
1845
1843
1846
/** @type {import("express").Application } */
1844
- ( app ) . get (
1845
- "/__webpack_dev_server__/sockjs.bundle.js" ,
1846
- /**
1847
- * @param {Request } req
1848
- * @param {Response } res
1849
- * @returns {void }
1850
- */
1851
- ( req , res ) => {
1852
- res . setHeader ( "Content-Type" , "application/javascript" ) ;
1847
+ ( app ) . get ( "/__webpack_dev_server__/sockjs.bundle.js" , ( req , res ) => {
1848
+ res . setHeader ( "Content-Type" , "application/javascript" ) ;
1853
1849
1854
- const clientPath = path . join ( __dirname , ".." , "client" ) ;
1850
+ const clientPath = path . join ( __dirname , ".." , "client" ) ;
1855
1851
1856
- res . sendFile ( path . join ( clientPath , "modules/sockjs-client/index.js" ) ) ;
1857
- } ,
1858
- ) ;
1852
+ res . sendFile ( path . join ( clientPath , "modules/sockjs-client/index.js" ) ) ;
1853
+ } ) ;
1859
1854
1860
1855
/** @type {import("express").Application } */
1861
- ( app ) . get (
1862
- "/webpack-dev-server/invalidate" ,
1863
- /**
1864
- * @param {Request } _req
1865
- * @param {Response } res
1866
- * @returns {void }
1867
- */
1868
- ( _req , res ) => {
1869
- this . invalidate ( ) ;
1856
+ ( app ) . get ( "/webpack-dev-server/invalidate" , ( _req , res ) => {
1857
+ this . invalidate ( ) ;
1870
1858
1871
- res . end ( ) ;
1872
- } ,
1873
- ) ;
1859
+ res . end ( ) ;
1860
+ } ) ;
1874
1861
1875
1862
/** @type {import("express").Application } */
1876
1863
( app ) . get ( "/webpack-dev-server/open-editor" , ( req , res ) => {
@@ -1886,74 +1873,65 @@ class Server {
1886
1873
} ) ;
1887
1874
1888
1875
/** @type {import("express").Application } */
1889
- ( app ) . get (
1890
- "/webpack-dev-server" ,
1891
- /**
1892
- * @param {Request } req
1893
- * @param {Response } res
1894
- * @returns {void }
1895
- */
1896
- ( req , res ) => {
1897
- /** @type {import("webpack-dev-middleware").API<Request, Response> }*/
1898
- ( middleware ) . waitUntilValid ( ( stats ) => {
1899
- res . setHeader ( "Content-Type" , "text/html" ) ;
1900
- // HEAD requests should not return body content
1901
- if ( req . method === "HEAD" ) {
1902
- res . end ( ) ;
1903
- return ;
1904
- }
1905
- res . write (
1906
- '<!DOCTYPE html><html><head><meta charset="utf-8"/></head><body>' ,
1907
- ) ;
1876
+ ( app ) . get ( "/webpack-dev-server" , ( req , res ) => {
1877
+ /** @type {import("webpack-dev-middleware").API<Request, Response> }*/
1878
+ ( middleware ) . waitUntilValid ( ( stats ) => {
1879
+ res . setHeader ( "Content-Type" , "text/html" ) ;
1880
+ // HEAD requests should not return body content
1881
+ if ( req . method === "HEAD" ) {
1882
+ res . end ( ) ;
1883
+ return ;
1884
+ }
1885
+ res . write (
1886
+ '<!DOCTYPE html><html><head><meta charset="utf-8"/></head><body>' ,
1887
+ ) ;
1908
1888
1909
- const statsForPrint =
1910
- typeof ( /** @type {MultiStats } */ ( stats ) . stats ) !== "undefined"
1911
- ? /** @type {MultiStats } */ ( stats ) . toJson ( ) . children
1912
- : [ /** @type {Stats } */ ( stats ) . toJson ( ) ] ;
1889
+ const statsForPrint =
1890
+ typeof ( /** @type {MultiStats } */ ( stats ) . stats ) !== "undefined"
1891
+ ? /** @type {MultiStats } */ ( stats ) . toJson ( ) . children
1892
+ : [ /** @type {Stats } */ ( stats ) . toJson ( ) ] ;
1913
1893
1914
- res . write ( `<h1>Assets Report:</h1>` ) ;
1894
+ res . write ( `<h1>Assets Report:</h1>` ) ;
1915
1895
1916
- /**
1917
- * @type {StatsCompilation[] }
1918
- */
1919
- ( statsForPrint ) . forEach ( ( item , index ) => {
1920
- res . write ( "<div>" ) ;
1921
-
1922
- const name =
1923
- // eslint-disable-next-line no-nested-ternary
1924
- typeof item . name !== "undefined"
1925
- ? item . name
1926
- : /** @type {MultiStats } */ ( stats ) . stats
1927
- ? `unnamed[${ index } ]`
1928
- : "unnamed" ;
1929
-
1930
- res . write ( `<h2>Compilation: ${ name } </h2>` ) ;
1931
- res . write ( "<ul>" ) ;
1932
-
1933
- const publicPath =
1934
- item . publicPath === "auto" ? "" : item . publicPath ;
1935
-
1936
- for ( const asset of /** @type {NonNullable<StatsCompilation["assets"]> } */ (
1937
- item . assets
1938
- ) ) {
1939
- const assetName = asset . name ;
1940
- const assetURL = `${ publicPath } ${ assetName } ` ;
1941
-
1942
- res . write (
1943
- `<li>
1896
+ /**
1897
+ * @type {StatsCompilation[] }
1898
+ */
1899
+ ( statsForPrint ) . forEach ( ( item , index ) => {
1900
+ res . write ( "<div>" ) ;
1901
+
1902
+ const name =
1903
+ // eslint-disable-next-line no-nested-ternary
1904
+ typeof item . name !== "undefined"
1905
+ ? item . name
1906
+ : /** @type {MultiStats } */ ( stats ) . stats
1907
+ ? `unnamed[${ index } ]`
1908
+ : "unnamed" ;
1909
+
1910
+ res . write ( `<h2>Compilation: ${ name } </h2>` ) ;
1911
+ res . write ( "<ul>" ) ;
1912
+
1913
+ const publicPath = item . publicPath === "auto" ? "" : item . publicPath ;
1914
+
1915
+ for ( const asset of /** @type {NonNullable<StatsCompilation["assets"]> } */ (
1916
+ item . assets
1917
+ ) ) {
1918
+ const assetName = asset . name ;
1919
+ const assetURL = `${ publicPath } ${ assetName } ` ;
1920
+
1921
+ res . write (
1922
+ `<li>
1944
1923
<strong><a href="${ assetURL } " target="_blank">${ assetName } </a></strong>
1945
1924
</li>` ,
1946
- ) ;
1947
- }
1948
-
1949
- res . write ( "</ul>" ) ;
1950
- res . write ( "</div>" ) ;
1951
- } ) ;
1925
+ ) ;
1926
+ }
1952
1927
1953
- res . end ( "</body></html>" ) ;
1928
+ res . write ( "</ul>" ) ;
1929
+ res . write ( "</div>" ) ;
1954
1930
} ) ;
1955
- } ,
1956
- ) ;
1931
+
1932
+ res . end ( "</body></html>" ) ;
1933
+ } ) ;
1934
+ } ) ;
1957
1935
}
1958
1936
1959
1937
/**
0 commit comments