A few good JavaScript development tools

Simon Kim
Simon Kimdoesn't matter
A Few Good JavaScript
Development Tools
Jul. 12 2016 Simon Kim
NexStreaming Corp.
Agenda
ECMAScript 6 - JavaScript Languages
Visual Studio Code - Editors or IDE
Node.js & npm - All Time Friends
webpack, Babel, UglifyJS - Build
Jasmine - Testing
Chrome Developer Tools - Debugging
YUIDoc - Documentation
Agenda
ECMAScript 6 - JavaScript Languages
Visual Studio Code - Editors or IDE
Node.js & npm - All Time Friends
webpack, Babel, UglifyJS - Build
Jasmine - Testing
Chrome Developer Tools - Debugging
YUIDoc - Documentation
Code
Build
Test
Debug
Document
Demo Project: https://github.com/simonkim/jstools-demo
JavaScript Language
ECMA-262 Specification
First Edition - June 1997
...
ECMAScript 5.1 Edition - June 2011
ECMAScript 6th Edition (ECMAScript 2015) - June 2015
ES6, ES2015
Misc.
CoffeeScript - http://coffeescript.org
JavaScript Language - ECMAScript 6
// ECMAScript 5
var Shape = function (id, x, y) {
this.id = id;
this.move(x, y);
};
Shape.prototype.move = function (x, y) {
this.x = x;
this.y = y;
};
// ECMAScript 6
class Shape {
constructor (id, x, y) {
this.id = id
this.move(x, y)
}
move (x, y) {
this.x = x
this.y = y
}
}
See http://es6-features.org for Details
Editors or IDEs
IDEs
WebStrom - JetBrains https://www.jetbrains.com/webstorm/ - $$$
Eclips IDE for JavaScript Web Developers - https://eclips.org - $$$
Aptana Studio 3 - http://www.aptana.com - $$$
Editors
Sublime Text - http://www.sublimetext.com - $
Atom - https://atom.io
Visual Studio Code - https://code.visualstudio.com/
Visual Studio Code
Node.js & npm
Node.js - https://nodejs.org/
JavaScript Runtime Built on Chrome’s V8 JavaScript Engine
Event Driven
Non-Blocking IO Model
npm - https://www.npmjs.com
Package Manager for JavaScript
Share and Reuse Node.js Modules
$ npm install express
# To publish
$ npm login
$ npm publish
npm - Example Node.js Module
See Using a package.json for Details
// package.json
{
"name": "mymodule",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo "Error: no test specified"
&& exit 1",
},
"author": "",
"license": "ISC"
}
// index.js
function Mymodule() {
}
Mymodule.prototype.hello = function() {
console.log(“Hello, Node.js module”);
}
module.exports = Mymodule;
// sample.js
Mymodule = require(‘./index’);
var mymodule = new MyModule();
mymodule.hello();
// Hello, Node.js module
Build
JavaScript is Interpreter Language, Why Build?
Bundle Multiple Modules into Single .JS File
<script src=”app.bundle.js” />
Transpile
Write in ES6, CoffeeScript, or TypeScript
Run Browser Compatible Version of JavaScript
Minimization and Obfuscation
The Smaller, The Faster Loading
Hard to Read Source
Build
GRUNT - http://gruntjs.com
A JavaScript task runner for automation configured in Gruntfile
gulp.js - http://gulpjs.com
Streaming build system runs tasks defined in gulpfile.js
Browserify - http://browserify.org
Bundle node modules to allow running in browsers
webpack - https://webpack.github.io
A module bundler: takes modules with dependencies and generates static assets
Build - webpack
Build - webpack
$ npm install webpack -g
$ webpack ./app.js app.bundle.js
http://webpack.github.io/docs/usage.html
Build - JavaScript in Web Browser
<body>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jque
ry.min.js"></script>
<div id="content">
<textarea id="input" rows=4 cols=80></textarea>
<button id="convert">Submit</button>
<p id="output"></p>
</div>
<script type="text/javascript">
$('#convert').click(function(e) {
var text = $('#input').val();
$( '#output' ).html( '<p>' + text + '</p>' );
});
</script>
</body>
Sample: https://jsfiddle.net/yd2517e4/
// webpack.config.js
module.exports = {
output.library: “Hlsm3u8”
}
Build - Node Module in Web Browser
<body>
<script
src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jque
ry.min.js"></script>
<script src="scripts/app.bundle.js"></script>
<div id="content">
<textarea id="input" rows=4 cols=80></textarea>
<button id="convert">Submit</button>
<p id="output"></p>
</div>
<script type="text/javascript">
$('#convert').click(function(e) {
var text = $('#input').val();
var hlsm3u8 = new Hlsm3u8();
text = hlsm3u8.parse(text);
$( '#output' ).html( '<p>' + text + '</p>' );
});
</script>
</body>
‘output.library’ option of ‘webpack’
enables access to node module
exports from browser code
Build - Transpile
CoffeeScript - http://coffeescript.org
TypeScript - https://www.typescriptlang.org
Babel - https://babeljs.io
A JavaScript Compiler
ECPAScript 2015 ( ES6 ) to Browser Compatible JavaScript (? TBC)
// output.js
'use strict';
var _createClass = function () { //... }();
function _classCallCheck(instance, Constructor) { //... }
var Sample = function () {
function Sample(text) {
_classCallCheck(this, Sample);
this.text = text;
}
_createClass(Sample, [{
key: 'printHello',
value: function printHello() {
console.log('hello ' + this.text);
}
}]);
return Sample;
}();
var sample = new Sample('Babel');
sample.printHello();
Babel - Example
// sample.js
class Sample {
constructor(text) { this.text = text; }
printHello() { console.log(`hello ${this.text}`); }
}
var sample = new Sample('Babel');
sample.printHello();
// .babelrc
{
presets: [“es2015”]
}
# Install babel and transpile
$ npm install --save-dev babel-cli babel-preset-
es2015
$ ./node_modules/.bin/babel sample.js >
output.js
Build - Babel with webpack
Install Node Modules
$ npm install --save-dev babel-loader babel-core
Configure webpack
// webpack.config.js
module: {
loaders: [
{ test: /.js$/, exclude: /node_modules/, loader:
"babel-loader" }
]
}
Configure Babel: .babelrc
{
"presets": ["es2015"]
}
See https://babeljs.io/docs/setup/#installation for
Details
Build - Minimization and Obfuscation
minifier - https://www.npmjs.com/package/minifier
YUI Compressor - http://yui.github.io/yuicompressor/
UglifyJS2 - https://github.com/mishoo/UglifyJS2
Build - UglifyJS2 Example
# Install UglifyJS2
$ npm install uglify-js -g
$ uglifyjs input.js --compress --mangle -o
ouput.js
// output.js
"use strict";function _classCallCheck(e,n){if(!(e instanceof n))throw new
TypeError("Cannot call a class as a function")}var
_createClass=function(){function e(e,n){for(var t=0;t<n.length;t++){var
l=n[t];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in
l&&(l.writable=!0),Object.defineProperty(e,l.key,l)}}return
function(n,t,l){return
t&&e(n.prototype,t),l&&e(n,l),n}}(),Sample=function(){function
e(n){_classCallCheck(this,e),this.text=n}return
_createClass(e,[{key:"printHello",value:function(){console.log("hello
"+this.text)}}]),e}(),sample=new Sample("Babel");sample.printHello();
// input.js
'use strict';
var _createClass = function () { //... }();
function _classCallCheck(instance, Constructor) { //... }
var Sample = function () {
function Sample(text) {
_classCallCheck(this, Sample);
this.text = text;
}
_createClass(Sample, [{
key: 'printHello',
value: function printHello() {
console.log('hello ' + this.text);
}
}]);
return Sample;
}();
var sample = new Sample('Babel');
sample.printHello();
Build - UglifyJS with webpack
webpack UglifyJSPlugin
http://webpack.github.io/docs/list-of-
plugins.html#uglifyjsplugin
$ npm install webpack --save-dev
// webpack.config.js
module.exports = {
...
plugins:[new webpack.optimize.UglifyJsPlugin({
compress: {warnings: false},
})]
…
}
$ webpack
Testing
Jasmine - http://jasmine.github.io
“Jasmine is a behavior-driven development framework for testing JavaScript code.”
Karma - https://karma-runner.github.io/
Test Runner. Unit Testing.
And Many Others.
Testing - Jasmine
Install ‘jasmine’ command
$ npm install -g jasmine
Create jasmine.json, default
configuration
$ jasmine init
Write test cases, jasmine specs, and
run
$ jasmine
// myappSpec.js
describe("A suite", function() {
it("contains spec with an expectation",
function() {
expect(true).toBe(true);
});
it("The 'toBeLessThan' matcher is for
mathematical comparisons", function() {
var pi = 3.1415926,
e = 2.78;
expect(e).toBeLessThan(pi);
expect(pi).not.toBeLessThan(e);
});
});
Running Tests in a Browser
In HTML, include source and spec files and jasmine files
Open the HTML File in Browser
Testing - Jasmine
<link rel="shortcut icon" type="image/png"
href="lib/jasmine-2.4.1/jasmine_favicon.png">
<link rel="stylesheet" href="lib/jasmine-
2.4.1/jasmine.css">
<script src="lib/jasmine-
2.4.1/jasmine.js"></script>
<script src="lib/jasmine-2.4.1/jasmine-
html.js"></script>
<script src="lib/jasmine-
2.4.1/boot.js"></script>
<!-- include source files here... -->
<script
src="../public/dist/hlsm3u8.js"></script>
<!-- include spec files here... -->
<script
src="../spec/hlsm3u8spec.js"></script>
Chrome Developer Tools - https://developers.google.com/web/tools/chrome-devtools/
Chrome -> Menu -> View -> Developers -> Developer Tools
Source Map
Maps combined/minified file back to an unbuilt state
Debugging
Debugging - Chrome Developer Tools
Debugging - Source Map
Without Source Map
Debugging - Source Map
With Source Map
Debugging - Source Map
Introduction to JavaScript Source Map
Generating Source Map with webpack Build
$ webpack -d
app.bundle.js
app.bundle.js.map
See Development shortcut -d and devtool Webpack configuration for Details
Chrome DevTools Locates Source Map (.map) in the Same Path of .JS
Documentation
JSDoc - http://usejsdoc.org
Docco - https://jashkenas.github.io/docco/
YUIDoc - http://yui.github.io/yuidoc/
Documentation - YUIDoc
# Install babel and transpile
$ npm install -g yuidocjs
$ yuidoc .
$ # open out/index.html in browser
Summary
Code BuildTestDebug Document
+ Source Map
Demo Project:
https://github.com/simonkim/jstools-demo
1 of 32

Recommended

Groovy Ecosystem - JFokus 2011 - Guillaume Laforge by
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGroovy Ecosystem - JFokus 2011 - Guillaume Laforge
Groovy Ecosystem - JFokus 2011 - Guillaume LaforgeGuillaume Laforge
3.6K views62 slides
Agile JavaScript Testing by
Agile JavaScript TestingAgile JavaScript Testing
Agile JavaScript TestingScott Becker
6.2K views48 slides
System webpack-jspm by
System webpack-jspmSystem webpack-jspm
System webpack-jspmJesse Warden
9.2K views45 slides
From Hacker to Programmer (w/ Webpack, Babel and React) by
From Hacker to Programmer (w/ Webpack, Babel and React)From Hacker to Programmer (w/ Webpack, Babel and React)
From Hacker to Programmer (w/ Webpack, Babel and React)Joseph Chiang
4K views54 slides
The JavaFX Ecosystem by
The JavaFX EcosystemThe JavaFX Ecosystem
The JavaFX EcosystemAndres Almiray
3.8K views37 slides
Javascript Test Automation Workshop (21.08.2014) by
Javascript Test Automation Workshop (21.08.2014)Javascript Test Automation Workshop (21.08.2014)
Javascript Test Automation Workshop (21.08.2014)Deutsche Post
2.2K views18 slides

More Related Content

What's hot

Testing frontends with nightwatch & saucelabs by
Testing frontends with nightwatch & saucelabsTesting frontends with nightwatch & saucelabs
Testing frontends with nightwatch & saucelabsTudor Barbu
1.4K views22 slides
Django for mobile applications by
Django for mobile applicationsDjango for mobile applications
Django for mobile applicationsHassan Abid
8.9K views57 slides
Single Page Web Applications with CoffeeScript, Backbone and Jasmine by
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and JasminePaulo Ragonha
24.6K views147 slides
20160905 - BrisJS - nightwatch testing by
20160905 - BrisJS - nightwatch testing20160905 - BrisJS - nightwatch testing
20160905 - BrisJS - nightwatch testingVladimir Roudakov
756 views52 slides
React Native in Production by
React Native in ProductionReact Native in Production
React Native in ProductionSeokjun Kim
1.4K views49 slides
Роман Лютиков "Web Apps Performance & JavaScript Compilers" by
Роман Лютиков "Web Apps Performance & JavaScript Compilers"Роман Лютиков "Web Apps Performance & JavaScript Compilers"
Роман Лютиков "Web Apps Performance & JavaScript Compilers"Fwdays
367 views37 slides

What's hot(20)

Testing frontends with nightwatch & saucelabs by Tudor Barbu
Testing frontends with nightwatch & saucelabsTesting frontends with nightwatch & saucelabs
Testing frontends with nightwatch & saucelabs
Tudor Barbu1.4K views
Django for mobile applications by Hassan Abid
Django for mobile applicationsDjango for mobile applications
Django for mobile applications
Hassan Abid8.9K views
Single Page Web Applications with CoffeeScript, Backbone and Jasmine by Paulo Ragonha
Single Page Web Applications with CoffeeScript, Backbone and JasmineSingle Page Web Applications with CoffeeScript, Backbone and Jasmine
Single Page Web Applications with CoffeeScript, Backbone and Jasmine
Paulo Ragonha24.6K views
React Native in Production by Seokjun Kim
React Native in ProductionReact Native in Production
React Native in Production
Seokjun Kim1.4K views
Роман Лютиков "Web Apps Performance & JavaScript Compilers" by Fwdays
Роман Лютиков "Web Apps Performance & JavaScript Compilers"Роман Лютиков "Web Apps Performance & JavaScript Compilers"
Роман Лютиков "Web Apps Performance & JavaScript Compilers"
Fwdays367 views
JavaFX – 10 things I love about you by Alexander Casall
JavaFX – 10 things I love about youJavaFX – 10 things I love about you
JavaFX – 10 things I love about you
Alexander Casall7.5K views
Metaprogramming 101 by Nando Vieira
Metaprogramming 101Metaprogramming 101
Metaprogramming 101
Nando Vieira1.7K views
Building a Startup Stack with AngularJS by FITC
Building a Startup Stack with AngularJSBuilding a Startup Stack with AngularJS
Building a Startup Stack with AngularJS
FITC32K views
The DOM is a Mess @ Yahoo by jeresig
The DOM is a Mess @ YahooThe DOM is a Mess @ Yahoo
The DOM is a Mess @ Yahoo
jeresig50.6K views
JavaOne - The JavaFX Community and Ecosystem by Alexander Casall
JavaOne - The JavaFX Community and EcosystemJavaOne - The JavaFX Community and Ecosystem
JavaOne - The JavaFX Community and Ecosystem
Alexander Casall1.7K views
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp by Matthew Davis
Optimising Your Front End Workflow With Symfony, Twig, Bower and GulpOptimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Optimising Your Front End Workflow With Symfony, Twig, Bower and Gulp
Matthew Davis52.6K views
Testing JS with Jasmine by Evgeny Gurin
Testing JS with JasmineTesting JS with Jasmine
Testing JS with Jasmine
Evgeny Gurin1.7K views
JavaScript Test-Driven Development with Jasmine 2.0 and Karma by Christopher Bartling
JavaScript Test-Driven Development with Jasmine 2.0 and Karma JavaScript Test-Driven Development with Jasmine 2.0 and Karma
JavaScript Test-Driven Development with Jasmine 2.0 and Karma

Viewers also liked

UglifyJS 使用文档 by
UglifyJS 使用文档UglifyJS 使用文档
UglifyJS 使用文档明 李
457 views10 slides
Debugging Javascript by
Debugging JavascriptDebugging Javascript
Debugging JavascriptSolTech, Inc.
998 views33 slides
Debugging tools in web browsers by
Debugging tools in web browsersDebugging tools in web browsers
Debugging tools in web browsersSarah Dutkiewicz
2.1K views15 slides
Debugging JavaScript (by Thomas Bindzus, Founder, Vinagility & Thanh Loc Vo, ... by
Debugging JavaScript (by Thomas Bindzus, Founder, Vinagility & Thanh Loc Vo, ...Debugging JavaScript (by Thomas Bindzus, Founder, Vinagility & Thanh Loc Vo, ...
Debugging JavaScript (by Thomas Bindzus, Founder, Vinagility & Thanh Loc Vo, ...JavaScript Meetup HCMC
1.7K views26 slides
FITC - Here Be Dragons: Advanced JavaScript Debugging by
FITC - Here Be Dragons: Advanced JavaScript DebuggingFITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript DebuggingRami Sayar
1.1K views40 slides
Tools and Techniques for Faster Development by
Tools and Techniques for Faster DevelopmentTools and Techniques for Faster Development
Tools and Techniques for Faster Developmentjtaby
17K views116 slides

Viewers also liked(7)

UglifyJS 使用文档 by 明 李
UglifyJS 使用文档UglifyJS 使用文档
UglifyJS 使用文档
明 李457 views
Debugging JavaScript (by Thomas Bindzus, Founder, Vinagility & Thanh Loc Vo, ... by JavaScript Meetup HCMC
Debugging JavaScript (by Thomas Bindzus, Founder, Vinagility & Thanh Loc Vo, ...Debugging JavaScript (by Thomas Bindzus, Founder, Vinagility & Thanh Loc Vo, ...
Debugging JavaScript (by Thomas Bindzus, Founder, Vinagility & Thanh Loc Vo, ...
FITC - Here Be Dragons: Advanced JavaScript Debugging by Rami Sayar
FITC - Here Be Dragons: Advanced JavaScript DebuggingFITC - Here Be Dragons: Advanced JavaScript Debugging
FITC - Here Be Dragons: Advanced JavaScript Debugging
Rami Sayar1.1K views
Tools and Techniques for Faster Development by jtaby
Tools and Techniques for Faster DevelopmentTools and Techniques for Faster Development
Tools and Techniques for Faster Development
jtaby17K views
Finding and debugging memory leaks in JavaScript with Chrome DevTools by Gonzalo Ruiz de Villa
Finding and debugging memory leaks in JavaScript with Chrome DevToolsFinding and debugging memory leaks in JavaScript with Chrome DevTools
Finding and debugging memory leaks in JavaScript with Chrome DevTools
Gonzalo Ruiz de Villa30.1K views

Similar to A few good JavaScript development tools

Xopus Application Framework by
Xopus Application FrameworkXopus Application Framework
Xopus Application FrameworkJady Yang
753 views27 slides
Angular JS in 2017 by
Angular JS in 2017Angular JS in 2017
Angular JS in 2017Ayush Sharma
132 views56 slides
Lecture: Webpack 4 by
Lecture: Webpack 4Lecture: Webpack 4
Lecture: Webpack 4Sergei Iastrebov
216 views39 slides
Symfony Live 2018 - Développez votre frontend avec ReactJS et Symfony Webpack... by
Symfony Live 2018 - Développez votre frontend avec ReactJS et Symfony Webpack...Symfony Live 2018 - Développez votre frontend avec ReactJS et Symfony Webpack...
Symfony Live 2018 - Développez votre frontend avec ReactJS et Symfony Webpack...Alain Hippolyte
1.4K views93 slides
Webpack Encore - Asset Management for the rest of us by
Webpack Encore - Asset Management for the rest of usWebpack Encore - Asset Management for the rest of us
Webpack Encore - Asset Management for the rest of usStefan Adolf
1.4K views36 slides
Npm scripts by
Npm scriptsNpm scripts
Npm scripts정윤 김
1.5K views71 slides

Similar to A few good JavaScript development tools(20)

Xopus Application Framework by Jady Yang
Xopus Application FrameworkXopus Application Framework
Xopus Application Framework
Jady Yang753 views
Symfony Live 2018 - Développez votre frontend avec ReactJS et Symfony Webpack... by Alain Hippolyte
Symfony Live 2018 - Développez votre frontend avec ReactJS et Symfony Webpack...Symfony Live 2018 - Développez votre frontend avec ReactJS et Symfony Webpack...
Symfony Live 2018 - Développez votre frontend avec ReactJS et Symfony Webpack...
Alain Hippolyte1.4K views
Webpack Encore - Asset Management for the rest of us by Stefan Adolf
Webpack Encore - Asset Management for the rest of usWebpack Encore - Asset Management for the rest of us
Webpack Encore - Asset Management for the rest of us
Stefan Adolf1.4K views
Npm scripts by 정윤 김
Npm scriptsNpm scripts
Npm scripts
정윤 김1.5K views
Webpack Encore Symfony Live 2017 San Francisco by Ryan Weaver
Webpack Encore Symfony Live 2017 San FranciscoWebpack Encore Symfony Live 2017 San Francisco
Webpack Encore Symfony Live 2017 San Francisco
Ryan Weaver2.8K views
(2018) Webpack Encore - Asset Management for the rest of us by Stefan Adolf
(2018) Webpack Encore - Asset Management for the rest of us(2018) Webpack Encore - Asset Management for the rest of us
(2018) Webpack Encore - Asset Management for the rest of us
Stefan Adolf1.1K views
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C... by Ryan Weaver
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Finally, Professional Frontend Dev with ReactJS, WebPack & Symfony (Symfony C...
Ryan Weaver13.7K views
[Strukelj] Why will Java 7.0 be so cool by javablend
[Strukelj] Why will Java 7.0 be so cool[Strukelj] Why will Java 7.0 be so cool
[Strukelj] Why will Java 7.0 be so cool
javablend484 views
May The Nodejs Be With You by Dalibor Gogic
May The Nodejs Be With YouMay The Nodejs Be With You
May The Nodejs Be With You
Dalibor Gogic451 views
Node.js vs Play Framework (with Japanese subtitles) by Yevgeniy Brikman
Node.js vs Play Framework (with Japanese subtitles)Node.js vs Play Framework (with Japanese subtitles)
Node.js vs Play Framework (with Japanese subtitles)
Yevgeniy Brikman42.5K views
HTML5 for the Silverlight Guy by David Padbury
HTML5 for the Silverlight GuyHTML5 for the Silverlight Guy
HTML5 for the Silverlight Guy
David Padbury2.5K views
Javascript unit testing, yes we can e big by Andy Peterson
Javascript unit testing, yes we can   e bigJavascript unit testing, yes we can   e big
Javascript unit testing, yes we can e big
Andy Peterson1.1K views
Code Splitting in Practice - Shanghai JS Meetup May 2016 by Wiredcraft
Code Splitting in Practice - Shanghai JS Meetup May 2016Code Splitting in Practice - Shanghai JS Meetup May 2016
Code Splitting in Practice - Shanghai JS Meetup May 2016
Wiredcraft142 views
Workflow para desenvolvimento Web & Mobile usando grunt.js by Davidson Fellipe
Workflow para desenvolvimento Web & Mobile usando grunt.jsWorkflow para desenvolvimento Web & Mobile usando grunt.js
Workflow para desenvolvimento Web & Mobile usando grunt.js
Davidson Fellipe3K views
Intro to ES6 and why should you bother ! by Gaurav Behere
Intro to ES6 and why should you bother !Intro to ES6 and why should you bother !
Intro to ES6 and why should you bother !
Gaurav Behere550 views
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ... by Jesse Gallagher
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
CollabSphere 2021 - DEV114 - The Nuts and Bolts of CI/CD With a Large XPages ...
Jesse Gallagher973 views
How to replace rails asset pipeline with webpack? by Tomasz Bak
How to replace rails asset pipeline with webpack?How to replace rails asset pipeline with webpack?
How to replace rails asset pipeline with webpack?
Tomasz Bak1.6K views

Recently uploaded

Informed search algorithms.pptx by
Informed search algorithms.pptxInformed search algorithms.pptx
Informed search algorithms.pptxDr.Shweta
16 views19 slides
Saikat Chakraborty Java Oracle Certificate.pdf by
Saikat Chakraborty Java Oracle Certificate.pdfSaikat Chakraborty Java Oracle Certificate.pdf
Saikat Chakraborty Java Oracle Certificate.pdfSaikatChakraborty787148
15 views1 slide
802.11 Computer Networks by
802.11 Computer Networks802.11 Computer Networks
802.11 Computer NetworksTusharChoudhary72015
9 views33 slides
STUDY OF SMART MATERIALS USED IN CONSTRUCTION-1.pptx by
STUDY OF SMART MATERIALS USED IN CONSTRUCTION-1.pptxSTUDY OF SMART MATERIALS USED IN CONSTRUCTION-1.pptx
STUDY OF SMART MATERIALS USED IN CONSTRUCTION-1.pptxAnnieRachelJohn
33 views34 slides
DESIGN OF SPRINGS-UNIT4.pptx by
DESIGN OF SPRINGS-UNIT4.pptxDESIGN OF SPRINGS-UNIT4.pptx
DESIGN OF SPRINGS-UNIT4.pptxgopinathcreddy
18 views47 slides
Literature review and Case study on Commercial Complex in Nepal, Durbar mall,... by
Literature review and Case study on Commercial Complex in Nepal, Durbar mall,...Literature review and Case study on Commercial Complex in Nepal, Durbar mall,...
Literature review and Case study on Commercial Complex in Nepal, Durbar mall,...AakashShakya12
63 views115 slides

Recently uploaded(20)

Informed search algorithms.pptx by Dr.Shweta
Informed search algorithms.pptxInformed search algorithms.pptx
Informed search algorithms.pptx
Dr.Shweta16 views
STUDY OF SMART MATERIALS USED IN CONSTRUCTION-1.pptx by AnnieRachelJohn
STUDY OF SMART MATERIALS USED IN CONSTRUCTION-1.pptxSTUDY OF SMART MATERIALS USED IN CONSTRUCTION-1.pptx
STUDY OF SMART MATERIALS USED IN CONSTRUCTION-1.pptx
AnnieRachelJohn33 views
Literature review and Case study on Commercial Complex in Nepal, Durbar mall,... by AakashShakya12
Literature review and Case study on Commercial Complex in Nepal, Durbar mall,...Literature review and Case study on Commercial Complex in Nepal, Durbar mall,...
Literature review and Case study on Commercial Complex in Nepal, Durbar mall,...
AakashShakya1263 views
How I learned to stop worrying and love the dark silicon apocalypse.pdf by Tomasz Kowalczewski
How I learned to stop worrying and love the dark silicon apocalypse.pdfHow I learned to stop worrying and love the dark silicon apocalypse.pdf
How I learned to stop worrying and love the dark silicon apocalypse.pdf
Effect of deep chemical mixing columns on properties of surrounding soft clay... by AltinKaradagli
Effect of deep chemical mixing columns on properties of surrounding soft clay...Effect of deep chemical mixing columns on properties of surrounding soft clay...
Effect of deep chemical mixing columns on properties of surrounding soft clay...
AltinKaradagli6 views
Multi-objective distributed generation integration in radial distribution sy... by IJECEIAES
Multi-objective distributed generation integration in radial  distribution sy...Multi-objective distributed generation integration in radial  distribution sy...
Multi-objective distributed generation integration in radial distribution sy...
IJECEIAES15 views
What is Whirling Hygrometer.pdf by IIT KHARAGPUR
What is Whirling Hygrometer.pdfWhat is Whirling Hygrometer.pdf
What is Whirling Hygrometer.pdf
IIT KHARAGPUR 11 views

A few good JavaScript development tools

  • 1. A Few Good JavaScript Development Tools Jul. 12 2016 Simon Kim NexStreaming Corp.
  • 2. Agenda ECMAScript 6 - JavaScript Languages Visual Studio Code - Editors or IDE Node.js & npm - All Time Friends webpack, Babel, UglifyJS - Build Jasmine - Testing Chrome Developer Tools - Debugging YUIDoc - Documentation
  • 3. Agenda ECMAScript 6 - JavaScript Languages Visual Studio Code - Editors or IDE Node.js & npm - All Time Friends webpack, Babel, UglifyJS - Build Jasmine - Testing Chrome Developer Tools - Debugging YUIDoc - Documentation Code Build Test Debug Document Demo Project: https://github.com/simonkim/jstools-demo
  • 4. JavaScript Language ECMA-262 Specification First Edition - June 1997 ... ECMAScript 5.1 Edition - June 2011 ECMAScript 6th Edition (ECMAScript 2015) - June 2015 ES6, ES2015 Misc. CoffeeScript - http://coffeescript.org
  • 5. JavaScript Language - ECMAScript 6 // ECMAScript 5 var Shape = function (id, x, y) { this.id = id; this.move(x, y); }; Shape.prototype.move = function (x, y) { this.x = x; this.y = y; }; // ECMAScript 6 class Shape { constructor (id, x, y) { this.id = id this.move(x, y) } move (x, y) { this.x = x this.y = y } } See http://es6-features.org for Details
  • 6. Editors or IDEs IDEs WebStrom - JetBrains https://www.jetbrains.com/webstorm/ - $$$ Eclips IDE for JavaScript Web Developers - https://eclips.org - $$$ Aptana Studio 3 - http://www.aptana.com - $$$ Editors Sublime Text - http://www.sublimetext.com - $ Atom - https://atom.io Visual Studio Code - https://code.visualstudio.com/
  • 8. Node.js & npm Node.js - https://nodejs.org/ JavaScript Runtime Built on Chrome’s V8 JavaScript Engine Event Driven Non-Blocking IO Model npm - https://www.npmjs.com Package Manager for JavaScript Share and Reuse Node.js Modules $ npm install express
  • 9. # To publish $ npm login $ npm publish npm - Example Node.js Module See Using a package.json for Details // package.json { "name": "mymodule", "version": "1.0.0", "description": "", "main": "index.js", "scripts": { "test": "echo "Error: no test specified" && exit 1", }, "author": "", "license": "ISC" } // index.js function Mymodule() { } Mymodule.prototype.hello = function() { console.log(“Hello, Node.js module”); } module.exports = Mymodule; // sample.js Mymodule = require(‘./index’); var mymodule = new MyModule(); mymodule.hello(); // Hello, Node.js module
  • 10. Build JavaScript is Interpreter Language, Why Build? Bundle Multiple Modules into Single .JS File <script src=”app.bundle.js” /> Transpile Write in ES6, CoffeeScript, or TypeScript Run Browser Compatible Version of JavaScript Minimization and Obfuscation The Smaller, The Faster Loading Hard to Read Source
  • 11. Build GRUNT - http://gruntjs.com A JavaScript task runner for automation configured in Gruntfile gulp.js - http://gulpjs.com Streaming build system runs tasks defined in gulpfile.js Browserify - http://browserify.org Bundle node modules to allow running in browsers webpack - https://webpack.github.io A module bundler: takes modules with dependencies and generates static assets
  • 13. Build - webpack $ npm install webpack -g $ webpack ./app.js app.bundle.js http://webpack.github.io/docs/usage.html
  • 14. Build - JavaScript in Web Browser <body> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jque ry.min.js"></script> <div id="content"> <textarea id="input" rows=4 cols=80></textarea> <button id="convert">Submit</button> <p id="output"></p> </div> <script type="text/javascript"> $('#convert').click(function(e) { var text = $('#input').val(); $( '#output' ).html( '<p>' + text + '</p>' ); }); </script> </body> Sample: https://jsfiddle.net/yd2517e4/
  • 15. // webpack.config.js module.exports = { output.library: “Hlsm3u8” } Build - Node Module in Web Browser <body> <script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/2.2.2/jque ry.min.js"></script> <script src="scripts/app.bundle.js"></script> <div id="content"> <textarea id="input" rows=4 cols=80></textarea> <button id="convert">Submit</button> <p id="output"></p> </div> <script type="text/javascript"> $('#convert').click(function(e) { var text = $('#input').val(); var hlsm3u8 = new Hlsm3u8(); text = hlsm3u8.parse(text); $( '#output' ).html( '<p>' + text + '</p>' ); }); </script> </body> ‘output.library’ option of ‘webpack’ enables access to node module exports from browser code
  • 16. Build - Transpile CoffeeScript - http://coffeescript.org TypeScript - https://www.typescriptlang.org Babel - https://babeljs.io A JavaScript Compiler ECPAScript 2015 ( ES6 ) to Browser Compatible JavaScript (? TBC)
  • 17. // output.js 'use strict'; var _createClass = function () { //... }(); function _classCallCheck(instance, Constructor) { //... } var Sample = function () { function Sample(text) { _classCallCheck(this, Sample); this.text = text; } _createClass(Sample, [{ key: 'printHello', value: function printHello() { console.log('hello ' + this.text); } }]); return Sample; }(); var sample = new Sample('Babel'); sample.printHello(); Babel - Example // sample.js class Sample { constructor(text) { this.text = text; } printHello() { console.log(`hello ${this.text}`); } } var sample = new Sample('Babel'); sample.printHello(); // .babelrc { presets: [“es2015”] } # Install babel and transpile $ npm install --save-dev babel-cli babel-preset- es2015 $ ./node_modules/.bin/babel sample.js > output.js
  • 18. Build - Babel with webpack Install Node Modules $ npm install --save-dev babel-loader babel-core Configure webpack // webpack.config.js module: { loaders: [ { test: /.js$/, exclude: /node_modules/, loader: "babel-loader" } ] } Configure Babel: .babelrc { "presets": ["es2015"] } See https://babeljs.io/docs/setup/#installation for Details
  • 19. Build - Minimization and Obfuscation minifier - https://www.npmjs.com/package/minifier YUI Compressor - http://yui.github.io/yuicompressor/ UglifyJS2 - https://github.com/mishoo/UglifyJS2
  • 20. Build - UglifyJS2 Example # Install UglifyJS2 $ npm install uglify-js -g $ uglifyjs input.js --compress --mangle -o ouput.js // output.js "use strict";function _classCallCheck(e,n){if(!(e instanceof n))throw new TypeError("Cannot call a class as a function")}var _createClass=function(){function e(e,n){for(var t=0;t<n.length;t++){var l=n[t];l.enumerable=l.enumerable||!1,l.configurable=!0,"value"in l&&(l.writable=!0),Object.defineProperty(e,l.key,l)}}return function(n,t,l){return t&&e(n.prototype,t),l&&e(n,l),n}}(),Sample=function(){function e(n){_classCallCheck(this,e),this.text=n}return _createClass(e,[{key:"printHello",value:function(){console.log("hello "+this.text)}}]),e}(),sample=new Sample("Babel");sample.printHello(); // input.js 'use strict'; var _createClass = function () { //... }(); function _classCallCheck(instance, Constructor) { //... } var Sample = function () { function Sample(text) { _classCallCheck(this, Sample); this.text = text; } _createClass(Sample, [{ key: 'printHello', value: function printHello() { console.log('hello ' + this.text); } }]); return Sample; }(); var sample = new Sample('Babel'); sample.printHello();
  • 21. Build - UglifyJS with webpack webpack UglifyJSPlugin http://webpack.github.io/docs/list-of- plugins.html#uglifyjsplugin $ npm install webpack --save-dev // webpack.config.js module.exports = { ... plugins:[new webpack.optimize.UglifyJsPlugin({ compress: {warnings: false}, })] … } $ webpack
  • 22. Testing Jasmine - http://jasmine.github.io “Jasmine is a behavior-driven development framework for testing JavaScript code.” Karma - https://karma-runner.github.io/ Test Runner. Unit Testing. And Many Others.
  • 23. Testing - Jasmine Install ‘jasmine’ command $ npm install -g jasmine Create jasmine.json, default configuration $ jasmine init Write test cases, jasmine specs, and run $ jasmine // myappSpec.js describe("A suite", function() { it("contains spec with an expectation", function() { expect(true).toBe(true); }); it("The 'toBeLessThan' matcher is for mathematical comparisons", function() { var pi = 3.1415926, e = 2.78; expect(e).toBeLessThan(pi); expect(pi).not.toBeLessThan(e); }); });
  • 24. Running Tests in a Browser In HTML, include source and spec files and jasmine files Open the HTML File in Browser Testing - Jasmine <link rel="shortcut icon" type="image/png" href="lib/jasmine-2.4.1/jasmine_favicon.png"> <link rel="stylesheet" href="lib/jasmine- 2.4.1/jasmine.css"> <script src="lib/jasmine- 2.4.1/jasmine.js"></script> <script src="lib/jasmine-2.4.1/jasmine- html.js"></script> <script src="lib/jasmine- 2.4.1/boot.js"></script> <!-- include source files here... --> <script src="../public/dist/hlsm3u8.js"></script> <!-- include spec files here... --> <script src="../spec/hlsm3u8spec.js"></script>
  • 25. Chrome Developer Tools - https://developers.google.com/web/tools/chrome-devtools/ Chrome -> Menu -> View -> Developers -> Developer Tools Source Map Maps combined/minified file back to an unbuilt state Debugging
  • 26. Debugging - Chrome Developer Tools
  • 27. Debugging - Source Map Without Source Map
  • 28. Debugging - Source Map With Source Map
  • 29. Debugging - Source Map Introduction to JavaScript Source Map Generating Source Map with webpack Build $ webpack -d app.bundle.js app.bundle.js.map See Development shortcut -d and devtool Webpack configuration for Details Chrome DevTools Locates Source Map (.map) in the Same Path of .JS
  • 30. Documentation JSDoc - http://usejsdoc.org Docco - https://jashkenas.github.io/docco/ YUIDoc - http://yui.github.io/yuidoc/
  • 31. Documentation - YUIDoc # Install babel and transpile $ npm install -g yuidocjs $ yuidoc . $ # open out/index.html in browser
  • 32. Summary Code BuildTestDebug Document + Source Map Demo Project: https://github.com/simonkim/jstools-demo