marp-team / marp-core

The core of Marp converter
MIT License
775 stars 130 forks source link

[bug] import failure `i is not a function` #322

Closed Mitoax closed 1 year ago

Mitoax commented 1 year ago
import { Marp } from "@marp-team/marp-core";

caused error:

image
yhatt commented 1 year ago

i means emoji-regex module. Is this code throwing some errors in your code context?

import emojiRegex from 'emoji-regex'
Mitoax commented 1 year ago

i means emoji-regex module. Is this code throwing some errors in your code context?

import emojiRegex from 'emoji-regex'

No error for this import

yhatt commented 1 year ago

OK, could you share a minimal reproducible example project? A code you've described is working on Node.js module without any errors.

If you are using a bundler, it may have met some kind of troubles about CommonJS interop from ESM.

yhatt commented 1 year ago

We have met exactly same situation in marp-team/marp-vscode. Here is a workaround: https://github.com/marp-team/marp-vscode/blob/23e905b970c81629353be31b564d50aadb2a8bc2/webpack.base.config.js#L7-L13

323 may resolve bundler's confusion about default export in external emoji modules.

yhatt commented 1 year ago

Confirmed it was fixed in v3.4.1.