Reputation: 1893
I've followed Meteor Doc to register a plug-in package.
Created a plug-in file in the package/plugin/
folder
Added a debugger;
in that file.
ran $ meteor debug;
Problem: debugger;
directive is ignored. How to debug the plug-in file?
Thx!
plugin/compile-atscript.js
:
Plugin.registerSourceHandler(
'ats'
, function (compileStep) {
var source = compileStep.read().toString('utf8');
console.log('source: ' + source);
debugger;
console.log('compiled source: ' + source);
});
Upvotes: 3
Views: 281
Reputation: 156
On macOS
Set Environment variable
export TOOL_NODE_FLAGS="--inspect-brk"
List env vars
printenv
Run meteor
meteor
Debugger will be listening and will get attached to Chrome dev tools on opening the Chrome Browser.
Upvotes: 0
Reputation: 30889
The Meteor tool runs build plugins in-process, so you just need to run it under the debugger. On Linux and Mac OS X, the launcher script supports a TOOL_NODE_FLAGS variable that can be used to pass arguments to the Node.js runtime to enable debugging. See the instructions for debugging the Meteor tool, although these are geared toward use with a git checkout of Meteor. A hacky shortcut:
METEOR_INSTALLATION=~/.meteor/packages/meteor-tool/$(meteor --long-version | sed -ne 's/^meteor-tool@//p')/mt-$(meteor --arch) TOOL_NODE_FLAGS=$METEOR_INSTALLATION/dev_bundle/lib/node_modules/node-inspector/bin/node-debug.js $METEOR_INSTALLATION/meteor
(Note, using just meteor
on the last line may not work because when the default version of the Meteor tool executes the proper version for the app, the debugger would be started a second time.)
On Windows, support for TOOL_NODE_FLAGS was added to the launcher script in Meteor 1.4.4. If the app is using an older version of Meteor, one could manually edit the launcher script. The commands to start debugging would look like:
set METEOR_INSTALLATION=%LOCALAPPDATA%\.meteor\packages\meteor-tool\TOOL_VERSION\mt-os.windows.x86_32 set TOOL_NODE_FLAGS=%METEOR_INSTALLATION%\dev_bundle\lib\node_modules\node-inspector\bin\node-debug.js %METEOR_INSTALLATION%\meteor.bat
(Someone else is welcome to add copy-and-pasteable code to figure out the correct TOOL_VERSION!)
Upvotes: 1