CC 4.0 License

The content of this section is derived from the content of the following links and is subject to the CC BY 4.0 license.

The following contents can be assumed to be the result of modifications and deletions based on the original contents if not specifically stated.

Module Variables

This section covers all variables available in code compiled with webpack. Modules will have access to certain data from the compilation process through module and other variables. (webpack-specific)

Indicates whether or not Hot Module Replacement is enabled and provides an interface to the process. See the HMR API page for details.

import.meta.webpackHot (webpack-specific)

An alias for, however import.meta.webpackHot can be used in strict ESM while can't.

__dirname (NodeJS)

Depending on the configuration option node.__dirname:

If used inside an expression that is parsed by the Parser, the configuration option is treated as true.

__resourceQuery (webpack-specific)

The resource query of the current module. If the following require call was made, then the query string would be available in file.js.

__resourceQuery === '?test';

__webpack_modules__ (webpack-specific)

Access to the internal object of all modules.

__webpack_hash__ (webpack-specific)

It provides access to the hash of the compilation.

__webpack_public_path__ (webpack-specific)

Equals the configuration option's output.publicPath.

__webpack_chunkname__ (webpack-specific)

Access to name of current chunk.

__webpack_runtime_id__ (webpack-specific)

Access the runtime id of current entry.