Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.javascript > #39715

Re: Exposing a module in the current scope

Path csiph.com!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From Anton Shepelev <anton.txt@gmail.com>
Newsgroups comp.lang.javascript
Subject Re: Exposing a module in the current scope
Date Sat, 20 Mar 2021 13:51:50 +0300
Organization A noiseless patient Spider
Lines 87
Message-ID <20210320135150.9172df52c3ad3891bcb2299b@gmail.com> (permalink)
References <20210318192107.08e2fac2d6aeada5596c4dd0@freeshell.de> <7921cdf5-084a-4011-9a0e-680e0b45c442n@googlegroups.com> <20210318235703.ea4798e2fc9d01b5194a34ca@gmail.com> <5a31706e-e012-47ea-b047-867d6da83212n@googlegroups.com> <20210319181117.c09ff1a07699679434f6310e@g{oogle}mail.com> <9dd35db1-fee3-4142-bf30-24e8da7bdc98n@googlegroups.com>
Mime-Version 1.0
Content-Type text/plain; charset=US-ASCII
Content-Transfer-Encoding 7bit
Injection-Info reader02.eternal-september.org; posting-host="0b6de666454792515201e0a3034742c6"; logging-data="26877"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+HNODZi3ggg8FKbeqTtwUGIWIO3cIohBU="
Cancel-Lock sha1:XmQSxVbmzzZuYo7cY3ebge1jkb4=
X-Newsreader Sylpheed 3.7.0 (GTK+ 2.24.30; i686-pc-mingw32)
Xref csiph.com comp.lang.javascript:39715

Show key headers only | View raw


Michael Haufe to Anton Shepelev:

> > Why are you writing in Markdown?
>
> To make clear what is code and what is a comment about the
> code

I see. Most of the time it seems sufficient simply to write
the code down after a vertical space. When doubt is
possible, I will also indent the code block on the left.

> More than JavaScript is used in this group in discussions.
> There is also TypeScript, ActionScript, and others.

One can also indicate the language in the prose.

> The above I find more straightforward than what used to be
> common: The above I find more straightforward than what
> used to be common:
> <script> ... </script>
>
> <script type="text/javascript">
> ...
> </script>
>
> <script type="text/typescript">
> ...
> </script>

Did anybody in this newsgroup use to post pieces of
JavaScript code inside HTML tags? That was terrible, indeed.
They must have been confusing Usenet articles that discuss
the code and actual web pages that use it.

> > As I wrote, it does recognise the `import' statement,
> > but fails with:
> >
> >    import declarations may only appear at top level of a module
> >
> > presumably because it cannot treat .xsjs files as
> > modules.
>
> Which makes sense as they mention the *.xjslib extension.

That extenstion is reserved for libraries, whereas the
actual server-side applications must be .xsjs, and I can't
seem to use the `import' statement in .xsjs  because of the
error quoted above. If I rename the main file to .mjs, the
error goes away, but HANA XS no longer "serves" them,
considering them as data files rather than JavaScript
sources to be executed. That is very strage and illogical.

> Since you verified that it's newer than ES5 you can't
> ignore my suggestion.  The modern module approach is more
> appropriate.

I do not ignore them. I just can't follow them :-)

> Since you confirmed that at least some ES6 features are
> available, you can ignore my example and try something
> more modern:
>
> ```
> function log(msg) { $.trace.debug(msg); };
>
> export default log
> ```
>
> or for multiple exports:
>
> ```
> function log(msg) { ... };
> function hello(msg){  ... };
>
> export {hello, log}
> ```

I will try it on Monday, but I think it will complain again
that `export' can only occur at the top level of a module,
because in its self-contradictory opinion a file is not a
module unless has one of the unsupported extensions .js or
.mjs. I will let you know.


-- 
()  ascii ribbon campaign -- against html e-mail
/\  http://preview.tinyurl.com/qcy6mjc [archived]

Back to comp.lang.javascript | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Exposing a module in the current scope Anton Shepelev <antonius@freeshell.de> - 2021-03-18 19:21 +0300
  Re: Exposing a module in the current scope Anton Shepelev <anton.txt@gmail.com> - 2021-03-18 23:57 +0300
    Re: Exposing a module in the current scope "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2021-03-18 18:45 -0700
      Re: Exposing a module in the current scope Anton Shepelev <anton.txt@g{oogle}mail.com> - 2021-03-19 18:11 +0300
        Re: Exposing a module in the current scope Anton Shepelev <anton.txt@g{oogle}mail.com> - 2021-03-19 19:08 +0300
          Re: Exposing a module in the current scope "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2021-03-19 10:51 -0700
            Re: Exposing a module in the current scope Anton Shepelev <anton.txt@gmail.com> - 2021-03-20 13:32 +0300
              Re: Exposing a module in the current scope "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2021-03-20 09:53 -0700
        Re: Exposing a module in the current scope "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2021-03-19 10:47 -0700
          Re: Exposing a module in the current scope Anton Shepelev <anton.txt@gmail.com> - 2021-03-20 13:51 +0300
            Re: Exposing a module in the current scope "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2021-03-20 09:59 -0700
              Re: Exposing a module in the current scope Anton Shepelev <anton.txt@g{oogle}mail.com> - 2021-03-24 20:43 +0300
          Re: Exposing a module in the current scope Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2021-03-22 21:14 +0100
            Re: Exposing a module in the current scope "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2021-03-22 16:00 -0700
              Re: Exposing a module in the current scope Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2021-03-23 01:11 +0100
              Re: Exposing a module in the current scope Anton Shepelev <anton.txt@gmail.com> - 2021-04-04 00:31 +0300
  Re: Exposing a module in the current scope "Michael Haufe (TNO)" <tno@thenewobjective.com> - 2021-03-18 11:30 -0700
  Re: Exposing a module in the current scope Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2021-03-22 21:05 +0100
  Re: Exposing a module in the current scope Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2021-03-23 01:00 +0100
    Re: Exposing a module in the current scope Anton Shepelev <anton.txt@g{oogle}mail.com> - 2021-03-23 20:06 +0300
      Re: Exposing a module in the current scope Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2021-03-25 20:04 +0100
        Re: Exposing a module in the current scope John G Harris <niam@jghnorth.org.uk.invalid> - 2021-03-26 08:32 +0000
        Re: Exposing a module in the current scope John G Harris <niam@jghnorth.org.uk.invalid> - 2021-03-26 08:48 +0000
  Re: Exposing a module in the current scope Anton Shepelev <anton.txt@g{oogle}mail.com> - 2021-04-13 18:49 +0300

csiph-web