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

Support mts / cts / cjs config files #1528

Closed
4 tasks done
sxzz opened this issue Jun 22, 2022 · 11 comments · Fixed by #1540
Closed
4 tasks done

Support mts / cts / cjs config files #1528

sxzz opened this issue Jun 22, 2022 · 11 comments · Fixed by #1540
Labels
enhancement New feature or request pr welcome

Comments

@sxzz
Copy link
Contributor

sxzz commented Jun 22, 2022

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

export const configFiles = [
'vitest.config.ts',
'vitest.config.js',
'vitest.config.mjs',
'vite.config.ts',
'vite.config.js',
'vite.config.mjs',
]

 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

@sheremet-va sheremet-va added enhancement New feature or request pr welcome labels Jun 22, 2022
@sheremet-va
Copy link
Member

Does Vite support vite.config.mts/vite.config.cts?

@sxzz
Copy link
Contributor Author

sxzz commented Jun 22, 2022

Not supported ATM, vitejs/vite#5201

@sxzz
Copy link
Contributor Author

sxzz commented Jun 22, 2022

So, we need wait supporting of Vite. Right?

@sheremet-va
Copy link
Member

You can open PR to both :P

@sxzz
Copy link
Contributor Author

sxzz commented Jun 22, 2022

Wait PR vitejs/vite#8729

@sxzz
Copy link
Contributor Author

sxzz commented Jul 2, 2022

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

@sheremet-va
Copy link
Member

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

After #1541

@capaj
Copy link

capaj commented Jul 13, 2022

is this released now? I am getting

$ vitest
failed to load config from /home/capaj/oss/graphql-repos/startup-stage-checklist-api/vitest.config.mts

⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯ Unhandled Error ⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯⎯
TypeError [ERR_UNKNOWN_FILE_EXTENSION]: Unknown file extension ".mts" for /home/capaj/oss/graphql-repos/startup-stage-checklist-api/vitest.config.mts
    at new NodeError (node:internal/errors:372:5)
    at Object.getFileProtocolModuleFormat [as file:] (node:internal/modules/esm/get_format:76:11)
    at defaultGetFormat (node:internal/modules/esm/get_format:118:38)
    at defaultLoad (node:internal/modules/esm/load:21:20)
    at ESMLoader.load (node:internal/modules/esm/loader:407:26)
    at ESMLoader.moduleProvider (node:internal/modules/esm/loader:326:22)
    at new ModuleJob (node:internal/modules/esm/module_job:66:26)
    at ESMLoader.#createModuleJob (node:internal/modules/esm/loader:345:17)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:304:34)
    at processTicksAndRejections (node:internal/process/task_queues:96:5) {
  code: 'ERR_UNKNOWN_FILE_EXTENSION'
}

with vitest 0.18.0

@sheremet-va
Copy link
Member

What Vite 3 version are you using?

@capaj
Copy link

capaj commented Jul 13, 2022

I don't have vite as direct dependency-it's a node.js backend app.

@capaj
Copy link

capaj commented Jul 13, 2022

this is the package.json

{
  "name": "startup-stage-checklist-api",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "type": "module",
  "dependencies": {
    "@prisma/client": "^4.0.0",
    "@types/node": "^18.0.3",
    "class-transformer": "^0.5.1",
    "decapi": "^2.0.8",
    "fastify": "^4.2.1",
    "graphql": "^16.5.0",
    "mercurius": "^10.1.0",
    "minifaker": "^1.34.1",
    "nanoid": "^4.0.0"
  },
  "devDependencies": {
    "husky": "^8.0.1",
    "patch-package": "^6.4.7",
    "postinstall-postinstall": "^2.1.0",
    "prettier": "^2.7.1",
    "pretty-quick": "^3.1.3",
    "rollup-plugin-typescript2": "^0.32.1",
    "ts-node": "^10.8.2",
    "ts-node-dev": "^2.0.0",
    "ttypescript": "^1.5.13",
    "typescript": "^4.7.4",
    "vitest": "^0.18.0"
  },
  "resolutions": {
    "graphql": "^16.5.0"
  },
  "scripts": {
    "start": "ts-node-esm -C ttypescript --experimental-specifier-resolution=node app.ts",
    "test": "vitest"
  },
  "husky": {
    "hooks": {
      "pre-commit": "pretty-quick --staged"
    }
  }
}

@github-actions github-actions bot locked and limited conversation to collaborators Jun 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request pr welcome
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants