Open massimiliamanto74 opened 2 years ago
autoComplete.js is compiled as an umd module, which means webpack sometimes gets confused. There's a few silly things you can try;
const autoComplete = require("@tarekraafat/autocomplete.js")
const autoComplete = require("@tarekraafat/autocomplete.js/dist/autoComplete")
import { autoComplete } from "@tarekraafat/autocomplete.js/dist/autoComplete"
import { autoComplete } from "@tarekraafat/autocomplete.js/src"
I use the last one. But I don't use webpack, I use parcel nightlies.
Or you need to use library: { type: 'umd' } }
: https://webpack.js.org/guides/author-libraries/#expose-the-library
https://jameshfisher.com/2020/10/04/what-are-umd-modules/ https://stackoverflow.com/questions/50435253/webpack-imported-module-is-not-a-constructor
I have a ts project with webpack. I have installed the package with npm:
npm i @tarekraafat/autocomplete.js.
I have add the library in my file:import { autoComplete } from "@tarekraafat/autocomplete.js";
I try to create a autocomplete using demo example:I receive this error: Uncaught TypeError: _tarekraafat_autocomplete_js__WEBPACK_IMPORTED_MODULE_0__.autoComplete is not a constructor
[ ] System Information
[ ] Describe the bug When I call const autoCompleteJS = new autoComplete({options}) the error below return
[ ] To Reproduce Steps to reproduce the behavior: <!-- Example below-!> Open the app
[ ] Expected behavior Create the autocomplete
[ ] Screenshots or GIF's (optional, but HIGHLY RECOMMENDED) If applicable, add screenshots to help explain your problem.
[ ] Additional context (optional) Add any other context about the problem here.