Khan / aphrodite

Framework-agnostic CSS-in-JS with support for server-side rendering, browser prefixing, and minimum CSS generation
5.34k stars 188 forks source link

How to load ESM from a CDN? (development without build) #394

Open dimaqq opened 4 years ago

dimaqq commented 4 years ago

I'm playing around with a style of development where I'd write, for example: import {html, Component, render, useState} from "https://unpkg.com/htm/preact/standalone.mjs";

And let evergreen browsers chew on that :)

It occurs to me that at the moment, same is not possible with aphrodite:

https://unpkg.com/aphrodite/dist/aphrodite.js is common js.

If I do import {css} from "https://unpkg.com/aphrodite@2.4.0/src/no-important.js"; then loading fails because src/util.js has import stringHash from 'string-hash';

It's same for es/..., where chunk-XXX has stringHash and import asap from 'asap';

baryla commented 4 years ago

It may not solve your problem but I suggest you use a UMD build (https://unpkg.com/aphrodite@2.4.0/dist/aphrodite.umd.min.js) or use something like wzrd.in or bundle.run to bundle everything into an IIFE.