tui.editor icon indicating copy to clipboard operation
tui.editor copied to clipboard

Custom named exports were specified for @toast-ui/editor/dist/esm/index.js but it does not appear to be a CommonJS module

Open ats1999 opened this issue 3 years ago • 3 comments

Describe the bug

I am trying to build a react-library using the editor. I'll customize this editor, styles, etc and used it across multiple projects.

I am using https://www.npmjs.com/package/create-react-library to build the package.

To Reproduce

Steps to reproduce the behaviour:

  1. Install https://www.npmjs.com/package/create-react-library
  2. npx create-react-library custom-editor
  3. cd ustom-editor
  4. npm i @toast-ui/editor-plugin-chart @toast-ui/editor-plugin-code-syntax-highlight @toast-ui/editor-plugin-color-syntax @toast-ui/editor-plugin-table-merged-cell @toast-ui/editor-plugin-uml @toast-ui/react-editor katex mermaid --save-dev
  5. npm start
  6. custom-editor/index.js
import React from 'react'
import { Editor } from '@toast-ui/react-editor'

export default function EditorComponent() {
  return (
    <Editor
      initialValue='hello react editor world!'
      previewStyle='vertical'
      height='600px'
      initialEditType='markdown'
      useCommandShortcut
    />
  )
}

Expected behaviour

It should load the editor but it's raising the below error

(commonjs plugin) Error: Custom named exports were specified for /home/rahul/Desktop/projects/temp/editor/tui/node_modules/@toast-ui/editor/dist/esm/index.js but it does not appear to be a CommonJS module
Error: Custom named exports were specified for /home/rahul/Desktop/projects/temp/editor/tui/node_modules/@toast-ui/editor/dist/esm/index.js but it does not appear to be a CommonJS module
    at transformCommonjs (/home/rahul/Desktop/projects/temp/editor/tui/node_modules/@rollup/plugin-commonjs/dist/index.js:753:13)
    at Object.transformAndCheckExports (/home/rahul/Desktop/projects/temp/editor/tui/node_modules/@rollup/plugin-commonjs/dist/index.js:1144:25)
    at Object.transform (/home/rahul/Desktop/projects/temp/editor/tui/node_modules/@rollup/plugin-commonjs/dist/index.js:1309:48)
    at /home/rahul/Desktop/projects/temp/editor/tui/node_modules/rollup/dist/shared/node-entry.js:13117:25

Screenshots

Screenshot from 2022-02-27 15-22-31

ats1999 avatar Feb 27 '22 09:02 ats1999

@ats1999

sorry for late reply, it is a ESM build. Are you in an SSR environment?

jwlee1108 avatar Mar 08 '22 00:03 jwlee1108

Yes. SSR environment causes this.

kgirma avatar Jul 27 '22 19:07 kgirma

@jwlee1108

kgirma avatar Jul 27 '22 19:07 kgirma