Skip to content
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

After migration, failed to load markdown-it plugins #1307

Closed
zillionare opened this issue Feb 19, 2024 · 2 comments
Closed

After migration, failed to load markdown-it plugins #1307

zillionare opened this issue Feb 19, 2024 · 2 comments

Comments

@zillionare
Copy link

Describe the bug
I used to load markdown-it-admon in vite.config.ts like this:

// vite.config.ts
        markdown: {
            /* markdown-it options */
            markdownItSetup(md) {
                /* custom markdown-it plugins */
                md.use(require('markdown-it-admon'));
                md.use(require('markdown-it-container'), 'takeaway');
                md.use(emoji);
            },
        },

when upgrading slidev to 0.48 beta, I have to make these changes:

//vite.config.ts

        markdown: {
            /* markdown-it options */
            markdownItSetup(md) {
                /* custom markdown-it plugins */
                md.use('markdown-it-admon'); /*remove require, otherwise, throw dynamic loading is not allowed error!!!*/
                md.use('markdown-it-container', 'takeaway');
                md.use(emoji);
            },
        },

at package.json, add this statement:

  "type": "module",

after upgrading, I'll got this error:

file:///apps/slidev_themes/node_modules/markdown-it/lib/index.mjs:485
  plugin.apply(plugin, args)
         ^

TypeError: plugin.apply is not a function
    at MarkdownIt.use (file:///apps/slidev_themes/node_modules/markdown-it/lib/index.mjs:485:10)
    at Object.markdownItSetup (file:///apps/slidev_themes/vite.config.ts.timestamp-1708337595180-85208ee05ece2.mjs:22:12)
    at Object.markdownItSetup (file:///apps/slidev_themes/node_modules/@slidev/cli/dist/chunk-FIXL4WBO.mjs:1562:35)
    at createMarkdown (file:///apps/slidev_themes/node_modules/unplugin-vue-markdown/dist/chunk-XC4FHL6S.js:144:17)
    at unpluginFactory (file:///apps/slidev_themes/node_modules/unplugin-vue-markdown/dist/chunk-XC4FHL6S.js:314:25)
    at file:///apps/slidev_themes/node_modules/unplugin/dist/index.mjs:1571:32
    at createMarkdownPlugin (file:///apps/slidev_themes/node_modules/@slidev/cli/dist/chunk-FIXL4WBO.mjs:1537:10)
    at async ViteSlidevPlugin (file:///apps/slidev_themes/node_modules/@slidev/cli/dist/chunk-FIXL4WBO.mjs:1816:26)
    at async createServer (file:///apps/slidev_themes/node_modules/@slidev/cli/dist/chunk-PDMXU2K7.mjs:2523:11)
    at async initServer (file:///apps/slidev_themes/node_modules/@slidev/cli/dist/cli.mjs:116:16)

Node.js v18.16.1

I know this may caused by convert from cjs to esm (no idea what this is though), but don't know how to fix it.

Many thanks if you could help!

Desktop (please complete the following information):

  • Slidev version: 0.48 beta
@zillionare
Copy link
Author

previous workable version is 0.42.11

@antfu
Copy link
Member

antfu commented Feb 19, 2024

We temporarily closed this due to the lack of enough information. We could not identify whether it was a bug or a userland misconfiguration with the given info.
Please provide a minimal reproduction to reopen the issue.
Thanks.

Why reproduction is required

@antfu antfu closed this as completed Feb 19, 2024
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

No branches or pull requests

2 participants