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

Add ES modules (ESM) support #84

Open
RabeeAbuBaker opened this issue Mar 18, 2024 · 2 comments
Open

Add ES modules (ESM) support #84

RabeeAbuBaker opened this issue Mar 18, 2024 · 2 comments

Comments

@RabeeAbuBaker
Copy link

Thank you for this awesome repo!!

I get this error after Importing AtButton into an ESM project ("type": "module")

image

import { AtButton } from "vite-component-library-template";
         ^^^^^^^^
SyntaxError: Named export 'AtButton' not found. The requested module 'vite-component-library-template' 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 'vite-component-library-template';
const { AtButton } = pkg;

    at ModuleJob._instantiate (node:internal/modules/esm/module_job:124:21)
    at ModuleJob.run (node:internal/modules/esm/module_job:190:5)
@RabeeAbuBaker
Copy link
Author

I was able to fix this by simply adding "type": "module" to package.json

@IgnacioNMiranda
Copy link
Owner

Hey! would you mind creating a PR with the change and an explanation? please also check if it creates any issue for other kind of deployments (:

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