Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
W
wax
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
hive
wax
Commits
f5b6428f
Commit
f5b6428f
authored
1 month ago
by
Mateusz Tyszczak
Committed by
Bartek Wrona
1 month ago
Browse files
Options
Downloads
Patches
Plain Diff
Allow bundling WASM binary in webpack to create single-file bundle
parent
aaa9bc0b
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
ts/wasm/lib/index.ts
+19
-10
19 additions, 10 deletions
ts/wasm/lib/index.ts
ts/wasm/lib/vite.ts
+7
-2
7 additions, 2 deletions
ts/wasm/lib/vite.ts
with
26 additions
and
12 deletions
ts/wasm/lib/index.ts
+
19
−
10
View file @
f5b6428f
...
@@ -11,16 +11,25 @@ declare global {
...
@@ -11,16 +11,25 @@ declare global {
}
}
const
ENVIRONMENT_IS_WORKER
=
typeof
WorkerGlobalScope
!=
'
undefined
'
;
const
ENVIRONMENT_IS_WORKER
=
typeof
WorkerGlobalScope
!=
'
undefined
'
;
const
getModuleExt
=
()
=>
({
const
getModuleExt
=
()
=>
{
locateFile
:
(
path
,
scriptDirectory
)
=>
{
// Warning: important change is moving conditional ternary expression outside of URL constructor call, what confused parcel analyzer.
if
(
path
===
"
wax.common.wasm
"
)
{
// Seems it must have simple variables & literals present to correctly translate code.
/// Warning: important change is moving conditional ternary expression outside of URL constructor call, what confused parcel analyzer.
const
wasmFilePath
=
(
ENVIRONMENT_IS_WORKER
?
new
URL
(
"
./build_wasm/wax.common.wasm
"
,
self
.
location
.
href
)
:
new
URL
(
"
./build_wasm/wax.common.wasm
"
,
import
.
meta
.
url
)).
href
;
/// Seems it must have simple variables & literals present to correctly translate code.
// Fallback for client-bundled inlined WASM, e.g. when using webpack
return
(
ENVIRONMENT_IS_WORKER
?
new
URL
(
"
./build_wasm/wax.common.wasm
"
,
self
.
location
.
href
)
:
new
URL
(
"
./build_wasm/wax.common.wasm
"
,
import
.
meta
.
url
)).
href
;
let
wasmBinary
:
Buffer
|
undefined
;
}
if
(
wasmFilePath
.
startsWith
(
"
data:application/wasm;base64,
"
))
return
scriptDirectory
+
path
;
wasmBinary
=
Buffer
.
from
(
wasmFilePath
.
slice
(
29
),
"
base64
"
);
}
})
return
{
locateFile
(
path
:
string
,
scriptDirectory
:
string
):
string
{
if
(
path
===
"
wax.common.wasm
"
)
{
return
wasmFilePath
;
}
return
scriptDirectory
+
path
;
},
wasmBinary
};
};
/**
/**
* Creates a Wax Hive chain instance
* Creates a Wax Hive chain instance
...
...
This diff is collapsed.
Click to expand it.
ts/wasm/lib/vite.ts
+
7
−
2
View file @
f5b6428f
...
@@ -10,12 +10,17 @@ const moduleArgs = (async () => {
...
@@ -10,12 +10,17 @@ const moduleArgs = (async () => {
if
((
import
.
meta
as
any
).
client
||
(
!
(
"
client
"
in
import
.
meta
)
&&
typeof
(
import
.
meta
as
any
).
env
===
"
object
"
&&
"
SSR
"
in
(
import
.
meta
as
any
).
env
))
{
if
((
import
.
meta
as
any
).
client
||
(
!
(
"
client
"
in
import
.
meta
)
&&
typeof
(
import
.
meta
as
any
).
env
===
"
object
"
&&
"
SSR
"
in
(
import
.
meta
as
any
).
env
))
{
const
resolvedUrl
=
(
await
import
(
'
./build_wasm/wax.common.wasm
'
+
'
?url
'
)).
default
;
const
resolvedUrl
=
(
await
import
(
'
./build_wasm/wax.common.wasm
'
+
'
?url
'
)).
default
;
let
wasmBinary
:
Buffer
|
undefined
;
if
(
resolvedUrl
.
startsWith
(
"
data:application/wasm;base64,
"
))
wasmBinary
=
Buffer
.
from
(
resolvedUrl
.
slice
(
29
),
"
base64
"
);
return
{
return
{
locateFile
:
(
path
,
scriptDirectory
)
=>
{
locateFile
(
path
:
string
,
scriptDirectory
:
string
):
string
{
if
(
path
===
"
wax.common.wasm
"
)
if
(
path
===
"
wax.common.wasm
"
)
return
resolvedUrl
;
return
resolvedUrl
;
return
scriptDirectory
+
path
;
return
scriptDirectory
+
path
;
}
},
wasmBinary
};
};
}
else
{
}
else
{
return
{};
return
{};
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment