question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Support `mts` / `cts` / `cjs` config files

See original GitHub issue

Clear and concise description of the problem

Import ESM-only package in vitest.config.ts

Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main defined in /Users/kevin/Developer/open-source/unplugin-jsx-string/node_modules/estree-walker/package.json

If I change extname to mts, Vitest can’t find and load this config file.

Suggested solution

https://github.com/vitest-dev/vitest/blob/5dca4ed8fd700690d022e34d8285bf9de76c0938/packages/vitest/src/constants.ts#L11-L18

 export const configFiles = [ 
      'vitest.config.ts', 
+++   'vitest.config.mts', 
+++   'vitest.config.cts', 
      'vitest.config.js', 
      'vitest.config.mjs', 
+++   'vitest.config.cjs', 
      'vite.config.ts', 
+++   'vite.config.mts', 
+++   'vite.config.cts', 
      'vite.config.js', 
      'vite.config.mjs', 
+++   'vite.config.cjs', 
 ]

Alternative

No response

Additional context

I will try to make an PR to implement it.

Validations

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:11 (8 by maintainers)

github_iconTop GitHub Comments

1reaction
sheremet-vacommented, Jul 2, 2022

Can we release a new version now? /cc @antfu @sheremet-va

After #1541

1reaction
sheremet-vacommented, Jun 22, 2022

You can open PR to both 😛

Read more comments on GitHub >

github_iconTop Results From Across the Web

Support `mts` / `cts` / `cjs` config files · vitest-dev/vitest ... - GitHub
A Vite-native test framework. It's fast! Contribute to vitest-dev/vitest development by creating an account on GitHub.
Read more >
Documentation - ECMAScript Modules in Node.js - TypeScript
Node.js supports a new setting in package.json called type . ... In turn, TypeScript supports two new source file extensions: .mts and .cts...
Read more >
`.mts` is a cool file extension (TypeScript ES modules)
js supports two extensions to help with this: .mjs and .cjs . .mjs files are always ES modules, and .cjs files are always...
Read more >
Content Types - ESBuild
This loader is enabled by default for .js , .cjs , and .mjs files. ... .tsx , .mts , and .cts files, which...
Read more >
How we employed the new ECMAScript Module Support in ...
You can also exempt files from this behavior by using special extensions. .mts and .cts are the TS equivalents of .cjs and .mjs...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found