(WIP) [Toolbox] Decouple the development environment #1181
Conversation
66acd9f
to
3904c88
Compare
const serveIndex = require("serve-index"); | ||
const express = require("express"); | ||
|
||
const toolbox = require("../node_modules/devtools-local-toolbox/index"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not just do require("devtools-local-toolbox")
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Help fix my duplicate account
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
that's a confusing aspect at the moment.
The reason for this is that devtools-local-toolbox
exports src/index.js
not index.js
This will be cleaned up in a subsequent PR, but it's not related to the console working per se. The issue here is that the toolbox does 2 things:
- It sets up a development environment - dev server and webpack config
- It has a web app for the landing page and establishing the connection
The development environment does not belong in the web app's webpack bundle so it's in its own index. I'll move it to a separate package after this is done.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I guess the main thing was referencing node_modules
directly though: you should be able to do require("devtools-local-toolbox/index")
right?
@@ -0,0 +1,20 @@ | |||
const _ = require("lodash"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think it's a little confusing for code and configs to share the same directory. I'm still getting my head around this new structure so I don't know what to propose yet, but ideally the top-level config
directory would just contain json files.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also when using lodash in node code, it generally makes more sense to call the variable itself lodash
, not _
, since it's much for informative to grep for a full word string like lodash
than it is to grep for a single character _
(especially with Node's ___filename
and __dirname
constants).
That said, most of what lodash does is covered by ES6+ these days, so that the only thing it's being used for in this code is covered by vanilla JS these days as Object.assign({}, envConfig, localConfig);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@Pomax I agree. I've advocated for limiting our use of lodash. I would suggest removing it from this file as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think config.js
in the top level would probably be fine.
I'm hesitant to move it into src
or bin
as those are different in my mind.
What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is src code so I don't see why src
wouldn't make sense?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm okay using ES6 where we can, but in this case, we do need a deep merge, so lodash.merge makes sense to me
3904c88
to
21e07d7
Compare
@@ -10,8 +10,12 @@ | |||
"url": "https://github.com/devtools-html/debugger.html/issues" | |||
}, | |||
"homepage": "https://github.com/devtools-html/debugger.html#readme", | |||
"engineStrict": true, | |||
"engines": { | |||
"node": ">=6.4.0" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
given the LTS status of 6.9, probably worth bumping this to >=6.9.0
3ef3466
to
35cad0e
Compare
35cad0e
to
8ce6d5f
Compare
Associated Issue: #1156
This is some preliminary work needed to get other tools to work with the local toolbox. This work came out of hacking on console.html while on the plane.
There are some high level pieces to look out for:
bin/dev-server
that uses the toolbox'sdev-server
configs
directorywebpack.config
that uses the toolbox's config.index.js
andclient/index.js
is tool agnostic. This includes the console passing in a dom element as root (not a react component).devtools-modules
needed for the consoleScreenshot