rspack icon indicating copy to clipboard operation
rspack copied to clipboard

support shim global with modules

Open hardfist opened this issue 2 years ago • 4 comments

It's very common that some third party library use some non standard global variable like globalprocess

module.exports = {
   builtins: {
      provide: { 
         'global': './shims/global.js'
     }
   }
}

like https://webpack.js.org/plugins/provide-plugin/

hardfist avatar Dec 06 '22 12:12 hardfist

It's very common that some third party library use some non standard global variable like globalprocess


module.exports = {

   builtins: {

      provide: { 

         'global': './shims/global.js'

     }

   }

}

like https://webpack.js.org/plugins/provide-plugin/

Is someone working on this? We want to use rspack in our project but we need to "provide" things like process, buffer, etc. I can create a PR if no one is currently working on this.

dhruvkelawala avatar Mar 16 '23 23:03 dhruvkelawala

I can create a PR if no one is currently working on this.

No one is currently working on this. But if you're interested in contributing, don't hesitate to open a pull request! Once it's submitted, I'll be happy to review it.

And if you need any guidance, feel free to reach out to me on Discord or GitHub.

Thank you in advance.

hyf0 avatar Mar 17 '23 02:03 hyf0

there's a workaround with it right now and we also use it in internal projects

  • rspack.config.js
module.exports = {
  entry: { 
     main: ['./shims.js', './src/index.js']
  }
}
  • shims.js
var global = globalThis;

hardfist avatar Mar 17 '23 02:03 hardfist

Thanks for replying @hyf0 @hardfist. I am almost half-way through the PR adding provide as a builtin. Hopefully will get some more work done during the weekend

dhruvkelawala avatar Mar 17 '23 10:03 dhruvkelawala

Closed by #2492

hyf0 avatar Apr 15 '23 04:04 hyf0