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

[Suggestion] Export the package as module #5

Open
yordan-kanchelov opened this issue May 27, 2019 · 34 comments
Open

[Suggestion] Export the package as module #5

yordan-kanchelov opened this issue May 27, 2019 · 34 comments

Comments

@yordan-kanchelov
Copy link
Contributor

It would be really easy and convenient if this is exported as npm package and to be able to import it in a project via the esnext import statement for example

@Mwni
Copy link
Owner

Mwni commented May 31, 2019

The newest version is compatible with nodejs.
By that I mean it's possible to import it as a module
const TextInput = require('./PIXI.TextInput')
Is that sufficient for it to work with esnext imports?

@buryo
Copy link

buryo commented May 31, 2019

Can u add more documentation about how to download and and use this please? I have no idea how to use this, struggling more than an hour now :/

(I'm using React)

@Mwni
Copy link
Owner

Mwni commented May 31, 2019

It's simply meant to be included in the html page. Grab the PIXI.TextInput.min.js from the dist folder and include it via a script a tag.
But I'm afraid you can't simply do that with react, it all gets compiled down and the html ist being generated for you, right?

@buryo
Copy link

buryo commented May 31, 2019

That's true, I already tried that =)

@Mwni
Copy link
Owner

Mwni commented May 31, 2019

How are you including pixi.js?

@buryo
Copy link

buryo commented May 31, 2019

Downloaded with NPM and including like:
import * as PIXI from 'pixi.js';

@yordan-kanchelov
Copy link
Contributor Author

yordan-kanchelov commented May 31, 2019

@Mwni My thought was to include it as npm package so you could be able to let's say

npm install pixi-text-input

and then include it like that

import { TextInput } from "pixi-text-input" ( or something like that )

Here is an example for a published project like that - https://github.com/jkanchelov/pixi-console
and here is an example project where it could be easily consumed https://github.com/jkanchelov/flappy-bird-pixijs

@ivanpopelyshev
Copy link

@Mwni if you want invite to pixijs slack, send an email to ivan.popelyshev@gmail.com , i'll send an invite.

There are people who can help with those kind of things.

@Mwni
Copy link
Owner

Mwni commented Jun 1, 2019

Okay first attempt of a npm package is online.
npm install pixi-text-input
then
const TextInput = require('pixi-text-input')
or
import 'pixi-text-input' as TextInput (not sure though)

Does it work? Can't test it inside node due to node not being a browser and don't have the browserify environment either.

@buryo
Copy link

buryo commented Jun 1, 2019

I think the npm package is okay but now we need to know how to use it I'm getting the following error:

I did:

  • npm install pixi-text-input
  • import TextInput from 'pixi-text-input';

Screenshot_3

Getting the error:
Attempted import error: 'TextInput' is not exported from 'pixi.js' (imported as 'PIXI').

@ivanpopelyshev
Copy link

ivanpopelyshev commented Jun 1, 2019

Lets meet in the middle. Its obviously that plugin creators who dont use React/Webpack and that stuff cnat get you everything. If we put something in npm and import kinda works - that's enough.

Import the module after you import pixi.js. Do not import classes.

Use PIXI.TextInput.

@buryo
Copy link

buryo commented Jun 1, 2019

I already tried almost everything Ivan, I think it doesn't inherit PIXI

@yordan-kanchelov
Copy link
Contributor Author

@buryo can you try and then confirm if let's say this package works for you https://github.com/jkanchelov/pixi-fps

@buryo
Copy link

buryo commented Jun 1, 2019

@jkanchelov Works like a charm! =)
https://i.imgur.com/e3y7M25.png

@yordan-kanchelov
Copy link
Contributor Author

Later today or tomorrow I will push the things you need to make it work and will go with pull request and if @Mwni approves it and publish the package you won't have problems afterward

@buryo
Copy link

buryo commented Jun 1, 2019

@jkanchelov Thanks for the effort hero

@yordan-kanchelov
Copy link
Contributor Author

#8

@Kurt-Montanaro
Copy link

Any luck with people using this in a typescript project?

@ivanpopelyshev
Copy link

@Kurt-Montanaro its not big, you can make typings for it.

@yordan-kanchelov
Copy link
Contributor Author

@Kurt-Montanaro i am using it from my fork but it’s still in a very ugly and early phase

@jjhesk
Copy link

jjhesk commented Jun 29, 2019

lets work on the npm module. someone already made it: https://github.com/jkanchelov/PIXI.TextInput

@jjhesk
Copy link

jjhesk commented Jun 30, 2019

no luck. i have got

having:

import TextInput from "pixi-text-input"

"Uncaught TypeError: pixi_text_input__WEBPACK_IMPORTED_MODULE_1___default.a is not a constructor"

@yordan-kanchelov
Copy link
Contributor Author

@jjhesk I could publish it in its current state, but currently, I don't have time to improve it

@jjhesk
Copy link

jjhesk commented Jun 30, 2019

yes, try my new PR i took 2 hours to made it done. https://github.com/ONode/pixi-textinput
usage:
import Textput from "pixi-textinput"

@connorjclark
Copy link

This package is a good example on how to support a Node and a drop-in browser target:
https://github.com/davidfig/pixi-viewport

Note the two types of file in dist/, and how module: in package.json points to a es.js file that exports its members (instead of polluting the PIXI namespace).

@karamvirs
Copy link

karamvirs commented Oct 2, 2019

There is no module export in TextInput.js file.
So just requiring it should work.
PIXI.TextInput = require('pixi-text-input')
But then I get another error:
"Cannot read property 'call' of undefined" in the _proto.render() function in PIXI.TextInput.js line 185.
On further troubleshooting I found that PIXI 4 is a dependency in package.json file of this module and the Container.js file in this dependecy (node_modules\pixi-text-input\node_modules\pixi.js\lib\core\display\Container.js) doesnt have a render() function. Only renderWebGL() and renderCanvas().
Deleting the node_module folder in the 'pixi-text-input' and using pixi 5 fixed the issue for me.

Has anyone else faced this issue?
I think it only works with PIXI 5.
If thats the case can you please update the dependecy in the npm package to PIXI 5?

@HusakYurii
Copy link

I have the same error, I am using pixi V5 (5.2.1). I installed "pixi-text-input" (now it is 1.0.4) feature, and created an instance of that and added to the stage, afterwards I run into that error related to rendering things. I think it is because now rendere was moved out of Display object?

@ivanpopelyshev
Copy link

it wasnt , its still there. Also all objects are Containers, displayobject is base abstraction , not being used directly.

@HusakYurii
Copy link

It's clear, thanks! So, the question to the author then, will it be fixed? Because it is such a great feature!

@Mwni
Copy link
Owner

Mwni commented Apr 26, 2020

ok, will patch in a few hours. have to add something else anyways.

@Mwni
Copy link
Owner

Mwni commented Apr 26, 2020

@HusakYurii please check if 1.0.5 is working for you now.

@HusakYurii
Copy link

@Mwni Good morning! Sorry for the delay!
Thank you a lot, it works (no more render issues thrown) !

I am building my bundle with pixi customize so, I added a few workarounds for my case, but in general it works !!!

@muhammadhaseebsohail
Copy link

i am still facing the same issue, can you guys let me know the exact version which cause no issue?

@HusakYurii
Copy link

@muhammadhaseebsohail I used PIXI.js v5.2.1 . The project was packed up using webpack

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants