landakram / remark-wiki-link

Parse and render wiki links.
MIT License
90 stars 15 forks source link

Use a default import #12

Closed landakram closed 3 years ago

landakram commented 3 years ago

In https://github.com/landakram/remark-wiki-link/pull/6, I removed the default import to prevent a warning in rollup. Almost all of the remark-* tools use a default import, so it's a little unexpected for people. It also fails silently.

Change the import to use a default import.

See:

entityleak commented 3 years ago

I'm using this plugin with a project built on top of Dendron, nuxt and Nuxt Content. It needs a default export to work here.

in nuxt.config.js

export default {
content: {
  markdown:{
    remarkPlugins: ['remark-wiki-link'],
  }
}

An update here to make it integrate seamlessly would be great :)

landakram commented 3 years ago

Apologies, I haven't had time to fix this yet. But the problem is that, when I upgraded to support breaking changes in unified, I decided to use rollup to support both cjs and esm module systems and ran into this issue. Essentially, default exports don't work well in esm and so rollup disallows them. So I removed the default export since I wanted to maintain maximum compatibility with different JS environments. Unfortunately, the remark/unified ecosystem is built around default exports, so the decision doesn't make much sense in retrospect.

I think only supporting cjs and providing a default export is a fine solution. If you or anyone else reading are able to make a fix, I would encourage and appreciate that. Otherwise, I will hopefully get to this soon.

landakram commented 3 years ago

Closed by https://github.com/landakram/remark-wiki-link/pull/17, released in 1.0.4