Skip to content

Commit dc2c37d

Browse files
committed
build: fix Error [ERR_REQUIRE_ESM]
1 parent 4c4c7bd commit dc2c37d

File tree

3 files changed

+7
-6
lines changed

3 files changed

+7
-6
lines changed

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
{
22
"name": "json-editor-vue",
3+
"pascalCasedName": "JsonEditorVue",
34
"version": "0.9.2",
45
"private": false,
56
"packageManager": "pnpm@latest",

src/Component.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,11 +13,11 @@ import type { PropType } from 'vue-demi'
1313
import { JSONEditor } from 'vanilla-jsoneditor'
1414
import { conclude } from 'vue-global-config'
1515
import { debounce } from 'lodash-es'
16+
import { pascalCasedName as name } from '../package.json'
1617
import { globalAttrs, globalProps } from './index'
1718

1819
export type Mode = 'tree' | 'text'
1920

20-
const name = 'JsonEditorVue'
2121
const modelValueProp = isVue3 ? 'modelValue' : 'value'
2222
const updateModelValue = isVue3 ? 'update:modelValue' : 'input'
2323
const boolAttrs = [
@@ -166,5 +166,3 @@ export default defineComponent({
166166
return () => h('div', { ref: 'jsonEditorRef' })
167167
},
168168
})
169-
170-
export { name }

vite.config.ts

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { ConfigEnv, UserConfigExport } from 'vite'
22
import dts from 'vite-plugin-dts'
3-
import { name } from './package.json'
4-
import { name as globalVariableName } from './src/Component'
3+
import { name, pascalCasedName } from './package.json'
54

65
// https://vitejs.dev/config/
76
export default ({ command }: ConfigEnv): UserConfigExport => {
@@ -20,7 +19,10 @@ export default ({ command }: ConfigEnv): UserConfigExport => {
2019
],
2120
output: {
2221
globals: {
23-
[name]: globalVariableName,
22+
[name]: pascalCasedName,
23+
'vanilla-jsoneditor': 'JSONEditor',
24+
'vue': 'Vue',
25+
'vue-demi': 'VueDemi',
2426
},
2527
},
2628
},

0 commit comments

Comments
 (0)