MaxLeiter / sortablejs-vue3

A thin wrapper around Sortable.js for Vue 3
https://sortablejs-vue3.maxleiter.com
MIT License
364 stars 20 forks source link

esm file must be of extension .mjs #89

Open said-m opened 11 months ago

said-m commented 11 months ago

tldr: https://github.com/vuejs/vitepress/issues/1399#issuecomment-1258364648

hi, when component builds inside vitepress, it's fails with error:

✖ rendering pages...
build error:
 file:///Users/path-to-project/docs/.vitepress/.temp/SomeComponent.c214d190.js:4
import { Sortable } from "sortablejs-vue3";
         ^^^^^^^^
SyntaxError: Named export 'Sortable' not found. The requested module 'sortablejs-vue3' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:

import pkg from 'sortablejs-vue3';
const { Sortable } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:190:5)

to handle such cases with different environments, need to change the extension of the file from .es.js to .es.mjs in package.json and vite.config of this project. checked locally with the this changes, project builds without errors and everything works

bgervan commented 6 months ago

@said-m can you create a PR for this change? I am using vitesse and get the same error