Skip to content

Commit

Permalink
fix: remove "type": "module" from vitest/package.json (#1411)
Browse files Browse the repository at this point in the history
Closes #325

Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
  • Loading branch information
aleclarson and antfu committed Jun 5, 2022
1 parent 1560417 commit b4a9b0b
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 11 deletions.
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'

0 comments on commit b4a9b0b

Please sign in to comment.