Skip to content

[Bug]: resolve.alias should support node:* imports #12666

@andrzej-erli

Description

@andrzej-erli

Version

System:
    OS: Linux 6.14 Ubuntu 24.04.3 LTS 24.04.3 LTS (Noble Numbat)
    CPU: (20) x64 12th Gen Intel(R) Core(TM) i7-12700H
    Memory: 30.50 GB / 62.47 GB
    Container: Yes
    Shell: 5.9 - /usr/bin/zsh
  Browsers:
    Chrome: 142.0.7444.175
    Firefox: 145.0.2
    Firefox Developer Edition: 145.0.2
  npmPackages:
    @rsbuild/core: ~1.7.2 => 1.7.2 
    @rsbuild/plugin-react: ~1.4.2 => 1.4.2 
    @rsbuild/plugin-sass: ~1.4.0 => 1.4.0 
    @rsbuild/plugin-type-check: ~1.3.2 => 1.3.2

Details

At the moment I'm aliasing { vm: 'vm-browserify' }. Default configuration of Biome forces me to replace vm with node:vm. Unfortunately, Rsbuild breaks the build and gives me only two solutions:

Solution: Check if you need to import Node.js module.

I can't remove this import, and @rsbuild/plugin-node-polyfill has too many dependencies for my needs. It should be possible to alias all imports regardless of origin, so { 'node:vm': 'vm-browserify' } should work.

Reproduce link

Reproduce Steps

An example which should work with { 'node:vm': 'vm-browserify' } in resolve.alias

import vm from 'node:vm';

// Create a context object
const context = { value: 10 }
vm.createContext(context)

// Compile then run
const script = new vm.Script('value *= 2')
script.runInNewContext(context)
console.log(context.value) // 20

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions