From 1432b6ab3b88fac4b26f647df787510ad714319a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Pedersen?= Date: Fri, 9 Oct 2020 13:09:48 +0200 Subject: [PATCH] Outline --- .gitignore | 2 ++ assets/js/lib/index.js | 3 +++ assets/js/main.js | 18 ++++++++++++++++++ assets/jsconfig.json | 11 +++++++++++ config.toml | 19 +++++++++++++++++++ go.mod | 13 +++++++++++++ go.sum | 16 ++++++++++++++++ layouts/index.html | 21 +++++++++++++++++++++ 8 files changed, 103 insertions(+) create mode 100644 .gitignore create mode 100644 assets/js/lib/index.js create mode 100644 assets/js/main.js create mode 100644 assets/jsconfig.json create mode 100644 config.toml create mode 100644 go.mod create mode 100644 go.sum create mode 100644 layouts/index.html diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b418425 --- /dev/null +++ b/.gitignore @@ -0,0 +1,2 @@ +public/ +node_modules/ \ No newline at end of file diff --git a/assets/js/lib/index.js b/assets/js/lib/index.js new file mode 100644 index 0000000..1c791ee --- /dev/null +++ b/assets/js/lib/index.js @@ -0,0 +1,3 @@ +export function hello4() { + return 'Hello from lib in the main project'; +} diff --git a/assets/js/main.js b/assets/js/main.js new file mode 100644 index 0000000..3ed0231 --- /dev/null +++ b/assets/js/main.js @@ -0,0 +1,18 @@ +// From mod1, but get its data from mod2. +import { hello1 } from 'core/util'; +// From mod1 +import { hello2 } from 'core/util'; +// From mod2 +import * as data from 'core/util/data.json'; +// hello3 lives in mod2 which also have a index.js in util. +// But doing import from 'core/util' you will get the index.js file from mod1 +// (higher up in the import list), so we need to be explicit: +import { hello3 } from 'core/util/hello3'; +// From main +import { hello4 } from './lib'; + +window.hello1 = hello1; +window.hello2 = hello2; +window.hello3 = hello3; +window.hello4 = hello4; +window.data = data; diff --git a/assets/jsconfig.json b/assets/jsconfig.json new file mode 100644 index 0000000..aaa17c7 --- /dev/null +++ b/assets/jsconfig.json @@ -0,0 +1,11 @@ +{ + "compilerOptions": { + "baseUrl": ".", + "paths": { + "*": [ + "../../hugoTestModulesJS/mod1/assets/*", + "../../hugoTestModulesJS/mod2/assets/*" + ] + } + } +} \ No newline at end of file diff --git a/config.toml b/config.toml new file mode 100644 index 0000000..3fab18c --- /dev/null +++ b/config.toml @@ -0,0 +1,19 @@ +baseURL = "https://example.org" + +disableKinds = ["page", "section", "term", "taxonomy"] + + +[module] +[[module.imports]] +path="github.com/gohugoio/hugoTestModulesJS/mod1" +[[module.imports]] +path="github.com/gohugoio/hugoTestModulesJS/mod2" +[[module.imports]] +path="github.com/date-fns/date-fns" +[[module.imports.mounts]] +source="src" +target="assets/date" + +[[module.imports]] +# This is not relevant for the testing itself. +path = "github.com/bep/hugo-jslibs/alpinejs" \ No newline at end of file diff --git a/go.mod b/go.mod new file mode 100644 index 0000000..1e45ab2 --- /dev/null +++ b/go.mod @@ -0,0 +1,13 @@ +module github.com/gohugoio/hugoTestProjectJSModImports + +go 1.15 + +require ( + github.com/bep/hugo-jslibs/alpinejs v0.5.14 // indirect + github.com/date-fns/date-fns v2.16.1+incompatible // indirect + github.com/gohugoio/hugoTestModulesJS/mod1 v0.0.0-20201011174806-5f7e20f9ff4a // indirect + github.com/gohugoio/hugoTestModulesJS/mod2 v0.0.0-20201011192008-decf54abafdd // indirect +) + +replace github.com/gohugoio/hugoTestModulesJS/mod1 => ../hugoTestModulesJS/mod1 +replace github.com/gohugoio/hugoTestModulesJS/mod2 => ../hugoTestModulesJS/mod2 \ No newline at end of file diff --git a/go.sum b/go.sum new file mode 100644 index 0000000..878c765 --- /dev/null +++ b/go.sum @@ -0,0 +1,16 @@ +github.com/alpinejs/alpine v2.5.0+incompatible/go.mod h1:BKI81egATMnaKqFeX5HEfYMnjZjcjcZmrYAu5Nck+EY= +github.com/bep/hugo-jslibs v0.0.0-20200822141830-44620243312e h1:JWYiSAOCdD0HO7ySFZgwiQcq4/vqObqTqesFSJ2sesw= +github.com/bep/hugo-jslibs/alpinejs v0.5.14 h1:PeZOraYYU+bH10G2Y/5M5VJsqOQyLAWCukvUIyQeTlE= +github.com/bep/hugo-jslibs/alpinejs v0.5.14/go.mod h1:AKan86yhrI16Cp+ga/+UuRkBgaO25SpubHWFgMTzh3o= +github.com/date-fns/date-fns v1.30.1 h1:zxR21/H1aFIN9dJnRPgWzm/d4vMjiPv0daTAJ+lJYJk= +github.com/date-fns/date-fns v2.16.1+incompatible h1:MhC76uGURHPWnZhfKDJs+ckojxxKwAFd3D/7VN3NQKo= +github.com/date-fns/date-fns v2.16.1+incompatible/go.mod h1:+ryiPUdf29FTxQJUxCwq0ip75zSWtk43q+htSAQLdFU= +github.com/gohugoio/hugoTestModulesJS v0.0.0-20201010100233-8db744a82e35 h1:Cha7HDCdZ57kmJpY5GgHNPoW8R1aRCHm9vOTe4wmJOg= +github.com/gohugoio/hugoTestModulesJS v0.0.0-20201011192008-decf54abafdd h1:IyL0HL6wUsRyCDelBh38gfDoiKMpJRrSJZDDdUVsiKo= +github.com/gohugoio/hugoTestModulesJS/mod1 v0.0.0-20201010100233-8db744a82e35/go.mod h1:IfctxwCwBB4wVUA+bUb4o5x2mvphWPXVLhKaclkpwz4= +github.com/gohugoio/hugoTestModulesJS/mod1 v0.0.0-20201010100603-5c7000b063e3 h1:6oAL5GX/uwfxpHog2bvTq2ARbf/strSuRZIX/KjZbIg= +github.com/gohugoio/hugoTestModulesJS/mod1 v0.0.0-20201010100603-5c7000b063e3/go.mod h1:IfctxwCwBB4wVUA+bUb4o5x2mvphWPXVLhKaclkpwz4= +github.com/gohugoio/hugoTestModulesJS/mod1 v0.0.0-20201011174806-5f7e20f9ff4a h1:h/+C4m4Aav50zgU2pfm2+GpuhoEgwVKkiRhDK2fjADs= +github.com/gohugoio/hugoTestModulesJS/mod1 v0.0.0-20201011174806-5f7e20f9ff4a/go.mod h1:IfctxwCwBB4wVUA+bUb4o5x2mvphWPXVLhKaclkpwz4= +github.com/gohugoio/hugoTestModulesJS/mod2 v0.0.0-20201011192008-decf54abafdd h1:Uu3lXkigL0q13sVksE7NVnoPTyxx4ViYKrNA70QDKA4= +github.com/gohugoio/hugoTestModulesJS/mod2 v0.0.0-20201011192008-decf54abafdd/go.mod h1:uynOkor8I03PIUuDZN4NYQ+Bmkye7vNLV5tRUBC2+10= diff --git a/layouts/index.html b/layouts/index.html new file mode 100644 index 0000000..2f8a43d --- /dev/null +++ b/layouts/index.html @@ -0,0 +1,21 @@ + + + + + + {{ .Title }} + + {{ $js := resources.Get "js/main.js" | js.Build (dict "minify" false ) }} + + {{ partialCached "jslibs/alpinejs/script-src.html" "-" }} + + +
+ +
\ No newline at end of file