Skip to content

esm: support loading data: URLs

Rodrigo Muino Tomonari requested to merge github/fork/bmeck/data-urls into master

This PR allows loading some formats of modules as data: URLs. This matches the web spec and has some concerns as we grow what can be loaded into ESM as per the open discussion at https://github.com/nodejs/security-wg/issues/520 . I'm opening this with expectation of some discussion to take place around MIME parsing (which is left in https://github.com/nodejs/node/pull/21128) which this PR doesn't properly do and what to do in the cases where module formats are not supported outside of file contexts. Currently I simply didn't include the CJS MIME or the C++ Addon MIME for what can be loaded via data: URLs. We could expose those but likely things would be awkward for things like __filename and that C++ addons would have to be written to disk first for dlopen to work. Once we resolve that we can write up docs on the decision and move this PR forward.

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • documentation is changed or added
  • commit message follows commit guidelines

Merge request reports

Loading