UziTech / marked-emoji

https://www.npmjs.com/package/marked-emoji
MIT License
14 stars 3 forks source link

Error when importing the function markedEmoji #37

Closed OguzcanKarakoc closed 1 year ago

OguzcanKarakoc commented 1 year ago

This is the message I get in the browser (Chrome):

Uncaught SyntaxError: The requested module '/node_modules/.vite/deps/marked-emoji.js?v=9d3d8f9d' does not provide an export named 'markedEmoji' (at main.ts:20:9)

This is what is inside the main.ts file. maint.ts

import { createApp, type Plugin } from 'vue'
import { createPinia } from 'pinia'

import App from './App.vue'
import router from './router'

import './assets/main.scss'

import 'aos/dist/aos.css'
import hljs from 'highlight.js/lib/core';
import 'highlight.js/styles/github-dark-dimmed.css'
// import 'highlight.js/styles/github.css';
import 'highlight.js/lib/common';
import hljsVuePlugin from "@highlightjs/vue-plugin";

import Particles from "vue3-particles";

// #region: marked
import { marked } from 'marked';
import {markedEmoji} from "marked-emoji";
import {Octokit} from "@octokit/rest";
const octokit = new Octokit();
const res = await octokit.rest.emojis.get();
const emojis = res.data;
const options = {
    emojis,
    unicode: false,
};
marked.use(markedEmoji(options));

// #endregion: marked
const app = createApp(App)

app.use(Particles as Plugin)
app.use(hljsVuePlugin)
app.use(createPinia())
app.use(router)

app.mount('#app')

marked.setOptions({

  renderer: new marked.Renderer(),
  highlight: function(code, lang) {
    const language = hljs.getLanguage(lang) ? lang : 'plaintext';
    return hljs.highlight(code, { language }).value;
  },
  langPrefix: 'hljs language-', // highlight.js css expects a top-level 'hljs' class.
  pedantic: false,
  gfm: true,
  breaks: false,
  sanitize: false,
  smartypants: false,
  xhtml: false
});
UziTech commented 1 year ago

I haven't used vite but I wonder if it is using the umd script. The umd script adds window.markedEmoji as a global variable. see if that works.

If you could create a repo where I could reproduce this I could help debug it.

UziTech commented 1 year ago

closing as stale