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

is support debug when use with esbuild? #40

Closed
sonygod opened this issue Jul 4, 2020 · 19 comments
Closed

is support debug when use with esbuild? #40

sonygod opened this issue Jul 4, 2020 · 19 comments

Comments

@sonygod
Copy link

sonygod commented Jul 4, 2020

from your three.js example, it seems not to support debug in vs code.

what's wrong?

@haxiomic
Copy link
Owner

haxiomic commented Jul 4, 2020

Could you give an example for what you’re trying to do? Debugging works but if you’re running the code in a browser vscode has to connect to the browser and this needs setting up

https://www.google.co.uk/amp/s/www.freecodecamp.org/news/how-to-set-up-the-debugger-for-chrome-extension-in-visual-studio-code-c0b3e5937c01/amp/

@haxiomic
Copy link
Owner

haxiomic commented Jul 4, 2020

Or it’s it just sourcemapping?

@sonygod
Copy link
Author

sonygod commented Jul 4, 2020 via email

@haxiomic
Copy link
Owner

haxiomic commented Jul 4, 2020

I mean how are you trying to debug? Are you trying to debug using vscode's debugging tool? The code is executed in a browser, vscode cannot debug anything running in a browser unless it's been setup to do so

@sonygod
Copy link
Author

sonygod commented Jul 6, 2020

build.hxml

 --class-path src
-main Main

# externs are written to local library path '.haxelib'
-lib three
-lib gsap
-js bin/dist/main.js
-dce full
--debug
-D js-es=6
# thee.js from npm uses require(), so we must run a bundler after building haxe code
-cmd npx esbuild bin/dist/main.js --bundle --outfile=bin/dist/bundle.js

cd bin & anywehre

then

   {
    // Use IntelliSense to learn about possible attributes.
    // Hover to view descriptions of existing attributes.
    // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
    "version": "0.2.0",
    "configurations": [
        {
            "type": "chrome",
            "request": "launch",
            "name": "Launch Chrome against localhost",
            "url": "http://localhost:8000",
            "webRoot": "${workspaceFolder}"
        }
    ]
}

@haxiomic
Copy link
Owner

haxiomic commented Jul 6, 2020

Try adding source maps with --sourcemap so this line becomes
-cmd npx esbuild bin/dist/main.js --bundle --outfile=bin/dist/bundle.js

-cmd npx esbuild bin/dist/main.js --bundle --outfile=bin/dist/bundle.js --sourcemap

@sonygod
Copy link
Author

sonygod commented Jul 7, 2020

still not work ,after add --sourcemap ,and generate bundle.js.map

BTW,is possible without esbuild? I don't want embed js engine to my app. and use some of cdn three.js version and share with

other app

@haxiomic
Copy link
Owner

haxiomic commented Jul 7, 2020

It's possible without esbuild – use the types the package in global.three instead and then you can use three.js via a <script> tag

@sonygod
Copy link
Author

sonygod commented Jul 7, 2020

after use global.three.* replace three.*;

I got this error:

ArrayIterator.hx:53 Uncaught ReferenceError: require is not defined
at ArrayIterator.hx:53
at ArrayIterator.hx:53

image

image

@haxiomic
Copy link
Owner

haxiomic commented Jul 7, 2020

That implies not all three types are coming from three.*, double check you haven't missed any

Feel free to zip the project and post here and I'll check too

@sonygod
Copy link
Author

sonygod commented Dec 1, 2021

three.zip

@haxiomic ,will you take a look?

@haxiomic
Copy link
Owner

haxiomic commented Dec 2, 2021

Hey :) – so there's currently a bug in esbuild where the haxe generated paths break when they get copied into esbuild

evanw/esbuild#1745

Likely not too complex to fix but I need to learn some Go lang first :P

@sonygod
Copy link
Author

sonygod commented Dec 3, 2021

can't wait you fixed this bug as soon as possible.

@haxiomic
Copy link
Owner

haxiomic commented Dec 3, 2021

It’s not something I need in the short term and I’m unlikely to fix with my current work load

I’d recommend exploring how to fix in esbuild (or the haxe compiler by avoiding the file:/// paths)

you can make it work manually by replacing file:/ with file:/// in the generate .map file

@sonygod
Copy link
Author

sonygod commented Dec 8, 2021

you mean repacing file:/ in main.js.map or bundle.js.map

in main.js ,it's already gen file:///

I re-add file:/// to bundle.js.map still does not work.

@haxiomic

@haxiomic
Copy link
Owner

haxiomic commented Dec 8, 2021

When you compile with -debug, in bundle.js.map you'll see a "sources" field with paths like file:/Users..., which if you replace file:/ with file:/// it should work. I'm only testing on mac so maybe it's different on windows

It would probably be best simpler to fix in esbuild however

@sonygod
Copy link
Author

sonygod commented Dec 14, 2021

but I still can't debug jump into *.hx file, only debug in main.js .

current bundle.js.map sources field have no 'file:/' or something else like ..

{
  "version": 3,
  "sources": ["node_modules\\three\\build\\three.js", "node_modules\\poly2tri\\dist\\version.json", "node_modules\\poly2tri\\src\\xy.js", "node_modules\\poly2tri\\src\\pointerror.js", "node_modules\\poly2tri\\src\\point.js", "node_modules\\poly2tri\\src\\triangle.js", "node_modules\\poly2tri\\src\\assert.js", "node_modules\\poly2tri\\src\\advancingfront.js", "node_modules\\poly2tri\\src\\utils.js", "node_modules\\poly2tri\\src\\sweep.js", "node_modules\\poly2tri\\src\\sweepcontext.js", "node_modules\\poly2tri\\src\\poly2tri.js", "node_modules\\three\\build\\three.module.js", "node_modules\\three\\examples\\jsm\\exporters\\GLTFExporter.js", "node_modules\\three\\examples\\jsm\\lines\\LineSegmentsGeometry.js", "node_modules\\three\\examples\\jsm\\lines\\LineMaterial.js", "node_modules\\three\\examples\\jsm\\lines\\LineSegments2.js", "node_modules\\three\\examples\\jsm\\lines\\LineGeometry.js", "node_modules\\three\\examples\\jsm\\lines\\Line2.js", "dist\\main.js"],

I try to readd file://mypath still not work.

dist.zip

@haxiomic

@sonygod
Copy link
Author

sonygod commented Dec 14, 2021

finally,I found the reason why doesn't work, I have to update esbuild to the last version . in your example,your esbuild version is too old to use .

  "devDependencies": {
    "esbuild": "^0.14.3",
    "dts2hx": "*"
  },

thanks agin.

@sonygod
Copy link
Author

sonygod commented Dec 14, 2021

three_fixeddebug.zip

may help somebody else

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

2 participants