nozer/quill-delta-to-html

module import

valentinbdv opened this issue · 5 comments

Is it possible to import the QuillDeltaToHtmlConverter constructor in a module base project after installing it with npm?

Thanks, great library!

It has worked by adding the full path in my file :

import {QuillDeltaToHtmlConverter} from '../../node_modules/quill-delta-to-html/src/QuillDeltaToHtmlConverter';

When I simply do this :

import QuillDeltaToHtmlConverter from 'quill-delta-to-html';

it tells me : Module ".../node_modules/quill-delta-to-html/dist/commonjs.main" he no default export.

I work with typescript if it helps

nozer commented

If you are importing to a .ts project, you should do import QuillDeltaToHtmlConverter = require('quill-delta-to-html');

If importing to a .js project, then you do var QuillDeltaToHtmlConverter = require('quill-delta-to-html');

Then you can do: let converter = new QuillDeltaToHtmlConverter([...], {..});

nozer commented

I may have to look into doing an export default ... as opposed to export = ... that I am doing currently. When exported with export default ..., import x from 'y' will work; however, when exported with export = syntax, then import must be like import x = require('y') from typescript;

Ok I didn't know that difference.
Indeed I think it would be better to just have import x from 'y' as most people will do I guess.
Or least explain that we have to add the require function in the README so that everybody has the right import from the first time!

Thanks a lot

nozer commented

Updated the README as you suggested.
You are welcome.