in liferay portal and liferay dxp

33
Modern frontend workflows in Liferay Portal and Liferay DXP Iván Zaera Avellon, Liferay Chema Balsas, Liferay Pier Paolo Ramon, SMC

Upload: others

Post on 09-Apr-2022

33 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: in Liferay Portal and Liferay DXP

Modern frontend workflowsin Liferay Portal and Liferay DXP

Iván Zaera Avellon, Liferay Chema Balsas, LiferayPier Paolo Ramon, SMC

Page 2: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier

Page 3: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier https://www.youtube.com/watch?v=Zcdwd4sCz6I

Page 4: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier https://www.youtube.com/watch?v=8zFvPPIF-SM

Page 5: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier

Page 6: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier

PROBLEM

The current support in Liferay Portal does not match the expectations of the

standard frontend developer

Page 7: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier

545’372Packages in the npm registry

Page 8: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier

2’273’588Downloads of the package lodash alone

During yesterday, 14th november 2017

Page 9: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier

Page 10: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier

SOLUTION

Support the most used industry-standard workflow for frontend

development: npm

Page 11: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier

Iván Zaera Avellon @izaera

Software Engineer,Liferay Spain

Chema Balsas @jbalsas

Software Engineer,Liferay Spain

Page 12: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier

Matching Developer ExpectationsIf a necessary feature has a high astonishment factor, it may be

necessary to redesign the feature— principle of least astonishment

Page 13: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier

DEVS FRONT-END ADMINS

Developers should simply develop, any

way they feel comfortable with.

Frontend developers should not care about the backend or how the application is put

together.

Admins must have some control over the

deployment and shared modules in a controlled

environment.

Page 14: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier

Addressing Technical Challenges

BACKWARDS COMPATIBILITY

PORTALMODULARITY

Reuse current Infrastructure

Don’t introduceBreaking Changes

Build tools inspired by standard bundlers.

Leverage Liferay AMD Loader

Page 15: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier

Liferay AMD LoaderAn asynchronous loader of JavaScript modules (files).

Page 16: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier

The solution

Page 17: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier

Do I need Node.js and npm on my server?!

NO

Page 18: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier

Build process Internal npmregistry

LiferayAMD Loader

Liferay Portal

BabelTypeScript

CoffeeScript• • •

(plain vanilla JS)

AMDCommonJSECMAScript

— — —(presets)

BundlingCompiling

Resolve packagedependencies graphs

Serve resolved resourcesto the client

Reduce request countby concatenating and minifing

Page 19: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier

The Beginning

An intrepid developer begins a portlet project!

Page 20: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier

Create a project

Our developer uses blade or the SDK to create the project and decides to use Javascript and some npm packages to implement his solution.

Page 21: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier

Use npm

The used npm packages are hosted by the npm registry (npmjs.com) for development consumption.

Page 22: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier

Download packages

Using npm standard tool, the developer downloads the needed npm packages to his local machine. Those packages are written to the standard node_modules folder.

Page 23: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier

Time for a decision

When finished, the developer decides to deploy the portlet to Liferay Portal.

Page 24: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier

Keep calm and use the bundler

The developer makes use of the npm bundler to pack all needed Javascript packages. Also, using gradle and standard Liferay plugins the developer assembles an OSGi bundle containing the artifacts generated by npm bundler. Finally, the OSGi bundle is deployed to the Portal making some

Page 25: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier

Black magic happens

The npm processor analyzes the deployed bundle searching for npm packages, and publishing everything found in the npm registry: the name of the packages, their version numbers, and dependencies, as well as their valid versions (semver expressions).

Page 26: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier

Moreblack magic happens

A Portal tracker registers and publishes the portlet.

Page 27: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier

Welcome visitors

Until some user opens a browser and hits a Portal page containing the deployed portlet.

Page 28: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier

Real World

The Portal sends the HTML and Javascript code for the page containing the portlet. That code is run by the browser and that makes the AMD Loader to initialize.

Page 29: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier

Module collaboration

The AMD Loader asks the Portal for information about all available Javascript modules, their versions, and dependencies. Such information is composed by the npm registry and published by means of a servlet.

Page 30: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier

The end!

Finally, the portlet’s Javascript codes invokes the AMD require() method at some time which makes the AMD Loader grab the npm packages that were bundled in the portlet.

Page 31: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier

When will it be available?

Liferay DXP FP 30 Liferay Portal CE GA 5

which is now!

Page 32: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier

Who wants a demo?

Page 33: in Liferay Portal and Liferay DXP

#LRIS17 | @_pier

Thanks and rate my session!If the demo worked.

Otherwise you can skip that step.No seriously please don’t.

Rate My Session!

Download the Liferay Events Mobile App Today

Pier Paolo Ramon

Twitter. @_pierGitHub: @yuchi