Skip to content

Commit

Permalink
fix(vite-node): use .mjs for esm build
Browse files Browse the repository at this point in the history
  • Loading branch information
antfu committed Jun 5, 2022
1 parent 3f5ff5b commit 692ad34
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
13 changes: 6 additions & 7 deletions packages/vite-node/package.json
@@ -1,6 +1,5 @@
{
"name": "vite-node",
"type": "module",
"version": "0.13.1",
"description": "Vite as Node.js runtime",
"author": "Anthony Fu <anthonyfu117@hotmail.com>",
Expand All @@ -19,26 +18,26 @@
".": {
"types": "./dist/index.d.ts",
"require": "./dist/index.cjs",
"import": "./dist/index.js"
"import": "./dist/index.mjs"
},
"./client": {
"types": "./dist/client.d.ts",
"require": "./dist/client.cjs",
"import": "./dist/client.js"
"import": "./dist/client.mjs"
},
"./server": {
"types": "./dist/server.d.ts",
"require": "./dist/server.cjs",
"import": "./dist/server.js"
"import": "./dist/server.mjs"
},
"./utils": {
"types": "./dist/utils.d.ts",
"require": "./dist/utils.cjs",
"import": "./dist/utils.js"
"import": "./dist/utils.mjs"
}
},
"main": "./dist/index.js",
"module": "./dist/index.js",
"main": "./dist/index.mjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"typesVersions": {
"*": {
Expand Down
9 changes: 6 additions & 3 deletions packages/vite-node/rollup.config.js
Expand Up @@ -4,6 +4,7 @@ import resolve from '@rollup/plugin-node-resolve'
import commonjs from '@rollup/plugin-commonjs'
import json from '@rollup/plugin-json'
import alias from '@rollup/plugin-alias'
import { defineConfig } from 'rollup'
import pkg from './package.json'

const entries = {
Expand Down Expand Up @@ -46,13 +47,14 @@ function onwarn(message) {
console.error(message)
}

export default () => [
export default defineConfig([
{
input: entries,
output: {
dir: 'dist',
format: 'esm',
entryFileNames: '[name].js',
entryFileNames: '[name].mjs',
chunkFileNames: 'chunk-[name].mjs',
},
external,
plugins,
Expand All @@ -64,6 +66,7 @@ export default () => [
dir: 'dist',
format: 'cjs',
entryFileNames: '[name].cjs',
chunkFileNames: 'chunk-[name].cjs',
},
external,
plugins,
Expand All @@ -82,4 +85,4 @@ export default () => [
],
onwarn,
},
]
])
2 changes: 1 addition & 1 deletion packages/vite-node/vite-node.mjs
@@ -1,2 +1,2 @@
#!/usr/bin/env node
import('./dist/cli.js')
import('./dist/cli.mjs')

0 comments on commit 692ad34

Please sign in to comment.