Closed vikerman closed 4 years ago
One note of caution is that this is a breaking change: People who currently require or import ./dist/ paths directly would no longer be able to. This can be softened by adding an export of “./“.
Excited to see this added to htm!
Looks like the node version changed and the test is failing because npm cache has older version of compiled iltorb. Clearing the npm cache in Travis could help
@vikerman - just switched to Actions, hopefully that addresses it.
Everything looks good. I'm wondering if there's a way to test this though. Something like:
{
"scripts": {
"test:dist": "npm pack && mv htm*.tgz test/fixtures/dist/htm.tgz && cd test/fixtures/dist && node ."
}
}
... where dist/
would be:
// package.json
{ "dependencies": {"htm": "file:htm.tgz" } }
// index.mjs
import 'htm';
import 'htm/preact';
import 'htm/preact/standalone';
import 'htm/react';
Added the test. It's not hooked up to CI though. Would work for node versions >=13. [Edit: It's hooked up to the CI now]
Hooked up the ESM dist test to CI when node version is 14.x.
Wow, thanks @vikerman that is absolutely perfect!
Creates conditional export that points "import" conditional exports to mjs files. This lets node load the esm version without having to set "type": "module" on the main package.json.
This is similar to the approach in the main preact repo - https://github.com/preactjs/preact/pull/2451