-
Notifications
You must be signed in to change notification settings - Fork 61
Expand file tree
/
Copy pathindex.html
More file actions
31 lines (26 loc) · 1000 Bytes
/
index.html
File metadata and controls
31 lines (26 loc) · 1000 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
<html>
<script src="https://cdn.jsdelivr.net/npm/@ruby/head-wasm-wasi@2.3.0/dist/browser.script.iife.js"></script>
<script type="text/ruby" data-eval="async">
# Patch require_relative to load from remote
require 'js/require_remote'
module Kernel
alias original_require_relative require_relative
# The require_relative may be used in the embedded Gem.
# First try to load from the built-in filesystem, and if that fails,
# load from the URL.
def require_relative(path)
caller_path = caller_locations(1, 1).first.absolute_path || ''
dir = File.dirname(caller_path)
file = File.absolute_path(path, dir)
original_require_relative(file)
rescue LoadError
JS::RequireRemote.instance.load(path)
end
end
# The above patch should not break the original require_relative
require 'uri'
URI.parse('http://example.com')
# Load the main script
require_relative 'main'
</script>
</html>