lukeed / lukeed/uvu

-r esm not working with uvu CLI

Open
#46 3 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
JavaScript
Stars
3k
Forks
101
PR merge metrics
No merged PRs in 30d

Description

Playing around with uvu tonight, I have a command that works with `node`, but doesn't work with the `uvu` CLI:

- Works: `node -r esm -r ../app-scripts-svelte/test/register.js ./src/App.test.js`
- Doesn't work: `yarn run uvu -r esm -r ../app-scripts-svelte/test/register.js src`
- Doesn't work: `../../node_modules/.bin/uvu -r esm -r ../app-scripts-svelte/test/register.js src` (run in a monorepo, if that matters)

Error:
```
... app-template-svelte/src/App.test.js:1
(function (exports, require, module, __filename, __dirname) { import { test } from 'uvu';
^^^^^^

SyntaxError: Cannot use import statement outside a module
```

Can confirm that putting random string in place of `esm` (`-r eawegiawingeawniegain`) causes a different error, so esm seems to be running but having no effect.

This is on the latest version from npm

Based loosly on https://github.com/lukeed/uvu/tree/master/examples/svelte

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Reproduce the three reported commands, including the monorepo invocation, and inspect the uvu CLI entry point and its handling of Node’s -r options. Done means the CLI loads esm and the register.js hook so the reported App.test.js import runs without the SyntaxError.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, node.js
Domain
cli, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.