-
-
Notifications
You must be signed in to change notification settings - Fork 5
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
[AT] - added Webpack build tools, ESLint, etc #78
Conversation
js/src/site-cards.js
Outdated
@@ -55,7 +55,7 @@ function createCard(site) { | |||
</button> | |||
<div class="dropdown-menu" aria-labelledby="dropdownMenuButton"> | |||
<a class="dropdown-item restartbtn" href="#">Restart</a> | |||
<a class="dropdown-item" onclick='electron.shell.showItemInFolder("` + site.approot + `")' href="#">Browse Local Files</a> | |||
<a class="dropdown-item browsebtn" data-app-root="` + site.approot + `" href="#">Browse Local Files</a> |
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.
kind of snuck this one in here. noticed another on-click fragment and it was pulled out to be consistent is all.
webpack.config.js
Outdated
] | ||
}, | ||
}; | ||
|
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.
Super simple webpack config. Basically states that we have an electron app, that's main entry point is ui.js, and we want all code to be transpiled into a single file called bundle.js that lives in /js/dist
The loader module will then run eslint on all .js files in the js/src directory.
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.
The code changes look OK, except that:
- bundle.js got committed - it needs to be excluded instead
- make clean needs to delete js/dist right?
As far as functionality, it seems to be broken rather dramatically:
- Add/Create site doesn't work at all any more.
- Stop doesn't work
- Browse local files doesn't work.
AFAICT the entire UI is nonfunctional.
Let me know if I'm completely crazy. But really, please do take each PR for a casual manual spin yourself before inviting review.
Oh, and I did see
WARNING in ./node_modules/cross-spawn/index.js
Module not found: Error: Can't resolve 'spawn-sync' in '/Users/rfay/go/src/github.com/drud/ddev-ui/node_modules/cross-spawn'
Not sure if that's an error or not.
.gitignore
Outdated
@@ -1,6 +1,6 @@ | |||
node_modules/ | |||
.DS_Store | |||
dist/ | |||
/dist/ |
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 doesn't catch js/dist does it? Don't we want that excluded?
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.
In fact, I see that js/dist/bundle.js got committed... It should be removed unless I misunderstand.
I haven't tested myself, but if base functionality is breaking then this further underscores the need to get our integration tests in place as soon as we get the first priorities of the v0.3 phase in place. Until that's the case, we need to do some basic tire kicking to ensure nothing bombs out. @andrew-c-tran Are you able to regenerate the errors that @rfay is noting with respect to the changes brought in by this PR? |
…ed webpack watch and hotreload/realtime linting moved dependencies to fit with webpack's strict modularization.
… src folders in JS) and updated references accordingly
…ebpack autolinting, updated make build.
Alright did some digging and regarding that warning @rfay , a dependency of a node module that is being used in the project (cross-spawn) is attempting to import/require a method (spawn-sync) that is missing from node <= v0.10. It's enclosed in a try/catch block, so the logic is that at runtime it will attempt to require the module, and if it's missing the call will fail and it will warn the end user. This works when being run inside of a javascript engine, but why it's warning is that webpack is just transpiling the files...it's not actually executing the try/catch logic and is warning us that that library is nowhere to be found (as it should not be in a modern node environment.) I then found an open PR for cross-spawn that would fix this warning by completely removing v0.10 support and thus removing the require check, and have asked the developer when they intend to merge (moxystudio/node-cross-spawn#83). Node 0.11 was released in march of 2013, and current LTS is v8.9, with edge being v9.4, so I think it's very safe to assume that all our build boxes won't be impacted by this change when the library is updated. Testing notes: To re-enable realtime linting, open webpack.config.js and remove the comment markers on lines 10 and 21. This will reenable linting as part of the webpack process and will cause |
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 almost ready to go. Let's simplify the Makefile so we're not being repetitive. While there, why don't we add targets for what we're normally doing (the short ddev-ui launch) so that it's done predictably. I'm thinking add an "npmstart" target that does the npm stuff that you need. Then a make clean npmstart
would be an easy testing technique. If you want me to make a commit with these changes to the Makefile I will.
Makefile
Outdated
@echo "Building $@" | ||
npm run build-linux | ||
|
||
darwin: npminstall | ||
npm run webpack |
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 should go in the npminstall target, doesn't make sense to duplicate it here. Let's rename npminstall to npmsetup and put both actions in there.
Sure, if you're in there already and can make those make file changes
easily then please do. I can get to it tomorrow but am away from a computer
right now
…On Jan 21, 2018 2:23 PM, "Randy Fay" ***@***.***> wrote:
***@***.**** requested changes on this pull request.
This is almost ready to go. Let's simplify the Makefile so we're not being
repetitive. While there, why don't we add targets for what we're normally
doing (the short ddev-ui launch) so that it's done predictably. I'm
thinking add an "npmstart" target that does the npm stuff that you need.
Then a make clean npmstart would be an easy testing technique. If you
want me to make a commit with these changes to the Makefile I will.
------------------------------
In Makefile
<#78 (comment)>:
> @echo "Building $@"
npm run build-linux
darwin: npminstall
+ npm run webpack
This should go in the npminstall target, doesn't make sense to duplicate
it here. Let's rename npminstall to npmsetup and put both actions in there.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#78 (review)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AIi5ayJ2sH6RL5MAimvUsC0yjPjNJG4Uks5tM6rmgaJpZM4RgL3l>
.
|
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 added the suggested update to the Makefile in ca43b81 - This simplifies it slightly. The clean target had to be fixed because it wasn't removing the right "dist", and there's a new npmstart target that can be used for local testing. make npmstart
does what needs to be done. make clean npmstart
will hit the clean target first and then do the npmstart-related activities.
The Problem/Issue/Bug:
DDEV-UI currently does not have any build tools or static code analysis.
How this PR Solves The Problem:
Added ESLint with AirBNB rules, added webpack watch and hotreload/realtime linting moved dependencies to fit with webpack's strict modularization.
Introducing webpack, we can now transpile code (ES6, JSX, SCSS, etc) as well as with hotrealoading/file monitoring, we can realtime lint our source code. ESLint was selected as a linter, and the Airbnb ruleset is used as they are both the most widely used and generally accepted as standard (https://hackernoon.com/what-javascript-code-style-is-the-most-popular-5a3f5bec1f6f)
Manual Testing Instructions:
You will need two terminal windows, both navigated to project root:
window 1
npm run webpack-reload
/dist/bundle.js
window 2
npm start
Automated Testing Overview:
This is completely transparent to tests and app functionality, so all tests should currently pass and no tests to directly test build tools are needed.
Related Issue Link(s):
#46
Release/Deployment notes:
No new build steps needed