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

Cannot load plugin with an empty exports file #6403

Closed
1 task
giuseppelt opened this issue Mar 2, 2023 · 1 comment
Closed
1 task

Cannot load plugin with an empty exports file #6403

giuseppelt opened this issue Mar 2, 2023 · 1 comment

Comments

@giuseppelt
Copy link
Contributor

giuseppelt commented Mar 2, 2023

What version of astro are you using?

2.0.15

Are you using an SSR adapter? If so, which one?

None

What package manager are you using?

pnpm

What operating system are you using?

Windows

Describe the Bug

I'm the author of astro-lottie-integration plugin.
It worked fine with the 1.9+. With the new 2 version, it breaks while bootstrapping.

It seems the new astro/vite version has trouble importing and re-exporting empty exports files.
In the main index.js:

export * from "./types"

where types.js is just:

export {}

The syntax is totally valid and shouldn't be a problem.
I don't know if it is a issue with astro itself or some configuration passed downstream to vite.

The repro is easy (already setup in the stackblitz link). In an empty astro site, just add the plugin

npm install astro-integration-lottie@0.2.0

then in the astro.config file

import { defineConfig } from 'astro/config';
import lottie from 'astro-integration-lottie';

export default defineConfig({
  integrations: [lottie()],
});

With the plugin, the site doesn't start as it crashes when calling the function lottie(). See giuseppelt/astro-lottie#2 for a detailed error.

If I have to forward this to vite, it's fine for me.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/github-jvgdx2?file=astro.config.mjs&on=stackblitz

Participation

  • I am willing to submit a pull request for this issue.
@bluwy
Copy link
Member

bluwy commented Mar 7, 2023

Here's a better error message I found:

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/Users/bjorn/Work/repros/astro-ssr-default/node_modules/.pnpm/astro-integration-lottie@0.2.0/node_modules/astro-integration-lottie/dist/types' imported from /Users/bjorn/Work/repros/astro-ssr-default/node_modules/.pnpm/astro-integration-lottie@0.2.0/node_modules/astro-integration-lottie/dist/index.js
    at new NodeError (node:internal/errors:387:5)
    at finalizeResolution (node:internal/modules/esm/resolve:429:11)
    at moduleResolve (node:internal/modules/esm/resolve:1006:10)
    at defaultResolve (node:internal/modules/esm/resolve:1214:11)
    at nextResolve (node:internal/modules/esm/loader:165:28)
    at ESMLoader.resolve (node:internal/modules/esm/loader:844:30)
    at ESMLoader.getModuleJob (node:internal/modules/esm/loader:431:18)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
    at link (node:internal/modules/esm/module_job:75:36)

I think this makes sense as in nodejs you need to specify the full ./types.js path to work. Though I'm not sure why it used to work. I'll create a issue in Vite to improve this error, and close this for now since the package needs to be fixed to work in nodejs.

@bluwy bluwy closed this as not planned Won't fix, can't repro, duplicate, stale Mar 7, 2023
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