Yarn Classic #287
Replies: 31 comments
-
Hi, thanks :) I am still making steady progress with it. I got it to load pixijs, kaplayjs, kaboom and some other external modules (see gist demos). It loads them from a web address atm, so if pixivn doesn't have its dist file hosted anywhere to be included as a script tag, I am thinking of allowing to host it with the other files in the gist. Running from yarns playground sort of requires to fully be able to run from a Web browser. The yarn editor data is already included in the output html and can be referenced by any scripts. The idea is to make a pixivn setup js file in the examples gist and allow anyone to quickly open yarn editor with that file ready to spin up pixivn with the editor data in a click. From there on the power user can extend its js wrapper. The creative writer user will just work on the dialogue tree side. The power creative user will be able to do both directly in the browser and have it backed up as a public or secret gist. The game can then be exported as a single html file with all the modules bundled in it. Resources like images and music could also be bundled as base64 strings in the html file, or cound be exported with it in a zip. I am still a bit undecided how to do them and for now am relying on them being hosted somewhere else, like the modules. Using base64 strings has the benefit of making it a bit harder for players to extract resources from a game bundle and just preview all the pictures in the game before even playing it. In the future I might expand this to use proper github repositories instead of gist. I like the simplicity of gist :) btw they have commit history and can revert changes, so are quite a powerful system to store code in yarn ticket |
Beta Was this translation helpful? Give feedback.
-
The dist/index.js file that gets generated, can it be used outside of node modules scenario? Would it work in a codepen? I am assuming that its dependent modules dont get included in the same output module file?
|
Beta Was this translation helpful? Give feedback.
-
it should work on codepen |
Beta Was this translation helpful? Give feedback.
-
what do you mean by "node modules scenario"? |
Beta Was this translation helpful? Give feedback.
-
they are not included in the pixi-vn npm package. |
Beta Was this translation helpful? Give feedback.
-
can you effectively run pixi-vn when bundling it at a codepen? https://codepen.io/your-work Remember since its purely online, there is no npm, and no node. These dependencies are not included in the file so I am guessing you have to add them manually as script tags? Pixijs sort of just works out of the box if you include a link to it as a script tag, because all of that was handled and tested. That is why there are lots of online in browser examples of pixijs which dont require the user to set up a dev environment and run a dev server. They just work on pixijs playground as well as codepens for example can you do this
here is a simple pixi js example I think you can get it to do that by playing with the settings of your bundler. These type of modules try to pack all their deps in the same file - so do have an increased dist size. Dev dependencies are not included btw. So if any of them are needed for it to function, they need to be moved to ordinary deps. |
Beta Was this translation helpful? Give feedback.
-
I tried it, but I couldn't get it to work (I'm not sure if I imported the library correctly, it's my first time using codepen). Theoretically the initialization shouldn't be much different from initializing the pixi-js application https://github.com/DRincs-Productions/pixi-vn/blob/main/src/managers/WindowManager.ts I don't know why it doesn't work. |
Beta Was this translation helpful? Give feedback.
-
the module at https://esm.sh/@drincs/[email protected] It looks more like this see how all of the dependencies, all the files from the project needed to run it - its all bundled in one file that is minified. Nothing is imported or required. On the codepen it looks like it tries to load a bunch of (relative?) files and fails to do so |
Beta Was this translation helpful? Give feedback.
-
I was looking at unpkg. https://unpkg.com/browse/@drincs/[email protected]/dist/ importing https://unpkg.com/browse/@drincs/[email protected]/dist/index.js might work |
Beta Was this translation helpful? Give feedback.
-
are you trying to import pixi-vn or pixi.js? |
Beta Was this translation helpful? Give feedback.
-
pixivn is the goal of this :) https://unpkg.com/browse/@drincs/[email protected]/dist/index.js This is something that vite probably can output for you btw. I suspect that you just have to enable it somehow. It is what bundlers are supposed to solve (rollup, webpack, vite, etc) maybe this? in theory the output file will contain pixijs and all the other files that you require/import, which means the browser has to do a single fetch request to get pixi-vn downloaded and ready to run. Having such an output file will not just benefit Yarn, it will benefit anyone else trying to use this module in a web scenario |
Beta Was this translation helpful? Give feedback.
-
It doesn't make sense to me, because pixi vn doesn't use version 8.3.3, but 8.3.2 I had done some tests, in theory it works for all modules, exactly like pixi.js. However I will check better. I made a step forward I managed to import the library GameWindowManager recognizes me, but it is undefined |
Beta Was this translation helpful? Give feedback.
-
In console you can see - the browser doesnt recognise "require" as part of its api |
Beta Was this translation helpful? Give feedback.
-
I added the ability to import the library with "many more technologies"(module CJS ESM). I basically followed this solution https://dev.to/orabazu/how-to-bundle-a-tree-shakable-typescript-library-with-tsup-and-publish-with-npm-3c46 Now you won't have the "require" error anymore. Could you try again? I noticed another error with the pixi.js import on codepen, I don't think you have it too. #209 To fix it I think I have to import all the Pixi.js features with: import * as PIXI from "pixi.js" I'll create another version to fix it, with other small fixes of the new version 0.7.0 |
Beta Was this translation helpful? Give feedback.
-
thank you :) I will give this a try over the weekend. Is the codepen here working then? |
Beta Was this translation helpful? Give feedback.
-
what happens if you include pixijs in the same codepen? Can it be made to work that way? Just to be clear, if this doesnt work in codepen, it will not work in yarn |
Beta Was this translation helpful? Give feedback.
-
I tried, but it didn't work. the thing is that I don't understand the problem and why it gives that error. I import Assets in the correct way https://pixijs.download/dev/docs/assets.html. I had to go by trial and error to solve it. |
Beta Was this translation helpful? Give feedback.
-
You need to use vite as a bundler That way the output is guaranteed to work the same way as it does in a dev environment. If you don't use a bundler output, what if whoever tries pixivn uses the wrong pixijs version with it. You run in all sorts of issues if you have a library with dependencies and you are not bundling the output. Just by using different versions of the dependencies, they are almost certain to run into bugs with version combinations you haven't tested. If you didn't have any deps like pixijs and others, you could have had it as a simple es6 module and do it with the import keyword from a script tagged as type module. But it has dependencies that the web browser doesn't know where to find. That's the reason we have and use bundlers. Its a build process setup problem, nothing with the code imo. I am assuming the vite configuration file needs to be told to export this type of module to produce a single file bundle? vitejs/vite#16123 I'm not entirely sure why its not bundling them, so I guess it just needs some googling |
Beta Was this translation helpful? Give feedback.
-
hello sorry but it's not clear to me what I should do. I currently use "tsup" to generate the package. and reading here it seems that there is a way to do it egoist/tsup#619 what do you think? but I don't like the fact of inserting pixi.js in the pixivn package. being able to update PixiJS to a more recent version than the one in pixivn can have its advantages. I've never used yarn, but if I'm not mistaken you don't import the libraries via an HTML file like I'm doing on codepen, right? I'm afraid that on codepen I'm not importing the libraries in the right way, maybe with yarn now it could work |
Beta Was this translation helpful? Give feedback.
-
So in my approach I have to keep yarn's bundle size small - so i created a plugin api to allow to treat these features as an extension - something the user chooses to add to yarn from a gist or a web address. For that to work, it needs to use a web module import - not a new node module dependency. With web modules, as I explained they all do that - bundle their dependencies in the same output file. pixijs itself does that too - you end up with a bigger file, but it guarantees that it will work regardless of how its used. The bundler can reduce the file size by minifying it. But this not about using one over the other - but adding the option for using a web module version to the already existing option. |
Beta Was this translation helpful? Give feedback.
-
Ok, this is the best solution. I wonder if it is possible to do this with tsup. https://github.com/egoist/tsup |
Beta Was this translation helpful? Give feedback.
-
Cool, I haven't hear of this before but its interesting. I thought that ts and vite already handle this. |
Beta Was this translation helpful? Give feedback.
-
I solved it, just put the libraries in devDependencies. |
Beta Was this translation helpful? Give feedback.
-
the best thing is that now I can use codepen for the wiki examples |
Beta Was this translation helpful? Give feedback.
-
Hi Thanks for getting it this far :) On your demo, can you at least make it show a picture and draw some text, so we can be sure that at its most basic its functional? The demo is just drawing a red square atm. Most of the current yarn demos are a copy of either pixijs playground, codepens or kaboomjs playground. I like using those as a way to also test my own playground. If it works on any of the other playgrounds, but doesnt in yarn - that means that yarn's playground has a problem. The cool thing about all of this is that it already allows creating easy share links where people can try these demos in a click and even save them locally. I am going to update the readme with a nice list with links to these playground demos too - so they are more visible |
Beta Was this translation helpful? Give feedback.
-
I really like the possibility of using YarnClassic. I also read the readme you updated recently, and I can't wait to try using it with pixi-vn.
Theoretically it shouldn't have any dependencies now. But I haven't done enough testing to get a feel for the performance. Is it that slow?
Ok I can create a test example from that site. What do you think I should show in the example? in the example i would like to show the fact that it is possible to use ink to write the narration, i should finish a big update soon that adds many functions of ink (pretty much all except the use of functions), and i would also like to finish DRincs-Productions/pixi-vn-ink#24 how would the connection between pixi-vn, YarnClassic and Ink work? |
Beta Was this translation helpful? Give feedback.
-
Hi @blurymind I've finished the development of the ink integration. I just created an example on code pen to see if the inports work: https://codepen.io/BlackRam-oss/pen/XWvjVjv Here you can find the documentation of the integration: https://pixi-vn.web.app/ink/ink.html |
Beta Was this translation helpful? Give feedback.
-
@blurymind Hi, sorry to insist, could you tell me if you can import the pixi-vn-ink library correctly? |
Beta Was this translation helpful? Give feedback.
-
I will have another test. It need to import and render a sprite with some text at least imo. If that works in your codepen, it should be enough to confirm that it works |
Beta Was this translation helpful? Give feedback.
-
Ok I also added an image. Anyway if you want to do quick tests I added a sandbox to the wiki to do quick tests https://pixi-vn.web.app/ink/ink.html |
Beta Was this translation helpful? Give feedback.
-
Hi @blurymind I closed issue #161 and opened this one, because the first ink implementation is now complete, but I wanted to keep an issue open to keep myself informed about the possibility of developing in PixiVN with YarnClassic.
I will also link this issue to the PixiVN documentation, considering that it is a development phase.
Beta Was this translation helpful? Give feedback.
All reactions