Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Arno Welzel Newsgroups: comp.lang.javascript Subject: Re: Using a single module Date: Sun, 20 Sep 2020 11:27:29 +0200 Lines: 50 Message-ID: References: <67Wdnb4wtM6Kr_nCnZ2dnUU7-aPNnZ2d@westnet.com.au> <44OdnYKC14DddfvCnZ2dnUU7-IXNnZ2d@westnet.com.au> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit X-Trace: individual.net arJP3bEwx2x/DlCatcg1ywzF131KAGyuElBQ20cRTn9r3a44Cm Cancel-Lock: sha1:ygaKKVQqB7Ie+9LCQwpBVGBHD6c= In-Reply-To: <44OdnYKC14DddfvCnZ2dnUU7-IXNnZ2d@westnet.com.au> Xref: csiph.com comp.lang.javascript:38820 Andrew Poulos: > On 18/09/2020 9:40 pm, Julio Di Egidio wrote: >> On Friday, 18 September 2020 06:05:58 UTC+2, Andrew Poulos wrote: >>> I'm trying my first use of modules and there some concepts that escape >>> me despite goog's help. >>> >>> If I find an ES module I'd like to use I can add it to the head of the >>> page eg >>> >>> >>> To use it in my code I need the script element that includes index.js to >>> have type="module" eg >>> >>> >>> In index.js I have: import { ... >>> >>> If I have other script files referenced in my page eg >>> >>> >>> and two.js wants to reference functions in index.js then it seems I need to >>> a. export the functions in index.js >>> b. add type="module" to the two.js' script element >>> >>> Then if there's another js file, third.js, that references a function in >>> index.js then I need to do the same. And so on for every other js file >>> that references function in files that are included as modules. >>> >>> So I end up with every script element having type="module" and every js >>> file exporting functions even though there's only one actual module I'd >>> like to use. Is that correct or am I missing something? >> >> Indeed, the docs as well as various articles I have opened >> do not seem to consider a mixed scenario at all: which may >> be telling. >> >> Anyway, I have found this solution, using dynamic imports: >> > > Dang, how do you guys find these things when I spend hours searching and > find nothing? Just have a look at the documentation: -- Arno Welzel https://arnowelzel.de