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

🐛 BUG: Generated code imports non-existent function createMetadata #808

Closed
joshamaju opened this issue Jun 25, 2023 · 2 comments
Closed

Comments

@joshamaju
Copy link

What version of @astrojs/compiler are you using?

1.5.1

What package manager are you using?

pnpm

What operating system are you using?

Mac

Describe the Bug

The generated output when calling the transform function contains the below import

import { createMetadata, createAstro, createComponent, render, maybeRenderHead, renderHead, renderComponent } from "astro/runtime/server/index.js";

const $$metadata = createMetadata("<stdin>", { modules: [], hydratedComponents: [], clientOnlyComponents: [], hydrationDirectives: /* @__PURE__ */ new Set([]), hoisted: [] });

but astro/runtime/server/index.js doesn't export createMetadata and $$metadata isn't used anywhere in the generated output.

Link to Minimal Reproducible Example

https://stackblitz.com/edit/vitejs-vite-nuwbp7?file=vite.config.js

@bluwy
Copy link
Member

bluwy commented Jun 25, 2023

The createMetadata is only added if the resolvePath option is not passed:

// Only needed if using fallback `resolvePath` as it calls `$$metadata.resolvePath`
if opts.opts.ResolvePath == nil {
p.addNilSourceMapping()
p.print("createMetadata as " + CREATE_METADATA)
}

Since Astro always pass the resolvePath option, it's provided astro/runtime/server/index.js runtime implementation can choose to not export the createMetadata API. The change was done in withastro/astro#5133

@bluwy bluwy closed this as not planned Won't fix, can't repro, duplicate, stale Jun 25, 2023
@joshamaju
Copy link
Author

Just added a noop

async resolvePath(specifier) {
    return specifier;
}

and it works, strange. Thanks

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