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

Update emotion support (MUI latest version) and add support for Node with ESM #45

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

dgadelha
Copy link

@dgadelha dgadelha commented Jun 6, 2023

  • Updates Emotion imports to use @emotion/react instead of @emotion/core [reference]
  • Add key to Emotion's createCache method, which is now required [reference]
  • Add support for loading config from ssr.config.cjs, as Node.js with ESM (package.json's "type": "module" doesn't allow require of .js files [reference]
  • Remove the dependency of urlsafe-base64, as it relies on Buffer API, which is not available in the browser

when a project uses type = module, require doesn't work
.cjs extension is needed to ensure code will be loaded otherwise an error will be thrown
it needs Buffer support, which is not available in the browser
LZString lib can handle this correctly
@dgadelha
Copy link
Author

dgadelha commented Jun 6, 2023

@saltyshiomix, somehow this is getting imported client-side and throws an Uncaught ReferenceError: process is not defined when rehydrating.

Locally, I've replaced this code with

const isProd = () => {
  return true;
};

but that doesn't seem to be the best option. I think maybe it is because the components (head, document) import the helpers.js, code that is ran client-side and fails.

I was only able to run this code with NODE_ENV=production, though. webpack-dev-server integration seems incomplete on 0.25.0-canary.2

EDIT: it seems that using import type { AlertColor } from "@mui/material"; and adding a prop color: AlertColor causes this behavior. I've removed this in my code and everything works fine now.

EDIT: fixed on last commit

@dgadelha dgadelha deleted the branch saltyshiomix:master June 14, 2023 18:42
@dgadelha dgadelha closed this Jun 14, 2023
@dgadelha dgadelha deleted the master branch June 14, 2023 18:42
@dgadelha dgadelha restored the master branch June 14, 2023 18:43
@dgadelha dgadelha reopened this Jun 14, 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

Successfully merging this pull request may close these issues.

1 participant