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

Module '"tui-image-editor"' has no default export. #219

Open
iomaak opened this issue Jul 4, 2019 · 12 comments
Open

Module '"tui-image-editor"' has no default export. #219

iomaak opened this issue Jul 4, 2019 · 12 comments
Assignees
Labels
Enhancement Enhance performance or improve usability of original features.
Milestone

Comments

@iomaak
Copy link

iomaak commented Jul 4, 2019

Version

"ngx-tui-image-editor": "^7.0.2"
"tui-image-editor": "^3.5.2"

Development Environment

"@angular/core": "~7.2.0", window 10 enterprize

Current Behavior

As I have integrated tui editor in my angular application but while building it's giving me an error
Module '"tui-image-editor"' has no default export. In your toast-tui-image-editor.component.d.ts file.

So its integration error or its bug. Help on this.

Expected Behavior

@junghwan-park
Copy link
Member

@Omaak
Are you using Typescript? ImageEditor has no default export. If ngx-tui-image-editor using ImageEditor via default exported module, I think you should turn on esModuleInterop to ture in tsconfig.json.

Checkout https://github.com/nhn/tui.image-editor#typescript section.

@iomaak
Copy link
Author

iomaak commented Jul 5, 2019

I am using angular4 having angular core 7.0.2 and all dependencies are looking good but not able to understand why its giving error to me.

@mrbatista
Copy link

@Omaak it seems that the latest version is broken (3.6.1).
jwashke/toast-ui-image-editor-angular-wrapper@73fcee9. When load application I have this error:

tui-image-editor.js:41410 Uncaught TypeError: Cannot read property 'TYPED_ARRAY_SUPPORT' of undefined

Same library with version 3.5.2 works.

@junghwan-park, do you have any idea what the cause may be?

@mrbatista
Copy link

@junghwan-park I have investigate and the problem is related to latest update of fabric and how transpiling with webpack. The problem is related when fabric load the buffer library

@junghwan-park
Copy link
Member

@mrbatista
I think current webpack external library configure was wrong.
I'll add this issue to next release.

@junghwan-park junghwan-park added Bug and removed Question labels Aug 1, 2019
@junghwan-park junghwan-park added this to the v3.7.0 milestone Aug 1, 2019
@junghwan-park junghwan-park self-assigned this Aug 1, 2019
junghwan-park added a commit that referenced this issue Aug 2, 2019
…ion (fix #129, #134, #219) (#234)

* fix: Resolve jQuery vulnerability

* fix: Change fabric import method named to default & correct webpack external config (fix #129, #219)

* fix: Add fabric.js to external library into karma webpack config (fix #134)

* fix: Add half stroke width to center added icon's left, top
@mrbatista
Copy link

@junghwan-park issue resolved with the latest release.

@arimus
Copy link

arimus commented Sep 2, 2019

Just a note that this is still an issue in the latest release (3.7.0). And the mentioned solution of enabling esModuleInterop does work, but has some consequences. There are some problems this can cause with other modules. Currently, I'm running into bootstrap popover issues with it enabled. Like hard locking the browser rendering thread at 100% CPU kind of problems.

Any way we can get a typescript-friendly solution which doesn't involve esModuleInterop being required?

@junghwan-park
Copy link
Member

@arimus
ImageEditor is exported with commonJS pattern like module.exports = ImageEditor;
Please see src/js/imageEditor.js#L1542.

In TypeScript, you should import ImageEditor module via import ImageEditor = require('tui-image-editor'); syntax if you don't want to using esModuleInterop compiler option.
Please see typescriptlang.org / Modules - export = and import = require() section.

@arimus
Copy link

arimus commented Sep 3, 2019

@junghwan-park Unfortunately, using import assignment like that is not an option when you are targeting ECMAScript modules in typescript. That leads to a TS1202 error.

At a minimum it seems that with the latest angular stack, you have to set allowSyntheticDefaultImports to true and use the "import ImageEditor from 'tui-image-editor'" form. I'm trying to get to the root issue with that causing problems in other modules, so we'll see what I find there.

update: looks like allowSyntheticDefaultImports in a clean project allows the use above and there are no oddities with locking up like I observed in a much larger project with many deps. There must be something else causing some of the issues.

@jinwoo-kim-nhn jinwoo-kim-nhn added Enhancement Enhance performance or improve usability of original features. and removed Bug labels Jan 7, 2020
@jinwoo-kim-nhn
Copy link
Contributor

There is nothing wrong with the current state.

We will reconsider the default export support for future major updates.

@fernandorochaworld
Copy link

The error keeps alive in the Angular version of the editor.

error TS2307: Cannot find module 'toast-ui-image-editor'.
11 import { ToastUiImageEditorModule } from "toast-ui-image-editor";

I always get this error when trying to run the project.

HerlinMatos pushed a commit to EveryMundo/tui.image-editor that referenced this issue Jul 2, 2020
…ion (fix nhn#129, nhn#134, nhn#219) (nhn#234)

* fix: Resolve jQuery vulnerability

* fix: Change fabric import method named to default & correct webpack external config (fix nhn#129, nhn#219)

* fix: Add fabric.js to external library into karma webpack config (fix nhn#134)

* fix: Add half stroke width to center added icon's left, top
@tuyenttran
Copy link

tuyenttran commented Dec 17, 2021

We have tried to integrate with TypeScript in angular.
So in file index.d.ts,

Can we export the namespace
export = tuiImageEditor;

instead of
export = tuiImageEditor.ImageEditor;

This way, we can use all interfaces/types declared in this module by importing in TypeScript like

import * as tuiImageEditor from 'tui-image-editor';

public imageEditor = new tuiImageEditor.ImageEditor(...);
public imageEditorOptions: tuiImageEditor.IOptions;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Enhance performance or improve usability of original features.
Projects
None yet
Development

No branches or pull requests

7 participants