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

fix: remove "type": "module" from vitest/package.json #1411

Merged
merged 2 commits into from Jun 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
7 changes: 3 additions & 4 deletions packages/vitest/package.json
@@ -1,6 +1,5 @@
{
"name": "vitest",
"type": "module",
"version": "0.13.1",
"description": "A blazing fast unit test framework powered by Vite",
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
Expand All @@ -23,7 +22,7 @@
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.js"
"import": "./dist/index.mjs"
},
"./*": "./*",
"./globals": {
Expand All @@ -34,12 +33,12 @@
},
"./node": {
"types": "./dist/node.d.ts",
"import": "./dist/node.js"
"import": "./dist/node.mjs"
},
"./config": {
"types": "./config.d.ts",
"require": "./dist/config.cjs",
"import": "./dist/config.js"
"import": "./dist/config.mjs"
}
},
"main": "./dist/index.js",
Expand Down
7 changes: 4 additions & 3 deletions packages/vitest/rollup.config.js
Expand Up @@ -61,6 +61,7 @@ export default ({ watch }) => [
output: {
dir: 'dist',
format: 'esm',
entryFileNames: '[name].mjs',
chunkFileNames: (chunkInfo) => {
const id = chunkInfo.facadeModuleId || Object.keys(chunkInfo.modules).find(i => !i.includes('node_modules') && i.includes('src/'))
if (id) {
Expand All @@ -70,9 +71,9 @@ export default ({ watch }) => [
.filter(i => !['src', 'index', 'dist', 'node_modules'].some(j => i.includes(j)) && i.match(/^[\w_-]+$/))),
)
if (parts.length)
return `chunk-${parts.slice(-2).join('-')}.[hash].js`
return `chunk-${parts.slice(-2).join('-')}.[hash].mjs`
}
return 'vendor-[name].[hash].js'
return 'vendor-[name].[hash].mjs'
},
},
external,
Expand All @@ -94,7 +95,7 @@ export default ({ watch }) => [
format: 'cjs',
},
{
file: 'dist/config.js',
file: 'dist/config.mjs',
format: 'esm',
},
],
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/node/pool.ts
Expand Up @@ -18,7 +18,7 @@ export interface WorkerPool {
close: () => Promise<void>
}

const workerPath = pathToFileURL(resolve(distDir, './worker.js')).href
const workerPath = pathToFileURL(resolve(distDir, './worker.mjs')).href

export function createPool(ctx: Vitest): WorkerPool {
const threadsCount = ctx.config.watch
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/runtime/mocker.ts
Expand Up @@ -230,7 +230,7 @@ export class VitestMocker {
private async ensureSpy() {
if (VitestMocker.spyModule)
return
VitestMocker.spyModule = await this.request(`/@fs/${slash(resolve(distDir, 'spy.js'))}`) as typeof import('../integrations/spy')
VitestMocker.spyModule = await this.request(`/@fs/${slash(resolve(distDir, 'spy.mjs'))}`) as typeof import('../integrations/spy')
}

public async requestWithMock(dep: string) {
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/src/runtime/worker.ts
Expand Up @@ -38,7 +38,7 @@ async function startViteNode(ctx: WorkerContext) {

const { run } = (await executeInViteNode({
files: [
resolve(distDir, 'entry.js'),
resolve(distDir, 'entry.mjs'),
],
fetchModule(id) {
return rpc().fetch(id)
Expand Down
2 changes: 1 addition & 1 deletion packages/vitest/vitest.mjs
@@ -1,2 +1,2 @@
#!/usr/bin/env node
import './dist/cli.js'
import './dist/cli.mjs'