-
-
Notifications
You must be signed in to change notification settings - Fork 357
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add some plugins to list of plugins #1291
Conversation
Added 3 plugins: - remark-fediverse-user - remark-corebc - remark-corepass Signed-off-by: Rastislav ₡ORE <rastislav@onion.email>
This comment has been minimized.
This comment has been minimized.
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #1291 +/- ##
=========================================
Coverage 100.00% 100.00%
=========================================
Files 6 6
Lines 142 142
=========================================
Hits 142 142 ☔ View full report in Codecov by Sentry. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rastislavcore!
Appreciate you sharing these.
A few thoughts which may benefit the projects:
- The example in the readme doesn't work https://github.com/bchainhub/remark-corebc/tree/1b682931b1dcbc1c6340ac4f6aaea5b770e42998?tab=readme-ov-file#usage .
remark
is ESM only, it cannot be imported withrequire
. - Consider using Node16 resolution in the TypeScript configuration https://www.typescriptlang.org/docs/handbook/modules/reference.html#node16-nodenext
Because node16 and nodenext are the only module options that reflect the complexities of Node.js’s dual module system, they are the only correct module options for all apps and libraries that are intended to run in Node.js v12 or later, whether they use ES modules or not.
- Consider running TSC to compile the JavaScript, then testing or running develop mode, as using a loader has different behavior from directly running the file. Or drop TypeScript syntax in favor of TypeScript JSDoc which can run without a compile step https://www.typescriptlang.org/docs/handbook/jsdoc-supported-types.html
- Consider adding
remark-plugin
as a keyword to the package.json, that is the topic/keyword all remark plugins use. - I'd recommend delivering in a single JS packaging format: the ESM format. But if you choose to dual package (https://github.com/bchainhub/remark-corebc/blob/1b682931b1dcbc1c6340ac4f6aaea5b770e42998/package.json#L55-L61) the require module needs to be in require format, this currently delivers ESM as require.
- Consider replacing
uvu
withnode:test
it is faster, more stable/supported, and has equally good ESM support https://nodejs.org/api/test.html - I'd recommend git ignoring generated files like the
dist
andtypes
folders, first time contributors tend to directly edit those instead of modifying the source files. Git ignoring generated removes that confusion. - When publishing through GitHub actions consider adding provenance for better traceability/security https://github.blog/2023-04-19-introducing-npm-package-provenance/
@ChristianMurphy Good catches! Mostly all of them integrated.
|
Thanks @rastislavcore!
It isn't required (none of them are).
Yes, Jest is becoming somewhat notorious for incomplete/broken ESM support (though no fault of their own, they have upstream dependencies blocking them).
What would you like clarified? A few other things:
|
All your points are valid. Thank you @ChristianMurphy for your feedback, it will increase the quality of the code.
I understand this part, but in there is CDN delivery services based on GitHub, which I found sometimes quite useful. Then I am keeping it. But I am open for discussion. Overall I would like to thank you, you are skilled developer willing to help other projects. |
A remark plugin written in TypeScript should roughly have the following layout: import { Root } from 'mdast'
import { Plugin } from 'unified'
import { visit } from 'unist-util-visit';
export interface RemarkCorepassOptions {
/**
* Describe this option here.
*/
enableIcanCheck?: boolean;
/**
* Describe this option here.
*/
enableSkippingIcanCheck?: boolean;
}
/**
* Describe your plugin here.
*/
const remarkCorepass: Plugin<[RemarkCorepassOptions?], Root> = (options = {}) => {
return (ast) => {
visit(ast, 'text', (node, index, parent) => {
})
}
}
export default remarkCorepass This gives you type inference for pretty much everything you need. There is no need for the Packages in the unified ecosystem currently support Node.js 16 and greater, so you can’t guarantee support for a lower version. For an example of a fairly minimal remark plugin authored in TypeScript, see |
See Remco's example above.
A surprising number of adopters do not read the readmes, and instead go straight to trying to use the plugin.
That is not enough for plug and play dependency systems like yarn and pnpm, it needs to be in
There are even more CDN services surrounding If the concern is serving the most recent and up-to-date version.
will serve you better, as it can deliver the raw source file from a PR or branch, without a compile step which may or may not have been run. |
Thank you folks @ChristianMurphy @remcohaszing for your advices. Highly appreciated! I tried to implement all your advices. When is something outstanding or some failure, please feel free to comment. I am really enjoying what you point out. Makes sense. |
@rastislavcore the types would be a lot simpler if you use Some other thoughts
|
You may also want to look into |
@ChristianMurphy is this ✅ for you now? |
@wooorm I won't block if others are comfortable. I'm not really yet, it doesn't work as documented #1291 (comment) |
@rastislavcore are you planning on working on these points listed by Christian? |
Sorry folks, I was quite busy. Will look today. |
I highly apologize for long delay gents. I had to take another project in the meantime. Anyway the update is:
@ChristianMurphy is it now ✅ ? |
Hey @rastislavcore! 👋 TL;DR Progress! One seems to mostly work as documented now! Two don't seem to work as documented still, and all three have typings which appear to be off/broken. More on that below: The types are still broken for all three #1291 (comment) The plugins still don't seem to do what their readmes say they do.
It doesn't crash now (progress!), but it also doesn't produce a link https://stackblitz.com/edit/github-cnzcy8-vrj5mk?file=src%2Fmain.ts The readme should also probably link to the specific Core Blockchain you support. Similar with CorePass
It is being transformed, but the generated content is not a link https://stackblitz.com/edit/github-2vdudu-xtnnmx?file=package.json,src%2Fmain.ts remark-fediverse-user does seem to work generating links now ✅ Though as noted above, the types are still psuedo-mdast, which poses risk to version upgrades and use with other plugins https://github.com/bchainhub/remark-fediverse-user/blob/cc1d3a631240306aa872d01653782948fa52b164/src/index.ts#L4-L31 |
Thank you, @ChristianMurphy, for the notes. They effectively improve the quality and security of the code. Changes:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @rastislavcore!
@types/unist
is no longer needed as adependency
https://github.com/bchainhub/remark-corebc/blob/bb441ad221834d347bdfbdae41ed9633ff4d5bb3/package.json#L42@types/mdast
is needed as adependency
(notdevDependency
) https://github.com/bchainhub/remark-corebc/blob/bb441ad221834d347bdfbdae41ed9633ff4d5bb3/package.json#L46- There is a merge conflict here, in this PR that needs to be resolved
Signed-off-by: Rastislav ₡ORE <rastislav@vasicka.eu>
Signed-off-by: Rastislav ₡ORE <rastislav@onion.email>
Thank you folks! @ChristianMurphy I am getting from tests:
https://github.com/remarkjs/remark/actions/runs/8883162589/job/24389434308?pr=1291#step:5:14 I assume something with tests itself? Is it? |
Core dump is the usually a message GHA prints if a job is cancelled.
|
Right. But why is it failing? 😅 Seems like all is fine now. I did do the correction. |
It looks like in your latest PR there's a different issue
That is coming from TypeScript and Node 22 not working together. |
Maybe then we should skip the tests because fix can be in next Node version. |
@wooorm @remcohaszing thoughts? |
Well that’s new. Is this No, the latest TS is 5.4.5, released 2 weeks ago. And last week this worked: https://github.com/remarkjs/remark/actions/runs/8814565179/job/24194685030 |
I do get this locally, on Node 22.0.0, with the same TS 5.4.5, on macOS. What fails is: $ ./node_modules/.bin/tsc --build
Segmentation fault: 11 |
@remcohaszing any knowledge of how best to debug TS to figure out where in the CLI things are going wrong? So we can figure out whether this is more an issue for TS or for Node? |
I’m troubleshooting by focusing on just I figured this might be related to that we’re doing some TypeScript things wrong, as I tried to explain in https://github.com/orgs/unifiedjs/discussions/238. However, that doesn’t solve it. I figured it could be related to types in JSDoc, but having only a Neither Downgrading to Node.js 20 solves it. I suggest we do this for the time being. |
Circling back here. It looks like this issue affects |
I locked the build to Node 20, rebasing to main should side-step this issue for now. |
That is GitHub's merge+rebase feature. |
Can’t you click “Update branch” here on this PR? And then pull locally? |
Initial checklist
Description of changes
Added 3 plugins into documentation: