frejs / fre

:ghost: Tiny Concurrent UI library with Fiber.

Home Page:https://fre.deno.dev

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Using as an ESM package with htm

wcastand opened this issue · comments

Hello :)
The title says most of it, i tried to use fre with htm as an ESM module so no compile time (i'm using skypack.dev for the import) and i get errors.

When i do : import { h, render, useState } from 'https://cdn.skypack.dev/fre';
i get an error saying the package doesn't export h

Uncaught SyntaxError: The requested module 'https://cdn.skypack.dev/fre' does not provide an export named 'h'

and when i do import fre from 'https://cdn.skypack.dev/fre';
i get a warning:

build:fre@v2.0.0-rc7-AqBU1BZDjxJhcj7ShvUU:14 [Package Error] "fre" could not be built. 
Installing package...
No "exports" main defined in fre/package.json
No "exports" main defined in /tmp/cdn/_AqBU1BZDjxJhcj7ShvUU/node_modules/fre/package.json

and an error after that :

build:fre@v2.0.0-rc7-AqBU1BZDjxJhcj7ShvUU:15 Uncaught Error: [Package Error] "fre" could not be built. 
    at build:fre@v2.0.0-rc7-AqBU1BZDjxJhcj7ShvUU:15

This is the really basic repo for testing if you want to look into to see if i made any obvious mistake :)
https://github.com/wcastand/esm-fre

I am orry, because the default export of fre is is UMD format, I want to know whether the ESM format is the mainstream and whether I should change the default export?

I haven't used skycdn, but unpkg can be downloaded module property from packacg.json

import { h, render } from 'https://unpkg.com/fre?module'

Thank you for your reminding. I found the problem where. It seems that the export property of package.json does not conform to skycdn specification.

We'll revise it right away, maybe tonight. @timeTravelCYN

https://docs.skypack.dev/package-authors/package-checks

@wcastand
We have released a new version. And strictly abide by skycdn specifications. Thanks @timeTravelCYN

At the same time, I pull a PR to you to fix some mistakes of htm.

I used to use fre + htm, which is very convenient.