jasononeil / webpack-haxe-loader

Webpack loader for the Haxe programming language.
MIT License
38 stars 11 forks source link

Haxeflixel #81

Closed joseasv closed 2 years ago

joseasv commented 2 years ago

Hello. I've been trying to use hot reload with my HaxeFlixel game with webpack-haxe-loader. My haxe code is very similar to the Hello World of the HaxeFlixel documentation (https://haxeflixel.com/documentation/hello-world/). I'm only using the HaxeFlixel libraries. This is my XHML:

-lib haxe-loader -lib lime -lib openfl -lib flixel -cp source -main Main -js out.js

When I execute webpack-dev-server I get this error: webpack-dev-server --open [webpack-dev-server] Project is running at: [webpack-dev-server] Loopback: http://localhost:9000/ [webpack-dev-server] On Your Network (IPv4): http://192.168.0.112:9000/ [webpack-dev-server] Content not from webpack is served from 'C:\HaxeProjects\HelloWorld\public' directory [webpack-dev-middleware] wait until bundle finished: / asset bundle.js 220 KiB [emitted] (name: main) 1 related asset runtime modules 27.2 KiB 12 modules modules by path ./node_modules/ 161 KiB modules by path ./node_modules/webpack-dev-server/client/ 56.8 KiB 12 modules modules by path ./node_modules/webpack/hot/*.js 4.3 KiB ./node_modules/webpack/hot/dev-server.js 1.59 KiB [built] [code generated] ./node_modules/webpack/hot/log.js 1.34 KiB [built] [code generated]

  • 2 modules modules by path ./node_modules/html-entities/lib/*.js 81.3 KiB ./node_modules/html-entities/lib/index.js 7.74 KiB [built] [code generated] ./node_modules/html-entities/lib/named-references.js 72.7 KiB [built] [code generated] ./node_modules/html-entities/lib/numeric-unicode-map.js 339 bytes [built] [code generated] ./node_modules/html-entities/lib/surrogate-pairs.js 537 bytes [built] [code generated] ./node_modules/ansi-html-community/index.js 4.16 KiB [built] [code generated] ./node_modules/events/events.js 14.5 KiB [built] [code generated] ./app.hxml 39 bytes [built] [code generated] [5 errors]

ERROR in ./app.hxml Module Error (from ./node_modules/haxe-loader/index.js): C:\HaxeToolkit\haxe\lib\flixel/4,11,0/flixel/graphics/FlxGraphic.hx:15: characters 8-32 : Type not found : openfl.display.Tilesheet

ERROR in ./app.hxml Module Error (from ./node_modules/haxe-loader/index.js): C:\HaxeToolkit\haxe\lib\flixel/4,11,0/flixel/graphics/FlxGraphic.hx:328: characters 35-44 : Type not found : Tilesheet

ERROR in ./app.hxml Module Error (from ./node_modules/haxe-loader/index.js): C:\HaxeToolkit\haxe\lib\flixel/4,11,0/flixel/graphics/tile/FlxDrawBaseItem.hx:9: characters 8-32 : Type not found : openfl.display.Tilesheet

ERROR in ./app.hxml Module Error (from ./node_modules/haxe-loader/index.js): C:\HaxeToolkit\haxe\lib\flixel/4,11,0/flixel/graphics/tile/FlxDrawTilesItem.hx:10: characters 8-32 : Type not found : openfl.display.Tilesheet

ERROR in ./app.hxml Module build failed (from ./node_modules/haxe-loader/index.js): Haxe Loader: Compilation failed haxe -debug -D webpack_namespace=app -lib haxe-loader -lib lime -lib openfl -lib flixel -cp "C:\HaxeProjects\HelloWorld\source" -main Main -js C:\Users\JOSESA~1\AppData\Local\Temp\tmp-6868ZYFfD25XQsji.js

4 errors have detailed information that is not shown. Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.

webpack 5.71.0 compiled with 5 errors in 49088 ms

I see that haxe-loader fails to find openfl types and I did add openfl and flixel in the HXML.

elsassph commented 2 years ago

It is recommended to use the lime CLI to compile your HaxeFlixel project. Ensure you get everything working with that first. It does possibly quite a bit of magic that you'll have a hard time reproducing with a manual build command.

For the error you get however there may be a version mismatch somewhere because Tilesheet class was removed from OpenFl a long time ago now https://community.openfl.org/t/type-not-found-openfl-display-tilesheet/7892

Now as far as hot-reload is concerned, I'm not sure Webpack will do what you expect - it's not automatic in general. What are you trying to achieve?

joseasv commented 2 years ago

Yes, the project compiles with lime just fine. I'm using it to generate a HTML5 build (Also working with Neko with no problems). I just want to change my code and trigger a refresh in the browser.

I'm using the latest openfl and flixel. At least with Neko I don't see those errors.

elsassph commented 2 years ago

So the problem is that lime does some magic.

I think lime has a -watch option to automatically rebuild on file changes, then there are http servers which can automatically refresh the browser (I've used https://nitoyon.github.io/livereloadx/ a lot) when the content changes.

I recommend you discuss that in the lime/haxeflixel community forums - I'm afraid webpack isn't really the best solution for you.

joseasv commented 2 years ago

No problem. I will look into lime first and then go to the forums. Thanks for your patience. Will close this.