Lessons learned
Piotr Lewandowski
npm install
npm install -g bower
bower install
npm install -g grunt
grunt
./gradlew run
# just works
# no need to install anything
npm
gradle
do we need global dependencies?
{
"scripts": {
"postinstall": "bower install",
"start": "grunt",
"release": "grunt build --release"
}
}
+ more control on remote env
e.g. Jenkins
+ all packages can be local
> npm install
> npm start
> npm run release
no more global dependencies
+ flat directory tree
+ simple dependency resolution
(simple yet effective)
+ no big problems actually
- the same work as npm
- additional tool in stack
(needs to be learnt)
- no clear future
still missing some front-end packages*
* you can put direct link to GitHub repo
but that's not the point
Don't install libraries
with
10 lines of code!
build = 200MB and 25k files*
*backend and other stuff per job = ~1GB
npm install
--no-optional
--cache-min=999999
--quiet
npm 3 is slightly better
npm 2+
even better for CI / Jenkins
npm install -g npm-cache
npm-cache install npm bower
1000+ lines of config file
a bit messy
... not only in config file
... regular changes needed
an unexpected journey
one reason to change a file
separate
linters
optimizations
releases
dashboard: {
files: {
'dist/js/dashboard.min.js': [
'src/modules/dashboard/module.js',
'!src/modules/dashboard/route.js'
'src/modules/dashboard/**/*.js'
]
}
// ... repeat for 40 other modules
// ... add new tasks at the end of file
var APP_MODULES = [
{ module: 'modules.shop', dir: 'shop', outFile: 'shop.min.js' },
{ module: 'modules.dashboard', dir: 'dashboard', outFile: 'dashboard.min.js' },
{ module: 'modules.account', dir: 'account', outFile: 'account.min.js' }
];
make project files structure RegEx friendly
var properties = {
VERSION: version,
API: '/* @echo API */',
TYPE: '/* @echo TYPE */',
REVISION: '/* @echo REVISION */',
DATE: '/* @echo DATE */'
};
one file!
can be injected anywhere
can be unit tested
list of all possibilities
in one place
Gandalf approves
gulp.task("compile", ["tslint"], () => {
return gulp.src("src/**/*.ts")
.pipe(sourcemaps.init())
.pipe(tsc(tsProject)).js
.pipe(ngAnnotate())
.pipe(sourcemaps.write("."))
.pipe(gulp.dest("build"));
});
for more complex apps
+ simple API
+ code over configuration
+ easily separated for many files
... you're gonna have a bad time
+ less team communication required
+ easier setup for front-end devs
- synchronization problem
- security
if your app is the only client
of your API
Thanks