Schotsl / Uwuifier

This repository contains the Uwuifier package! It's written in Deno with TypeScript and compiled into JavaScript for NPM, makes use of Jest for testing the code and is deployed on NPM and https://deno.land.
https://uwuifier.com
MIT License
110 stars 7 forks source link

"Uwuifier is not a constructor" at node version 18.9.0 #67

Closed phil-flip closed 2 years ago

phil-flip commented 2 years ago

This is in regard to https://github.com/Schotsl/Uwuifier/issues/65

But this is a very weird issue, because I don't seem to have the issue on the Docker container and on my old Windows installation. So I did a little digging and found out that it might be an issue with the node version.

Is there any way to fix this other than reverting to previous node versions?

phil-flip commented 2 years ago

And yes, I'm aware that the package is pushing import/export, but most of the other packages are still commonJS... But it does work… Just not with that little bit of version difference.

wouterdebruijn commented 2 years ago

What is provided in the "type" variable of your package.json?

This is a ES module. Your project should be a ES module for it to work properly.

Regarding the other packages still being commonJS, an ES module project will be able to import commonJS modules. An example can be found here: https://codesandbox.io/s/wandering-glitter-etq85n?file=/src/index.js

If you are able, please provide (part of) your source repository for more detailed assistance.

phil-flip commented 2 years ago

I am not using ES Module. The suggested method doesn't work with discord.js, unless I'm doing something wrong and don't quite understand this editor? https://codesandbox.io/s/wonderful-browser-1r558f?file=/src/index.js

wouterdebruijn commented 2 years ago

discord.js works with these imports.

Here is an example index.js file using both Discord.JS and Uwuifier.

index.js

import { IntentsBitField } from "discord.js"
import Uwuifier from "uwuifier"

const uwu = new Uwuifier();

const intents = new IntentsBitField([
    IntentsBitField.Flags.Guilds,
    IntentsBitField.Flags.GuildMessages
  ]);

console.log(intents);
// IntentsBitField { bitfield: 513 }

console.log(uwu.uwuifySentence("Some epic package making this sentence all uwu!"));
// Some epic package making this sentence aww uwu?!!

package.json

"type": "module"

Node version: v18.9.1

phil-flip commented 2 years ago

Yea, I just tested it as well. It wasn't always like that, tho. Might take some time to switch it out in the bot.

Schotsl commented 2 years ago

This issue is resolved then? :)

phil-flip commented 2 years ago

Yea. After thinking about it, ill opt for using version 4.0.4 on node 18.5.0 as changing it would require a lot of framework changes what I cant do at the moment.