Skip to content

refactor: separate packages for Vue, React and Nuxt#34

Open
farnabaz wants to merge 12 commits intomainfrom
refactor/separate-packages
Open

refactor: separate packages for Vue, React and Nuxt#34
farnabaz wants to merge 12 commits intomainfrom
refactor/separate-packages

Conversation

@farnabaz
Copy link
Contributor

@farnabaz farnabaz commented Mar 5, 2026

Works in production: https://comark-sample-g9zr41pys-farnabazs-projects.vercel.app/

dependencies are:

  "dependencies": {
    "@comark/nuxt": "https://pkg.pr.new/comarkdown/comark/@comark/nuxt@34",
    "nuxt": "^4.3.1",
    "vue": "^3.5.29",
    "vue-router": "^4.6.4"
  }

@vercel
Copy link

vercel bot commented Mar 5, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
comark Error Error Mar 6, 2026 3:16pm

@pkg-pr-new
Copy link

pkg-pr-new bot commented Mar 5, 2026

Open in StackBlitz

comark

npm i https://pkg.pr.new/comarkdown/comark@34

@comark/nuxt

npm i https://pkg.pr.new/comarkdown/comark/@comark/nuxt@34

@comark/react

npm i https://pkg.pr.new/comarkdown/comark/@comark/react@34

@comark/vue

npm i https://pkg.pr.new/comarkdown/comark/@comark/vue@34

@comark/plugin-cjk

npm i https://pkg.pr.new/comarkdown/comark/@comark/plugin-cjk@34

@comark/plugin-math

npm i https://pkg.pr.new/comarkdown/comark/@comark/plugin-math@34

@comark/plugin-mermaid

npm i https://pkg.pr.new/comarkdown/comark/@comark/plugin-mermaid@34

commit: 4e194a2

@atinux
Copy link
Contributor

atinux commented Mar 5, 2026

Last refactor 🤞
Good for me @farnabaz 🚀

@@ -1,9 +1,8 @@
import { defineComarkComponent } from 'comark/vue'

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems wrong, as the defineComarkComponent fn is still used below

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm noticing now that the plugins also have the same problem where they export multiple frameworks' components / are bundled (meaning lots of potential issues with package deduplication in end user apps) -- I wonder if the plugins should only export the actual Comark plugin (for example, comarkMermaid), and the framework packages (@comark/svelte, @comark/vue, etc) should re-export them:

// `@comark/svelte/plugin-mermaid`
import { comarkMermaid } from '@comark/plugin-mermaid';
import { Mermaid } from './Mermaid.svelte';

export { Mermaid, comarkMermaid }

That way the vast majority of users still only have one package to install, and treeshaking will still work great...

input: ['./src/module.ts'],
},
],
externals: ['@nuxt/kit', 'nuxt', 'nuxt/schema', 'vue', '@comark/vue'],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think comark needs to be external as well, otherwise users who have both @comark/nuxt and comark installed will end up with two copies of comark, right?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

some additional questions about bundling / config that are confusing me as I work with the svelte lib

input: ['./src/index.ts'],
},
],
externals: ['react', 'react/jsx-runtime', 'comark'],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should have scule as well, right?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm still unclear on why this package needs to be bundled at all, but if it does need to be bundled, shouldn't it externalize its dependencies?

input: ['./src/index.ts'],
},
],
externals: ['comark'],

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same question here re: externalizing dependencies and being confused as to why we need a bundler in the first place

@elliott-with-the-longest-name-on-github

Having thought about it for most of the day, this is what's currently floating around in my head:

  • It's confusing that we're using a bundler for what appear to be js-only packages. At best this should just be a tsc step to generate the output ESM and, if necessary, an export map. This reduces the library's complexity and avoids a whole category of headaches around making sure we're externalizing the correct dependencies. (In the case of a library like this, really all of the dependencies should be externalized, which... kind of defeats the purpose of bundling in the first place.)
  • For the standalone plugins, I think we should pare them down to only the actual plugin code, and move the framework-specific implementations into the framework packages as subpath exports. Users of frameworks are going to be using a bundler and therefore will trivially be able to treeshake away plugins they're not using, and it means we can keep the framework-specific stuff in the "leaves" of the library and maintain a single package installation / import for the vast majority of cases.
  • Incidentally, this'll also give us better indications of usage / growth by framework, as all "things to do with a given framework" will be handled under their own packages with their own download statistics

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants