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

Double default wrapping @emotion/cache #158

Closed
deviprsd opened this issue Jan 7, 2022 · 6 comments
Closed

Double default wrapping @emotion/cache #158

deviprsd opened this issue Jan 7, 2022 · 6 comments

Comments

@guybedford
Copy link
Member

This is because CommonJS conversion follows the Node.js semantics so that module.exports = { __esModule, default } is turned into a double default wrapper.

You can work around the issue by adding the module condition in the generator - then the "module" entry will be used from emotion, which you can see here - https://generator.jspm.io/#M2NhYGBkDM0rySzJSU1hcEjNzS/JzM/TT05Mzkh1MDTUM9czBAATEeXuJAA.

@deviprsd
Copy link
Author

deviprsd commented Jan 8, 2022

@guybedford I have figured this out like you said sometime today, but my biggest issue with "module" was process.env which isn't awfully hard to work around and I'm currently achieving it as such

(window as any).process = {
  env: {
    NODE_ENV: "production",
  },
};

I was hoping if there are any better ways to handle the process.env?

@guybedford
Copy link
Member

@deviprsd yes it's a common issue - JSPM could easily handle process.env but follows the browser semantics so doesn't add magic like this by default. I usually post PRs like reactjs/react-transition-group#777 to libraries for this.

@deviprsd
Copy link
Author

deviprsd commented Jan 8, 2022

Being an early adopter of import-maps has been a journey, SystemJS here comes to your rescue but so far jspm is the only one to provide proper support for a SystemJS CDN.

I'm big supporter of it but there is a long way to go to a bundler free web world.

@deviprsd deviprsd closed this as completed Jan 8, 2022
@jaydenseric
Copy link

@deviprsd

there is a long way to go to a bundler free web world.

I've been working full time for much of the last year on a zero build, Deno based SSR web framework utilising import maps and I'm getting closer to have solved the remaining problems (not relating to import maps). Along the way I've discovered some really cool techniques that are only possible with ESM and import maps, so I can't wait to share it all once it's ready!

Interestingly, I thought JSPM would be essential but it turns out after doing pure ESM right in almost all the dependencies they can be specified in the import map as being served raw from https://unpkg.com without any processing at all. JSPM is still the best thing when dependencies are not published correctly as pure ESM, but moving forwards I hope to avoid such situations.

@deviprsd
Copy link
Author

deviprsd commented Jan 8, 2022

@jaydenseric

I can't wait to share it all once it's ready!

I'll be looking out for it; I have very much made up my mind to go zero build, Deno and ESM. I have Learned a great deal from my company's mistakes and have been pushing them towards a transition state for the last year with Single-Spa (micro-frontend) which is also uses import-maps in its core through SystemJS.

Going full ESM is just a matter of the dependencies being used and if they support it, but I would be fine with tsc being my 1 step build. I have spend days researching and through trial & error ... trying to just get certain things to work just because how they are exported and which CDN provides the best conversion to work correctly.

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