From 50024fbf8cf1fd6cbe6a53809f50caa6c571b262 Mon Sep 17 00:00:00 2001 From: Mihail Stoykov Date: Tue, 9 Jul 2024 10:22:02 +0300 Subject: [PATCH 1/2] Update README with modules info closes #7 --- README.md | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 030278f..f574425 100644 --- a/README.md +++ b/README.md @@ -23,10 +23,21 @@ Features * Capable of running Babel, Typescript compiler and pretty much anything written in ES5. * Sourcemaps. * Most of ES6 functionality, still work in progress, see https://github.com/grafana/sobek/milestone/1?closed=1 + * Experimental ESM support. Known incompatibilities and caveats ----------------------------------- +### ESM support + +ECMAScript Modules or ESM for short was implemented and merged in this fork to facilitate the needs of [k6](https://github.com/grafana/k6/) as such some compromises were taken in favor of time. + +In general the API is very close to the specification, which unfortunately does *not* translate greatly to actual usage. + +For this reason it is very likely that it will be updated in breaking manner in the future and there is currently no concrete documentation around it. + +For any usage info or bare documentation it is recommended to look at the tests in [modules_test.go](https://github.com/grafana/sobek/blob/main/modules_test.go) and [modules_integration_test.go](https://github.com/grafana/sobek/blob/main/modules_integration_test.go). + ### WeakMap WeakMap is implemented by embedding references to the values into the keys. This means that as long as the key is reachable all values associated with it in any weak maps also remain reachable and therefore @@ -132,7 +143,6 @@ do not just base it on a couple of examples that work fine. Current Status -------------- - * There should be no breaking changes in the API, however it may be extended. * Some of the AnnexB functionality is missing. Basic Example From 81ffcb755be663de018da3cd17292ea4714adf7e Mon Sep 17 00:00:00 2001 From: Mihail Stoykov Date: Tue, 9 Jul 2024 10:50:01 +0300 Subject: [PATCH 2/2] Add note about event loop and ESM --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index f574425..dd5d23f 100644 --- a/README.md +++ b/README.md @@ -38,6 +38,8 @@ For this reason it is very likely that it will be updated in breaking manner in For any usage info or bare documentation it is recommended to look at the tests in [modules_test.go](https://github.com/grafana/sobek/blob/main/modules_test.go) and [modules_integration_test.go](https://github.com/grafana/sobek/blob/main/modules_integration_test.go). +Also of note is that due to the nature of ESM you need to have an event loop implementation to use it. That is still not provided by Sobek and likely never will be. + ### WeakMap WeakMap is implemented by embedding references to the values into the keys. This means that as long as the key is reachable all values associated with it in any weak maps also remain reachable and therefore