Skip to content

Commit

Permalink
Remove explicitly unimplemented importScripts
Browse files Browse the repository at this point in the history
We have no plans to ever implement `importScripts()` and having
it defined but marked explicitly non-implemented is causing issues
with using certain third-party libraries in workers. So let's just
remove it entirely.

Refs: #1521
  • Loading branch information
jasnell committed Jan 21, 2024
1 parent 84417dd commit f2485d8
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 4 additions & 2 deletions src/workerd/api/global-scope.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,12 +133,14 @@ class WorkerGlobalScope: public EventTarget, public jsg::ContextGlobal {
public:
jsg::Unimplemented importScripts(kj::String s) { return {}; };

JSG_RESOURCE_TYPE(WorkerGlobalScope) {
JSG_RESOURCE_TYPE(WorkerGlobalScope, CompatibilityFlags::Reader flags) {
JSG_INHERIT(EventTarget);

JSG_NESTED_TYPE(EventTarget);

JSG_METHOD(importScripts);
if (!flags.getNoImportScripts()) {
JSG_METHOD(importScripts);
}

JSG_TS_DEFINE(type WorkerGlobalScopeEventMap = {
fetch: FetchEvent;
Expand Down
6 changes: 6 additions & 0 deletions src/workerd/io/compatibility-date.capnp
Original file line number Diff line number Diff line change
Expand Up @@ -361,4 +361,10 @@ struct CompatibilityFlags @0x8f8c1b68151b6cef {
# The client stub is currently guarded by the experimental flag, however, we don't want to let
# experimental clients call JS methods over RPC if the Worker receiving the request hasn't
# explicitly exposed its methods to RPC.

noImportScripts @40 :Bool
$compatEnableFlag("no_global_importscripts")
$compatDisableFlag("global_importscripts")
$compatEnableDate("2024-03-04");
# Removes the non-implemented importScripts() function from the global scope.
}

0 comments on commit f2485d8

Please sign in to comment.