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
10 changes: 8 additions & 2 deletions lib/config-generator.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ class ConfigGenerator {
this.webpackConfig.runtimeConfig.devServerFinalIsHttps = false;
}

/**
* @type {import('webpack').Configuration}
*/
const config = {
context: this.webpackConfig.getContext(),
entry: this.buildEntryConfig(),
Expand Down Expand Up @@ -158,6 +161,9 @@ class ConfigGenerator {
}

buildEntryConfig() {
/**
* @type {Record<string, string[]>}
*/
const entry = {};

for (const [entryName, entryChunks] of this.webpackConfig.entries) {
Expand Down Expand Up @@ -544,7 +550,7 @@ class ConfigGenerator {
}

if (this.webpackConfig.shouldUseSingleRuntimeChunk) {
optimization.runtimeChunk = 'single';
optimization.runtimeChunk = /** @type {const} */ ('single');
}

optimization.splitChunks = applyOptionsCallback(
Expand All @@ -558,7 +564,7 @@ class ConfigGenerator {
buildCacheConfig() {
const cache = {};

cache.type = 'filesystem';
cache.type = /** @type {const} */ ('filesystem');
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this syntax with /** @type */ followed by a parenthesized expression as the JSDoc syntax for a cast.
Using const as type allows to do the same than as const in typescript

cache.buildDependencies = this.webpackConfig.persistentCacheBuildDependencies;

applyOptionsCallback(
Expand Down
3 changes: 3 additions & 0 deletions lib/loaders/css.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@ module.exports = {
getLoaders(webpackConfig, useCssModules = false) {
const usePostCssLoader = webpackConfig.usePostCssLoader;

/**
* @type {boolean|object}
*/
let modulesConfig = false;
if (useCssModules) {
modulesConfig = {
Expand Down