embroider-build / embroider

Compiling Ember apps into spec-compliant, modern Javascript.
MIT License
333 stars 136 forks source link

How do you debug the macros? #1040

Closed NullVoxPopuli closed 2 years ago

NullVoxPopuli commented 2 years ago

I was reading: https://github.com/embroider-build/embroider/blob/master/CONTRIBUTING.md and I had tried:

JOBS=1 NODE_OPTIONS="--inspect-brk" ember s

with a debugger in the dependency-satisifies file (in node modules, js, compiled), but it seems babel ran in another thread.

How do you debug that part of that build?

ef4 commented 2 years ago

This is the right instructions, but probably you were hitting the persistent babel cache so the code was not being run.

You can rm -rf $TMPDIR/embroider first to eliminate the cache.

NullVoxPopuli commented 2 years ago

Trying to get a debugger going now to see what's going on with: https://github.com/embroider-build/embroider/issues/1066 but,

using:

 rm -rf /tmp/embroider/ && JOBS=1 NODE_OPTIONS="--inspect-brk" ember s

even though nothing is running on this port before I run the command, I get this error upon starting:

Starting inspector on 127.0.0.1:9229 failed: address already in use

so... trying with

❯ rm -rf /tmp/embroider/ && JOBS=1 NODE_OPTIONS="--inspect-brk=0.0.0.0:9000" ember s

still gets a similar error:

Starting inspector on 0.0.0.0:9000 failed: address already in use

So, I think JOBS=1 maybe is insufficient?

maybe there is another way to single-thread or maybe a way to spawn multiple debuggers?

ef4 commented 2 years ago

If you debug with vscode this is all very automatic. The instructions I use are:

  1. Launch a "Javascript debug terminal".
  2. Run "ember s" in that terminal.

That's it. It doesn't even need JOBS because it follows child processes correctly.

NullVoxPopuli commented 2 years ago

that sounds awesome and easy and I wish neovim had something that did that -- I may use that for all ember debugging if I can get this working.

I'm still somehow unable to hit my breakpoints in dependency-satisfies.js :thinking:

Anything look out of the ordinary to you? (I deleted /tmp/embroider first) image

ef4 commented 2 years ago

That looks correct. Did you also remove the cache? That is still a potential blocker.

NullVoxPopuli commented 2 years ago

Did you also remove the cache?

at /tmp/embroider, yea :cry:

NullVoxPopuli commented 2 years ago

Got this to work on my personal machine with local ember, rather than the globally installed one. ../node_modules/.bin/ember

roomman commented 2 years ago

That's it. It doesn't even need JOBS because it follows child processes correctly.

How I wish this statement was true. Spent the day trying to get a breakpoint to bind in VSCode, to try ascertain why @ember/render-modifiers is causing glimmer to throwing Error: Invalid modifier manager compatibility specified... again! 2022 has not been kind so far 🤣

I've tried ember s and ./node_modules/ember-cli/bin/ember s in a Javascript debug terminal, several variations of launch and attach configurations, dredged up from forums and none of it works for me.

@NullVoxPopuli can you share your setup for this please?

ef4 commented 2 years ago

Nine times out of ten, when people have a problem with dependencySatisfies it's because dependencySatisfies is faithfully reporting that NPM or yarn have given them an invalid node_modules structure.

cd into the copy of render-modifiers that is failing and run node -e 'console.log(require.resolve("ember-source/package.json"))'. That will tell you which copy of ember-source, if any, render-modifiers is seeing.