bigskysoftware / idiomorph

A DOM-merging algorithm
BSD 2-Clause "Simplified" License
631 stars 31 forks source link

Idiomorph imported as empty object #28

Closed DEfusion closed 5 months ago

DEfusion commented 6 months ago

If I try using 0.3.0 with webpack (we're on 4, moving to esbuild shortly) & babel I get an error thatIdiomorph.morph is undefined, if I do the following:

import Idiomorph from 'idiomorph';

console.log(Idiomorph);

I get an empty object logged.

For now I'm just sticking on 0.2.0. I don't know enough about the craziness of providing the different module formats via packages but I know I've seen entries in package.json for other projects that are like:

"module": "dist/foo.js",
"main": "dist/foo.umd.js",

Sorry if that doesn't help.

MaxHatfull commented 6 months ago

We're also seeing this issue

1cg commented 6 months ago

can you try:

import Idiomorph from 'idiomorph.umd';

(I think)

We split all the different types of modules out into various module-files

MaxHatfull commented 6 months ago

I managed to get this working. We were seeing the issue in Jest which turned out to be a transformer issue. I added the following to our jest config:

"transformIgnorePatterns": [ "node_modules/(?!(idiomorph)/)" ]

and importing like this: import { Idiomorph } from "idiomorph/dist/idiomorph.esm";

I hope this gives others some clues for their issue.

davidjr82 commented 5 months ago

and importing like this: import { Idiomorph } from "idiomorph/dist/idiomorph.esm";

I hope this gives others some clues for their issue.

Thanks for the tip @MaxHatfull, works for me with:

import { Idiomorph } from "idiomorph/dist/idiomorph.esm";
window.Idiomorph = Idiomorph;
weaverryan commented 5 months ago

Also using import { Idiomorph } from 'idiomorph/dist/idiomorph.esm.js'; - perhaps the module key is simply missing from package.json to point to this file?

Fix Proposed in #35.