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

broken SSR: environment-glimmerx does not support nodejs modules #223

Closed
lifeart opened this issue Oct 17, 2021 · 5 comments
Closed

broken SSR: environment-glimmerx does not support nodejs modules #223

lifeart opened this issue Oct 17, 2021 · 5 comments

Comments

@lifeart
Copy link

lifeart commented Oct 17, 2021

If I use

import Component from '@glint/environment-glimmerx/component';

ssr build fails with:

13:40:24 [vite] Error when evaluating SSR module /node_modules/@glint/environment-glimmerx/component/index.js?v=b8520994:
ReferenceError: exports is not defined
    at /node_modules/@glint/environment-glimmerx/component/index.js?v=b8520994:24:23
    at instantiateModule (C:\Users\lifeart\Documents\repos\glimmerx-workshop\node_modules\vite\dist\node\chunks\dep-55830a1a.js:66458:15)

if I replace import with glimmerx default-one, SSR works

It will be great to have this package shipped in 2 types: esm & cjs

@dfreeman
Copy link
Member

dfreeman commented Nov 5, 2021

Can you provide a reproduction for this issue? It would surprise me if in general CJS modules were working for the browser but specifically breaking in SSR, especially since CJS is still so common in the Node ecosystem as a whole.

I do see that GlimmerX ships both versions, but I'd love to understand if that's working around some other intrinsic incompatibility between Vite's SSR mode and CJS modules.

@lifeart
Copy link
Author

lifeart commented Nov 7, 2021

may be related: josemarluedke/glimmer-apollo#45

@dfreeman reproduction: https://github.com/lifeart/glimmerx-workshop/tree/glint-ssr-issue-reproduction

steps to get error: yarn && yarn dev, visit: http://localhost:3000

@dfreeman
Copy link
Member

As of Glint 0.7.4 native import paths are available, and as of version 0.8.0, Glint no longer exposes any runtime imports itself, so this should no longer be a problem! Check out the migration guide for further details.

@knownasilya
Copy link

@lifeart any plans to update your vite plugin?

@lifeart
Copy link
Author

lifeart commented Oct 2, 2022

@knownasilya this update should work without plugin update. But let me know if we could improve smf in vite-plugin-glimmerx

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

3 participants