File tree Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Expand file tree Collapse file tree 3 files changed +22
-1
lines changed Original file line number Diff line number Diff line change @@ -12,6 +12,18 @@ import { hello4 } from './lib';
12
12
// From the Hugo template.
13
13
import * as params from '@params' ;
14
14
15
+ var worker = new Worker ( params . myworker ) ;
16
+
17
+ worker . addEventListener (
18
+ 'message' ,
19
+ function ( e ) {
20
+ console . log ( 'Worker said: ' , e . data ) ;
21
+ } ,
22
+ false
23
+ ) ;
24
+
25
+ worker . postMessage ( 'Hello Worker' ) ;
26
+
15
27
// https://github.com/gohugoio/hugo/issues/7948
16
28
// TODO(bep) make this work in Hugo integration tests import { helloNodeModules } from 'mynodemod';
17
29
Original file line number Diff line number Diff line change
1
+ self . addEventListener (
2
+ 'message' ,
3
+ function ( e ) {
4
+ self . postMessage ( 'Echo From Worker: ' + e . data ) ;
5
+ } ,
6
+ false
7
+ ) ;
Original file line number Diff line number Diff line change 10
10
< script src ="https://unpkg.com/react@17/umd/react.production.min.js " crossorigin > </ script >
11
11
< script src ="https://unpkg.com/react-dom@17/umd/react-dom.production.min.js " crossorigin > </ script >
12
12
{{ end }}
13
+ {{/* We (Hugo/ESBuild) needs to improve the worker integration, but this could be a OK workaround. */}}
14
+ {{ $worker := resources.Get "js/myworker.js" | js.Build }}
13
15
{{ $inject := slice "js/shims/process.js" }}
14
- {{ $js := resources.Get "js/main.js" | js.Build (dict "minify" false "params" (dict "myparam" "Hugo Rocks!") "inject" $inject ) }}
16
+ {{ $js := resources.Get "js/main.js" | js.Build (dict "minify" false "params" (dict "myparam" "Hugo Rocks!" "myworker" $worker.RelPermalink ) "inject" $inject ) }}
15
17
< script src ="{{ $js.RelPermalink }} "> </ script >
16
18
{{ partialCached "jslibs/alpinejs/script-src.html" "-" }}
17
19
</ head >
You can’t perform that action at this time.
0 commit comments