### JSONP Library Output Example Source: https://rspack.rs/config/output Example of the generated JSONP wrapper output. ```javascript MyLibrary(_entry_return_); ``` -------------------------------- ### Install @module-federation/runtime-tools with deno Source: https://rspack.rs/plugins/webpack/module-federation-plugin Install the runtime package required for Module Federation support using deno. ```sh deno add npm:@module-federation/runtime-tools ``` -------------------------------- ### Install Dependencies with bun Source: https://rspack.rs/guide/migration/storybook Install the necessary packages for migrating to storybook-rsbuild using bun. ```sh bun add storybook-react-rsbuild @rsbuild/core @rsbuild/plugin-react -D ``` -------------------------------- ### Install @module-federation/runtime-tools with bun Source: https://rspack.rs/plugins/webpack/module-federation-plugin Install the runtime package required for Module Federation support using bun. ```sh bun add @module-federation/runtime-tools ``` -------------------------------- ### Install next-rspack with bun Source: https://rspack.rs/guide/tech/next Install the next-rspack package as a development dependency using bun. ```sh bun add next-rspack -D ``` -------------------------------- ### Install Rspack with bun Source: https://rspack.rs/guide/migration/webpack Install Rspack core, CLI, and dev-server dependencies using bun. ```sh bun add @rspack/core @rspack/cli @rspack/dev-server -D ``` -------------------------------- ### Install css-loader and style-loader with deno Source: https://rspack.rs/guide/tech/css Install the necessary loaders for CSS processing using deno. ```sh deno add npm:css-loader npm:style-loader -D ``` -------------------------------- ### Install css-loader and style-loader with bun Source: https://rspack.rs/guide/tech/css Install the necessary loaders for CSS processing using bun. ```sh bun add css-loader style-loader -D ``` -------------------------------- ### Install css-loader with deno Source: https://rspack.rs/guide/tech/css Install the css-loader package using deno for CSS processing. ```sh deno add npm:css-loader -D ``` -------------------------------- ### Install @module-federation/runtime-tools with pnpm Source: https://rspack.rs/plugins/webpack/module-federation-plugin Install the runtime package required for Module Federation support using pnpm. ```sh pnpm add @module-federation/runtime-tools ``` -------------------------------- ### Install Dependencies with deno Source: https://rspack.rs/guide/migration/storybook Install the necessary packages for migrating to storybook-rsbuild using deno. ```sh deno add npm:storybook-react-rsbuild npm:@rsbuild/core npm:@rsbuild/plugin-react -D ``` -------------------------------- ### Install Rspack with deno Source: https://rspack.rs/guide/migration/webpack Install Rspack core, CLI, and dev-server dependencies using deno. ```sh deno add npm:@rspack/core npm:@rspack/cli npm:@rspack/dev-server -D ``` -------------------------------- ### Install Rspack Core and CLI with deno Source: https://rspack.rs/guide/start/quick-start Install @rspack/core and @rspack/cli as development dependencies using deno. ```bash deno add npm:@rspack/core npm:@rspack/cli -D ``` -------------------------------- ### Install css-loader with bun Source: https://rspack.rs/guide/tech/css Install the css-loader package using bun for CSS processing. ```sh bun add css-loader -D ``` -------------------------------- ### Install Rspack Core and CLI with bun Source: https://rspack.rs/guide/start/quick-start Install @rspack/core and @rspack/cli as development dependencies using bun. ```bash bun add @rspack/core @rspack/cli -D ``` -------------------------------- ### Install next-rspack with deno Source: https://rspack.rs/guide/tech/next Install the next-rspack package as a development dependency using deno. ```sh deno add npm:next-rspack -D ``` -------------------------------- ### Install @module-federation/runtime-tools with npm Source: https://rspack.rs/plugins/webpack/module-federation-plugin Install the runtime package required for Module Federation support using npm. ```sh npm add @module-federation/runtime-tools ``` -------------------------------- ### Install css-loader and style-loader with npm Source: https://rspack.rs/guide/tech/css Install the necessary loaders for CSS processing using npm. ```sh npm add css-loader style-loader -D ``` -------------------------------- ### Install @module-federation/runtime-tools with yarn Source: https://rspack.rs/plugins/webpack/module-federation-plugin Install the runtime package required for Module Federation support using yarn. ```sh yarn add @module-federation/runtime-tools ``` -------------------------------- ### Install @rspack/core with bun Source: https://rspack.rs/api/javascript-api/index Install the Rspack core package as a development dependency using bun. ```sh bun add @rspack/core -D ``` -------------------------------- ### System.register Module Output Example Source: https://rspack.rs/config/output Example of the generated System.register module output when library type is set to 'system'. ```javascript System.register([], function (__WEBPACK_DYNAMIC_EXPORT__, __system_context__) { return { execute: function () { // ... }, }; }); ``` -------------------------------- ### Install Less and Less Loader with bun Source: https://rspack.rs/guide/tech/css Install the necessary packages for using Less with Rspack using bun. ```sh bun add less less-loader -D ``` -------------------------------- ### Install Rspack with yarn Source: https://rspack.rs/guide/migration/webpack Install Rspack core, CLI, and dev-server dependencies using yarn. ```sh yarn add @rspack/core @rspack/cli @rspack/dev-server -D ``` -------------------------------- ### CSS Example: style.css Source: https://rspack.rs/guide/tech/css Example of a plain CSS file with a local class and a globally scoped local class. ```css .button { color: red; } :local(.title) { color: blue; } ``` -------------------------------- ### Install SWC Styled Components Plugin Source: https://rspack.rs/blog/announcing-1-0-alpha Install the SWC plugin for Styled Components as a development dependency. ```bash npm i @swc/plugin-styled-components -D ``` -------------------------------- ### Install Less and Less Loader with Deno Source: https://rspack.rs/guide/tech/css Install the necessary packages for using Less with Rspack using Deno. ```sh deno add npm:less npm:less-loader -D ``` -------------------------------- ### Install @rspack/core with deno Source: https://rspack.rs/api/javascript-api/index Install the Rspack core package as a development dependency using deno. ```sh deno add npm:@rspack/core -D ``` -------------------------------- ### Install Rspack Dev Server (bun) Source: https://rspack.rs/api/cli Installs the `@rspack/dev-server` dependency using bun, which is required for the `rspack dev` command. ```sh bun add @rspack/dev-server -D ``` -------------------------------- ### CJS Plugin Structure Source: https://rspack.rs/guide/features/plugin Implement the `apply` method to hook into Rspack's compilation process using CJS syntax. This example logs a message when compilation starts. ```javascript const PLUGIN_NAME = 'MyPlugin'; class MyPlugin { apply(compiler) { compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => { console.log('The Rspack build process is starting!'); }); } } module.exports = MyPlugin; ``` -------------------------------- ### Initialize Project and npm Package Source: https://rspack.rs/guide/start/quick-start Create a project directory and initialize an npm package.json file. ```bash mkdir rspack-demo cd rspack-demo npm init -y ``` -------------------------------- ### ESM Plugin Structure Source: https://rspack.rs/guide/features/plugin Implement the `apply` method to hook into Rspack's compilation process using ESM syntax. This example logs a message when compilation starts. ```javascript const PLUGIN_NAME = 'MyPlugin'; export class MyPlugin { apply(compiler) { compiler.hooks.compilation.tap(PLUGIN_NAME, (compilation) => { console.log('The Rspack build process is starting!'); }); } } ``` -------------------------------- ### Configuration File for Version A Source: https://rspack.rs/plugins/webpack/normal-module-replacement-plugin Example configuration file for a specific application target (VERSION_A). ```javascript export const config = { title: 'I am version A', }; ``` -------------------------------- ### DllPlugin Configuration Example Source: https://rspack.rs/plugins/webpack/dll-plugin This snippet shows how to instantiate the DllPlugin with essential options. It specifies the output path for the manifest file and a naming convention for the exposed library. Ensure the 'path' option points to a valid location for the manifest.json file. ```javascript new rspack.DllPlugin({ path: path.resolve(__dirname, 'manifest.json'), name: '[name]_dll_lib', }); ``` -------------------------------- ### compiler.watchFileSystem Source: https://rspack.rs/api/javascript-api/compiler Get the proxy object used for watching file or directory changes. It provides a `watch` method to start watching and passes changed and removed items in the callback. ```APIDOC ## compiler.watchFileSystem ### Description Get the proxy object used for watching files or directories changes, which provides a `watch` method to start watching, and passes in the changed and removed items in the callback. ### Type `WatchFileSystem` ### Example See [WatchFileSystem.ts](/api/javascript-api/compiler.ts) ``` -------------------------------- ### Install Rspack Core and CLI with pnpm Source: https://rspack.rs/guide/start/quick-start Install @rspack/core and @rspack/cli as development dependencies using pnpm. ```bash pnpm add @rspack/core @rspack/cli -D ``` -------------------------------- ### Resolving Imports Relative to Project Root Source: https://rspack.rs/config/resolve Configures Rspack to resolve server-relative URLs (starting with '/') relative to the specified 'roots'. This example uses the project's current directory. ```javascript import path from 'node:path'; import { fileURLToPath } from 'node:url'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); export default { resolve: { roots: [__dirname], }, }; ``` -------------------------------- ### Example package.json with browser, module, and main fields Source: https://rspack.rs/config/resolve Illustrates a package.json structure where 'browser' and 'module' fields are present, affecting package entry point resolution based on 'mainFields' configuration. ```json { "name": "foo", "browser": "./dist/browser.js", "module": "./dist/module.js" } ``` -------------------------------- ### Install Rspack Dev Server Source: https://rspack.rs/api/cli Installs the necessary `@rspack/dev-server` dependency for `rspack dev` and `rspack preview` commands. ```bash npm add @rspack/dev-server -D ``` ```bash yarn add @rspack/dev-server -D ``` ```bash pnpm add @rspack/dev-server -D ``` ```bash bun add @rspack/dev-server -D ``` ```bash deno add npm:@rspack/dev-server -D ``` -------------------------------- ### Install Rspack Core and CLI with npm Source: https://rspack.rs/guide/start/quick-start Install @rspack/core and @rspack/cli as development dependencies using npm. ```bash npm add @rspack/core @rspack/cli -D ``` -------------------------------- ### Async watchRun Hook Example Source: https://rspack.rs/api/plugin-api/compiler-hooks Use the `tapPromise` method to register an asynchronous callback for the `watchRun` hook. This hook is triggered during watch mode after a new compilation is initiated but before it starts, and supports async operations. ```javascript class ExamplePlugin { apply(compiler) { compiler.hooks.watchRun.tapPromise('ExamplePlugin', compiler => { await someAsyncOperation(); }); } } ``` -------------------------------- ### Configuration File for Version B Source: https://rspack.rs/plugins/webpack/normal-module-replacement-plugin Example configuration file for a different application target (VERSION_B). ```javascript export const config = { title: 'I am version B', }; ``` -------------------------------- ### compiler.rspack Source: https://rspack.rs/api/javascript-api/compiler Get the exports of @rspack/core to obtain the associated internal objects. This is especially useful when you cannot directly reference `@rspack/core` or there are multiple Rspack instances. A common example is accessing the sources object in a Rspack plugin. ```APIDOC ## compiler.rspack ### Description Get the exports of `@rspack/core` to obtain the associated internal objects. This is especially useful when you cannot directly reference `@rspack/core` or there are multiple Rspack instances. A common example is accessing the [sources](/api/javascript-api/index.md#sources-object) object in a Rspack plugin. ### Type `typeof rspack` ### Example ```js const { RawSource } = compiler.rspack.sources; const source = new RawSource('console.log("Hello, world!");'); ``` ``` -------------------------------- ### Sync watchRun Hook Example Source: https://rspack.rs/api/plugin-api/compiler-hooks Use the `tap` method to register a synchronous callback for the `watchRun` hook. This hook is triggered during watch mode after a new compilation is initiated but before it starts, providing access to `modifiedFiles` and `removedFiles`. ```javascript class ExamplePlugin { apply(compiler) { compiler.hooks.watchRun.tap('ExamplePlugin', (compiler) => { const { modifiedFiles, removedFiles } = compiler; if (modifiedFiles) { console.log('Changed files:', Array.from(modifiedFiles)); } if (removedFiles) { console.log('Removed files:', Array.from(removedFiles)); } }); } } ``` -------------------------------- ### Run Rspack Preview Source: https://rspack.rs/api/cli Execute the `rspack preview` command to start a local server for your production build output. Ensure you have built your project first using `rspack build`. ```bash npx rspack preview ``` -------------------------------- ### Accessing RawSource from compiler.rspack Source: https://rspack.rs/api/javascript-api/compiler Get the exports of @rspack/core to obtain associated internal objects, useful when direct reference is not possible or multiple Rspack instances exist. This example shows accessing RawSource for creating a new source. ```javascript const { RawSource } = compiler.rspack.sources; const source = new RawSource('console.log("Hello, world!");'); ``` -------------------------------- ### Select Additional Tools in create-rsbuild Source: https://rspack.rs/blog/announcing-1-7 Example of selecting additional tools like Rstest or Storybook during create-rsbuild project initialization. Use space to select and enter to continue. ```text ◆ Select additional tools (Use to select, to continue) │ ◼ Rstest - testing │ ◻ Biome - linting & formatting │ ◻ ESLint - linting │ ◻ Prettier - formatting │ ◻ Storybook - component development └ ``` -------------------------------- ### Install NestJS Dependencies with deno Source: https://rspack.rs/guide/tech/nestjs Installs the core NestJS runtime packages using deno. Ensure Node.js build dependencies are installed first. ```bash deno add npm:@nestjs/common npm:@nestjs/core npm:@nestjs/platform-express npm:reflect-metadata npm:rxjs ``` -------------------------------- ### Install Rspack Dev Server (deno) Source: https://rspack.rs/api/cli Installs the `@rspack/dev-server` dependency using deno, which is required for the `rspack dev` command. ```sh deno add npm:@rspack/dev-server -D ``` -------------------------------- ### Resource Matching Example Source: https://rspack.rs/config/module-rules Illustrates how different parts of a module's resource identifier (like path, query, and fragment) can be matched using conditions. ```plaintext Example: app.js imports "./image.png?inline#foo": - `resource` is `/path/to/image.png`, and will match against with [rules[].resource](#rulesresource) Condition - `resourceQuery` is `?inline`, and will match against with [rules[].resourceQuery](#rulesresourcequery) Condition - `resourceFragment` is `#foo`, and will match against with [rules[].resourceFragment](#rulesresourcefragment) Condition ``` -------------------------------- ### Install NestJS Dependencies with bun Source: https://rspack.rs/guide/tech/nestjs Installs the core NestJS runtime packages using bun. Ensure Node.js build dependencies are installed first. ```bash bun add @nestjs/common @nestjs/core @nestjs/platform-express reflect-metadata rxjs ``` -------------------------------- ### Install NestJS Dependencies with pnpm Source: https://rspack.rs/guide/tech/nestjs Installs the core NestJS runtime packages using pnpm. Ensure Node.js build dependencies are installed first. ```bash pnpm add @nestjs/common @nestjs/core @nestjs/platform-express reflect-metadata rxjs ``` -------------------------------- ### Instantiate VirtualModulesPlugin Source: https://rspack.rs/plugins/rspack/virtual-modules-plugin Demonstrates how to create an instance of the VirtualModulesPlugin. This is the initial step before configuring virtual modules. ```javascript import { rspack } from '@rspack/core'; new rspack.experiments.VirtualModulesPlugin({ // ...modules }); ``` -------------------------------- ### Install NestJS Dependencies with yarn Source: https://rspack.rs/guide/tech/nestjs Installs the core NestJS runtime packages using yarn. Ensure Node.js build dependencies are installed first. ```bash yarn add @nestjs/common @nestjs/core @nestjs/platform-express reflect-metadata rxjs ``` -------------------------------- ### Equivalent DefinePlugin Configuration Source: https://rspack.rs/plugins/webpack/environment-plugin This shows the equivalent configuration using DefinePlugin for the basic EnvironmentPlugin example. ```javascript new rspack.DefinePlugin({ 'process.env.NODE_ENV': JSON.stringify(process.env.NODE_ENV), 'process.env.DEBUG': JSON.stringify(process.env.DEBUG), }); ``` -------------------------------- ### DotenvPlugin Configuration Example Source: https://rspack.rs/plugins/webpack/environment-plugin Example configuration for the third-party DotenvPlugin to expose dotenv variables into the build. Assumes a .env file exists. ```javascript new Dotenv({ path: './.env', // Path to .env file (this is the default) safe: true, // load .env.example (defaults to "false" which does not use dotenv-safe) }); ``` -------------------------------- ### Install NestJS Dependencies with npm Source: https://rspack.rs/guide/tech/nestjs Installs the core NestJS runtime packages using npm. Ensure Node.js build dependencies are installed first. ```bash npm add @nestjs/common @nestjs/core @nestjs/platform-express reflect-metadata rxjs ``` -------------------------------- ### Install Rspack Agent Skill with deno Source: https://rspack.rs/guide/start/ai Use the 'skills' package with deno to install a specific Rspack agent skill. This command installs the 'rspack-best-practices' skill. ```sh deno run -A npm:skills add rstackjs/agent-skills --skill rspack-best-practices ``` -------------------------------- ### Configure 'from' option with various path types Source: https://rspack.rs/plugins/rspack/copy-rspack-plugin Demonstrates the flexibility of the 'from' option, showing how to specify source paths as relative paths, absolute paths, and glob patterns. It also illustrates handling absolute paths with glob patterns. ```javascript import { rspack } from '@rspack/core'; import path from 'node:path'; import { fileURLToPath } from 'node:url'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); export default { plugins: [ new rspack.CopyRspackPlugin({ patterns: [ // relative path { from: 'relative/path/to/file.js' }, { from: 'relative/path/to/dir' }, // absolute path { from: path.resolve(__dirname, 'src', 'file.js') }, { from: path.resolve(__dirname, 'src', 'dir') }, // glob { from: 'dir/**/*' }, // If absolute path is a `glob` we replace backslashes with forward slashes, // because only forward slashes can be used in the `glob` { from: path.posix.join( path.resolve(__dirname, 'src').replace(/\/g, '/'), '*.txt', ), }, ], }), ], }; ``` -------------------------------- ### Install Rspack Agent Skill with bunx Source: https://rspack.rs/guide/start/ai Use the 'skills' package with bunx to install a specific Rspack agent skill. This command installs the 'rspack-best-practices' skill. ```sh bunx skills add rstackjs/agent-skills --skill rspack-best-practices ``` -------------------------------- ### Emit a file with asset info Source: https://rspack.rs/api/loader-api/context This example demonstrates emitting a file using this.emitFile() and providing additional asset information, such as the source filename. ```javascript module.exports = function loader(source) { this.emitFile( 'foo.js', 'console.log("Hello, world!");', undefined, // no sourcemap { sourceFilename: this.resourcePath, }, ); return source; }; ``` -------------------------------- ### Install Rspack Agent Skill with pnpm Source: https://rspack.rs/guide/start/ai Use the 'skills' package with pnpm to install a specific Rspack agent skill. This command installs the 'rspack-best-practices' skill. ```sh pnpm dlx skills add rstackjs/agent-skills --skill rspack-best-practices ``` -------------------------------- ### Install Rspack Agent Skill with yarn Source: https://rspack.rs/guide/start/ai Use the 'skills' package with Yarn to install a specific Rspack agent skill. This command installs the 'rspack-best-practices' skill. ```sh yarn dlx skills add rstackjs/agent-skills --skill rspack-best-practices ``` -------------------------------- ### Install Rspack Agent Skill with npm Source: https://rspack.rs/guide/start/ai Use the 'skills' package to install a specific Rspack agent skill for enhanced AI assistance. This command installs the 'rspack-best-practices' skill. ```sh npx skills add rstackjs/agent-skills --skill rspack-best-practices ``` -------------------------------- ### Example package.json with imports field Source: https://rspack.rs/config/resolve Demonstrates the structure of a package.json file using the 'imports' field to define internal package requests. ```json { "name": "lib", "imports": { "#foo": "./src/foo.js", "#common/*": "./src/common/*.js" }, "testImports": { "#foo": "./src/test/foo.js" } } ``` -------------------------------- ### Enable writeToDisk for Dev Server Source: https://rspack.rs/guide/tech/node Enable `devServer.devMiddleware.writeToDisk` when the server process is started from the generated bundle. ```javascript export default { devServer: { devMiddleware: { writeToDisk: true, }, }, }; ``` -------------------------------- ### Install css-loader with pnpm Source: https://rspack.rs/guide/tech/css Install the css-loader package using pnpm for CSS processing. ```sh pnpm add css-loader -D ``` -------------------------------- ### Install css-loader with yarn Source: https://rspack.rs/guide/tech/css Install the css-loader package using yarn for CSS processing. ```sh yarn add css-loader -D ``` -------------------------------- ### Install css-loader with npm Source: https://rspack.rs/guide/tech/css Install the css-loader package using npm for CSS processing. ```sh npm add css-loader -D ``` -------------------------------- ### Install next-rspack with pnpm Source: https://rspack.rs/guide/tech/next Install the next-rspack package as a development dependency using pnpm. ```sh pnpm add next-rspack -D ``` -------------------------------- ### Install next-rspack with yarn Source: https://rspack.rs/guide/tech/next Install the next-rspack package as a development dependency using yarn. ```sh yarn add next-rspack -D ``` -------------------------------- ### Install next-rspack with npm Source: https://rspack.rs/guide/tech/next Install the next-rspack package as a development dependency using npm. ```sh npm add next-rspack -D ``` -------------------------------- ### AMD Library Usage Example Source: https://rspack.rs/config/output Shows how to consume an AMD library using the `require` function. This assumes the library has been loaded and defined. ```javascript require(['MyLibrary'], function (MyLibrary) { // Do something with the library... }); ``` -------------------------------- ### Loader Execution Order Example Source: https://rspack.rs/contribute/architecture/rspack-loader Illustrates the sequential execution order of loader pitch and normal phases for a chain of loaders (A, B, C). ```javascript loader-A(pitch) loader-B(pitch) loader-C(pitch) loader-B(normal) loader-A(normal) ``` -------------------------------- ### Install React Server Components Dependencies (bun) Source: https://rspack.rs/guide/tech/rsc Install the necessary React and React Server DOM packages using bun. ```sh bun add react react-dom react-server-dom-rspack ``` -------------------------------- ### Expose Library via 'window' Source: https://rspack.rs/config/output Assigns the entry point's return value to the `window` object under the property name specified by `output.library.name`. Suitable for browser environments. ```javascript export default { output: { library: { name: 'MyLibrary', type: 'window', }, }, }; ``` ```javascript window['MyLibrary'] = _entry_return_; window.MyLibrary.doSomething(); ``` -------------------------------- ### Install Dependencies with pnpm Source: https://rspack.rs/guide/migration/storybook Install the necessary packages for migrating to storybook-rsbuild using pnpm. ```sh pnpm add storybook-react-rsbuild @rsbuild/core @rsbuild/plugin-react -D ``` -------------------------------- ### Install Dependencies with yarn Source: https://rspack.rs/guide/migration/storybook Install the necessary packages for migrating to storybook-rsbuild using yarn. ```sh yarn add storybook-react-rsbuild @rsbuild/core @rsbuild/plugin-react -D ``` -------------------------------- ### Install Dependencies with npm Source: https://rspack.rs/guide/migration/storybook Install the necessary packages for migrating to storybook-rsbuild using npm. ```sh npm install storybook-react-rsbuild @rsbuild/core @rsbuild/plugin-react -D ``` -------------------------------- ### Configure Multiple Static Directories with Objects Source: https://rspack.rs/config/dev-server Provide an array of objects to `devServer.static` when you need to configure multiple static folders with individual settings. ```js import path from 'node:path'; export default { devServer: { static: [ { directory: path.join(import.meta.dirname, 'assets'), }, { directory: path.join(import.meta.dirname, 'css'), }, ], }, }; ``` -------------------------------- ### Single Entry Point Configuration Source: https://rspack.rs/config/entry Configure a single entry point for your application. This is the most common setup for single-page applications or libraries. ```javascript export default { entry: './src/index.js', }; ``` -------------------------------- ### Install css-loader and style-loader with pnpm Source: https://rspack.rs/guide/tech/css Install the necessary loaders for CSS processing using pnpm. ```sh pnpm add css-loader style-loader -D ``` -------------------------------- ### Install css-loader and style-loader with yarn Source: https://rspack.rs/guide/tech/css Install the necessary loaders for CSS processing using yarn. ```sh yarn add css-loader style-loader -D ``` -------------------------------- ### ProvidePlugin with Full Path Source: https://rspack.rs/plugins/webpack/provide-plugin Shows how to specify a full path for module resolution in ProvidePlugin, useful for custom module locations. ```javascript import path from 'node:path'; import { fileURLToPath } from 'node:url'; const __dirname = path.dirname(fileURLToPath(import.meta.url)); new rspack.ProvidePlugin({ identifier: path.resolve(path.join(__dirname, 'src/module1')), // ... }); ```