Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

--experimental-loader does not work #673

Closed
rickyes opened this issue May 17, 2020 · 3 comments
Closed

--experimental-loader does not work #673

rickyes opened this issue May 17, 2020 · 3 comments

Comments

@rickyes
Copy link

rickyes commented May 17, 2020

Use --experimental-loader in the test file to launch the subprocess.

  • Nodejs Version: v14.2.0
  • Tap Version: v14.10.7
// coffee.test.js
const { test } = require('tap');
const path = require('path');
const { spawnSync } = require('child_process');

const PATH_ESM_LOADER = path.join(__dirname, 'coffeescript-loader.mjs');
const PATH_MAIN = path.join(__dirname, 'main.coffee');

test('test esm', t => {
  spawnSync(process.execPath, [
    '--experimental-loader',
    PATH_ESM_LOADER,
    PATH_MAIN
  ], { encoding: 'utf8', stdio: 'inherit' });
  t.end();
});
  1. Running with tap causes errors:
$ tap coffee.test.js

coffee.test.js 2> internal/modules/run_main.js:54
coffee.test.js 2>     internalBinding('errors').triggerUncaughtException(
coffee.test.js 2>                               ^
coffee.test.js 2>
coffee.test.js 2> TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension "" for /Users/ricky/.node-spawn-wrap-92169-8c7dd84acf79/node
esm/coffee.test.js 2>     at Loader.defaultGetFormat [as _getFormat] (internal/modules/esm/get_format.js:65:15)
coffee.test.js 2>     at Loader.getFormat (internal/modules/esm/loader.js:113:42)
coffee.test.js 2>     at Loader.getModuleJob (internal/modules/esm/loader.js:244:31)
coffee.test.js 2>     at processTicksAndRejections (internal/process/task_queues.js:97:5)
coffee.test.js 2>     at async Loader.import (internal/modules/esm/loader.js:178:17)
coffee.test.js 2>     at async internal/process/esm_loader.js:55:9 {
coffee.test.js 2>   code: 'ERR_UNKNOWN_FILE_EXTENSION'
  1. Run successfully with node:
$ node coffee.test.js | tap-mocha-reporter spec

test esm
  ✓ test esm (179.536ms)

  1 passing (192.018ms)
@coreyfarrell
Copy link
Member

The issue is a conflict between nyc 14 and current versions of node.js. See nodejs/node#33226 for more information about the error you are seeing. The work-around for tap v14 is to run tap --no-cov coffee.test.js - this disables collection of code coverage. If you need coverage you can install nyc@15 as a development dependency to your own package and run nyc tap --no-cov. Also note coverage of native ES modules is difficult. It only experimentally supported by using @istanbuljs/esm-loader-hook, this would conflict with your own loader hook so I cannot suggest a solution.

Note that tap v15 will use nyc v15 which resolves this issue but this fix is semver-major so it will not be available for tap.

@rickyes
Copy link
Author

rickyes commented May 17, 2020

Thank you for your comments and I will take your comments into account to fix the test case.

@isaacs
Copy link
Member

isaacs commented Sep 3, 2023

Completely different way of doing this in tap 18. A coffeescript plugin would be easy to write, you can look at the typescript plugin as an example.

@isaacs isaacs closed this as completed Sep 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants