core icon indicating copy to clipboard operation
core copied to clipboard

Compiled code causes unexpected issues with ESMs

Open legodude17 opened this issue 2 years ago • 1 comments

  • remark-embedder-core version: 3.0.1
  • node version: 18.4.0
  • npm version: 8.13.0

Relevant code or config

Copied directly from example, except added braces around the remark import.

What you did: Ran the code.

What happened: Nothing. The output simply created two <p> tags, rather than the embed.

Problem description: When doing import remarkEmbedder from '@remark-embedder/core' you actually get an object with a single property: default, which then actually contains the function. When passed to unified, this does nothing. In order to use it, you must instead write remarkEmbedder.default, which is rather counterintuitive.

Suggested solution: Change the build system to include ESM code, for importing.

legodude17 avatar Oct 12 '22 01:10 legodude17

Running into the same issue. I think the solution would be to either expose an ESM entry point or maybe different type definitions somehow? Not sure exactly

TomerAberbach avatar Apr 13 '24 21:04 TomerAberbach