On 11/12/2021 17:40, Pirate Praveen wrote:


On ശ, ഡിസം 11 2021 at 05:38:11 വൈകു +0100 +0100, Yadd <y...@debian.org> wrote:
On 11/12/2021 17:35, Pirate Praveen wrote:


On ശ, ഡിസം 11 2021 at 05:28:13 വൈകു +0100 +0100, Yadd <y...@debian.org> wrote:
On 11/12/2021 16:21, Pirate Praveen wrote:


On ശ, ഡിസം 11 2021 at 01:48:18 വൈകു +0100 +0100, Julien Puydt <julien.pu...@gmail.com> wrote:
Hi,

Le samedi 11 décembre 2021 à 13:24 +0100, Yadd a écrit :

 echo -n require > debian/tests/pkg-js/SKIP

Good one!

How does one test an import-able module?

Create test.mjs as
import {loadJsonFile} from 'load-json-file';

node test.mjs

or more generic
import * as loadJSONFile from 'load-json-file';

or even simpler

import 'load-json-file';

This does not work with node 12

I tested in node 12 only

load-json-file was installed via npm i load-json-file

(debian-sid)pravi@mahishi:/tmp$ cat test.mjs
import 'load-json-file';(debian-sid)pravi@mahishi:/tmp$ node -v
v12.22.7
(debian-sid)pravi@mahishi:/tmp$ apt policy nodejs
nodejs:
  Installed: 12.22.7~dfsg-2
  Candidate: 12.22.7~dfsg-2
  Version table:
     16.13.0~dfsg-5 1
          1 http://deb.debian.org/debian experimental/main amd64 Packages
*** 12.22.7~dfsg-2 500
        500 http://deb.debian.org/debian sid/main amd64 Packages
        100 /var/lib/dpkg/status
(debian-sid)pravi@mahishi:/tmp$ node test.mjs
(debian-sid)pravi@mahishi:/tmp$ echo $?
0
(debian-sid)pravi@mahishi:/tmp$

I understand, this works because you download it in node_modules. This does not work with an installed module

Then it should be fixed in nodejs itself, right? Like how we did for commonjs. Or does ES6 prohibit global installations?

For testing, we could probably add a symbolic link like with extlinks. I think it is better than skipping.

Hi,

I built pkg-js-tools 0.9.85 (experimental) which tries to launch that. However it is not enough because sub-import will fail until nodejs will be able to "import" from its paths.

Cheers,
Yadd

Reply via email to