Skip to content

Commit 64d9c28

Browse files
authored
feat: add polyfilled fetch support (#1229)
feat(graalvm): add polyfilled `fetch` support feat(runtime): add polyfill for `fetch` api chore(graalvm): rebuild polyfills and modules Signed-off-by: Sam Gammon <sam@elide.dev>
1 parent 74babd4 commit 64d9c28

File tree

6 files changed

+12
-9
lines changed

6 files changed

+12
-9
lines changed

packages/cli/src/main/kotlin/elide/tool/cli/Elide.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,6 +115,7 @@ import elide.tool.io.RuntimeWorkdirManager
115115
NativeEngine.boot(RuntimeWorkdirManager.acquire()) {
116116
listOf(
117117
"elide.js.vm.enableStreams" to "true",
118+
"jdk.httpclient.allowRestrictedHeaders" to "Host,Content-Length", // needed for fetch
118119
"io.netty.allocator.maxOrder" to "3",
119120
"io.netty.serviceThreadPrefix" to "elide-svc",
120121
"io.netty.native.deleteLibAfterLoading" to "true", // reversed bc of bug (actually does not delete)

packages/graalvm/src/main/kotlin/elide/runtime/core/internals/graalvm/GraalVMEngine.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,7 @@ import org.graalvm.polyglot.HostAccess as PolyglotHostAccess
101101
.allowCreateProcess(true)
102102
.allowHostClassLoading(true)
103103
.allowNativeAccess(true)
104+
.allowHostClassLookup { true }
104105
.engine(engine)
105106

106107
// allow plugins to customize the context on creation

packages/graalvm/src/main/kotlin/elide/runtime/plugins/js/JavaScript.kt

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,22 +128,23 @@ import elide.runtime.plugins.js.JavaScriptVersion.*
128128
"js.string-lazy-substrings",
129129
"js.shadow-realm",
130130
"js.zone-rules-based-time-zones",
131+
// Enabled for use by polyfills or for experimental features:
132+
"js.java-package-globals",
133+
"js.graal-builtin",
134+
"js.polyglot-evalfile",
135+
"js.load",
136+
"js.polyglot-builtin",
131137
)
132138

133139
disableOptions(
134140
"js.console",
135-
"js.graal-builtin",
136141
"js.interop-complete-promises",
137-
"js.java-package-globals",
138-
"js.load",
139-
"js.polyglot-evalfile",
140142
"js.print",
141143
"js.regexp-static-result",
142144
"js.scripting",
143145
"js.syntax-extensions",
144146
// Experimental:
145147
"js.operator-overloading",
146-
"js.polyglot-builtin",
147148
)
148149

149150
setOptions(

packages/graalvm/src/main/resources/META-INF/elide/embedded/runtime/js/polyfills.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/graalvm/src/test/kotlin/elide/runtime/intrinsics/js/JsGlobalsTest.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,8 +241,6 @@ private const val ENABLE_SUPPRESSIONS = true
241241
"TextDecoderStream", // not yet implemented
242242
"TextEncoderStream", // not yet implemented
243243
"DOMException", // not yet implemented
244-
).plus(
245-
fetchGlobals
246244
)
247245

248246
// Types which are expected to be provided by JS polyfills.
@@ -255,6 +253,8 @@ private const val ENABLE_SUPPRESSIONS = true
255253
"TransformStreamDefaultController",
256254
"WritableStreamDefaultController",
257255
"WritableStreamDefaultWriter",
256+
).plus(
257+
fetchGlobals
258258
)).toSortedSet()
259259

260260
// Globals which are expected not to be found host-side.

0 commit comments

Comments
 (0)