AngleSharp / AngleSharp.Js

:angel: Extends AngleSharp with a .NET-based JavaScript engine.
https://anglesharp.github.io
MIT License
103 stars 22 forks source link

JS module and importmap support #92

Closed tomvanenckevort closed 6 months ago

tomvanenckevort commented 6 months ago

New Feature Proposal

Description

Now there is Jint v3 support, there should also be support for JS modules and import maps.

Background

Currently AngleSharp.Js only parses and executes script elements with type="javascript", so it will ignore the newer modules and import maps. An example of a simple test scenario:

<!doctype html>
<script type="importmap">
    {
        "imports": {
          "jquery": "https://cdn.jsdelivr.net/npm/jquery@4.0.0-beta/+esm"
        }
      }
</script>
<script type="module">
    import { $ } from 'jquery';

    console.log($.toString());
</script>

Specification

The JsScriptingService needs to be updated to also allow processing of module and importmap script elements. And then depending on the type it will need to run different Jint commands to deal with modules and import maps.