[Feature]: External type with customizable require function #12103
Replies: 3 comments
-
|
you can use swc wasm plugin to transform require to your custom require and use custom runtimeModule to inject your own runtime |
Beta Was this translation helpful? Give feedback.
-
|
I have tried implementing the proposed solution and run into an issue: I need to access one of the libraries' modules in the custom runtime module. I have tried to use getModuleId to then require it, however this breaks with module concatenation or if the module isn't imported anywhere. Are there better ways to do this or is there a method to prevent a module from being concatenated and a method to add a module to the module graph? |
Beta Was this translation helpful? Give feedback.
-
|
you can set |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
What problem does this feature solve?
In my environment exists a global require function that is not called
require. I would like to use this similar to thecommonjsexternalsType. Sadly, the function that that externals type uses is not customizable. I have not found any other method for doing this that does not cripple Rspack's optimization features, particularly module concatenation.What does the proposed API of configuration look like?
Perhaps a new
externalsRequireproperty or an extension to the currentcommonjstype such ascommonjs(object.with.require)where the parameterobject.with.requirespecifies a function accessible on the global. I am honestly uncertain of how best the configuration for this would be exposed and am open to suggestions.Beta Was this translation helpful? Give feedback.
All reactions