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

esm file must be of extension .mjs #89

Open
said-m opened this issue Jul 31, 2023 · 1 comment
Open

esm file must be of extension .mjs #89

said-m opened this issue Jul 31, 2023 · 1 comment

Comments

@said-m
Copy link

said-m commented Jul 31, 2023

tldr: vuejs/vitepress#1399 (comment)

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
Copy link

bgervan commented Jan 2, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants