remark-cite icon indicating copy to clipboard operation
remark-cite copied to clipboard

Export citePlugin as default

Open benjamineskola opened this issue 3 years ago • 3 comments

This seems to fix #1 by exporting a default method.

I've also ensured options is set, because otherwise I got an exception:

  1:1  error  TypeError: Cannot read property 'syntax' of undefined
    at Function.citePlugin (/Users/ben/Code/remark-cite/remark-cite/dist/index.cjs.js:21:72)
…

I'm not sure if there's a better way of writing that — I've never used typescript before.

benjamineskola avatar Apr 09 '22 19:04 benjamineskola

Thanks for the PR! I tried testing this locally with remark-cli (by installing remark-cli alongside remark-cite in a project, but replacing the @benrbray/remark-cite version string in package.json with the path to my local copy of your fork).

Were you able to successfully test this locally? What was your setup?

benrbray avatar Apr 10 '22 01:04 benrbray

Also as a side note: I think this will be a breaking change to the package since it changes how the citePlugin needs to be imported (as a default rather than named export). So I will need to bump the major version. I don't mind doing this as long as it does indeed fix the issue with remark-cli.

benrbray avatar Apr 10 '22 01:04 benrbray

I ran this locally by doing npm run build then npm install -g, and I was able to confirm that my …/node_modules/@benrbray/remark-cite/dist/index.*.js had the changes applied.

Then I was able to run remark test.md as normal and see first of all that in debug mode the extension was listed as being loaded (when it hadn't previously), and secondly that the output was as expected (citation nodes in the AST output, preserved citations in the markdown output).

benjamineskola avatar Apr 10 '22 08:04 benjamineskola

remark-cite now has a default export, so I believe this issue is resolved. Let me know if that's not the case!

benrbray avatar Jul 29 '24 13:07 benrbray