[Pkg-javascript-devel] Bug#1006378: Bug#1006378: pkg-js-tools: pkg-js-autopkgtest-require fails with type=module without default export

Yadd yadd at debian.org
Thu Feb 24 16:24:40 GMT 2022


Control: tags -1 + moreinfo

On 24/02/2022 16:51, Jonas Smedegaard wrote:
 > Package: pkg-js-tools
 > Version: 0.12.9
 > Severity: important
 >
> EcmaScript modules are supported since nodejs v12.20.0, as documented at
> https://nodejs.org/api/esm.html#modules-ecmascript-modules (in the
> "History" foldout).
> 
> EcmaScript modules can export functions in two ways, and only in one of
> them will a default export exists:
> https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/export#description
> 
> When pkg-js-tools detects that a Node.js library is an EcmaScript module
> it runs a test with the assumption that a default export exists.
> 
> This fails for EcmaScript modules using named export.
> 
> An example is the module espree.
> 
> Upgrading Debian package node-espree requires _avoiding_ pkg-js-tools,
> because the autopkgtest will fail and apparently cannot be overridden
> (seems only additionally added tests can be overridden).
> 
> Setting severity=important due to the affect of upgradability of
> existing packages.
> 
> 
>   - Jonas

Hi,

logically, pkg-js-autopkgtest should ignore such error. Could you give 
me an example ? Current node-espree isn't a module and with next one 
(9.3.1), test passed _(even if it reports an IGNORED error)_
Note: reporting such error means that module was loaded, then 
pkg-js-autopkgtest considers that enough to mark test as "PASS 
(superficial)"

Full output:

autopkgtest [17:20:30]: test pkg-js-autopkgtest-require: 
[-----------------------
# Using ./package.(json|yaml)
# Node module name is espree
# Test: require
# /!\ Package is a ES module
#   Dependency acorn: copied
#   Dependency eslint-visitor-keys: copied
#   Dependency acorn-jsx: copied
#   Dependency espree: copied
#   Testing espree: 
file:///tmp/autopkgtest.6Q8ryx/autopkgtest_tmp/test.mjs:1
import TMP from 'espree';console.log('Import succeeds')
        ^^^
SyntaxError: The requested module 'espree' does not provide an export 
named 'default'
     at ModuleJob._instantiate (internal/modules/esm/module_job.js:97:21)
     at async ModuleJob.run (internal/modules/esm/module_job.js:142:20)
     at async Loader.import (internal/modules/esm/loader.js:182:24)
     at async Object.loadESM (internal/process/esm_loader.js:68:5)
not ok
#   Testing espree via require: ok
autopkgtest [17:20:32]: test pkg-js-autopkgtest-require: 
-----------------------]
autopkgtest [17:20:32]: test pkg-js-autopkgtest-require:  - - - - - - - 
- - - results - - - - - - - - - -
pkg-js-autopkgtest-require PASS (superficial)



More information about the Pkg-javascript-devel mailing list