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.
While Rspack supports multiple module syntaxes, we recommend following a single syntax for consistency and to avoid odd behaviors/bugs.
Rspack support ES6 module syntax natively, you can use static
Rspack is also support
CommonJS syntax natively, you can use
Rspack supports importing DataURI modules using the
In addition, Base64 encoded requests are also supported:
The DataURI module can be used as a method to implement virtual modules, such as combining with a Loader to dynamically load custom modules at runtime.
Aside from the module syntaxes described above, Rspack also support some webpack-specific methods.
require.context( (directory: String), (includeSubdirs: Boolean) /* optional, default true */, (filter: RegExp) /* optional, default /^\.\/.*$/, any file */, (mode: String) /* optional, 'sync' | 'eager' | 'weak' | 'lazy' | 'lazy-once', default 'sync' */ );
Specify a whole group of dependencies using a path to the
directory, an option to
includeSubdirs, a filter for more fine grained control of the modules included, and a mode to define the way how loading will work.
If mode is set to 'lazy', the underlying modules will be loaded asynchronously.
Indicates whether or not Hot Module Replacement is enabled and provides an interface to the process. See the HMR API page for details.
An alias for
import.meta.webpackHot can be used in strict ESM while module.hot can't.
Depending on the configuration option
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';
Access to the internal object of all modules.
It provides access to the hash of the compilation.
Equals the configuration option's