Skip to content

[browser] Support for web extension constraints #80045

Open
@elringus

Description

@elringus

Support for web extension constraints

The requirements for web extension are very strict: they have to be bundled as a single JS file, can't use any imports or node/browser APIs, etc. That would also refine various APIs, as, for example, new JSInterop requires loading modules for imported function at runtime from C#, which is not allowed in a VS Code web extension (#87365).

From #91558
Here is the link to the patch I'm using to strip all the offenders: https://github.com/elringus/bootsharp/blob/main/src/cs/Bootsharp.Publish/Pack/ModulePatcher/InternalPatcher.cs After the patch, bundlers are only complaining about module and process unresolved externals (tested with webpack, rollup, esbuild, vite) and the bundled runtime is working in browsers, node, deno, bun and VS Code web extensions.

Regarding module and process — would be optimal to guard them as well, though I wasn't able to find a straightforward way to do that (conditional usage still trigger bundlers). As a workaround, I'm marking them as global (eg, -g process,module in rollup), which seem to satisfy the bundlers.

Metadata

Metadata

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions