Skip to content

[DX-399] ES6 template#252

Merged
matteofigus merged 36 commits intomasterfrom
es6-template
Mar 5, 2018
Merged

[DX-399] ES6 template#252
matteofigus merged 36 commits intomasterfrom
es6-template

Conversation

@nickbalestra
Copy link
Contributor

@nickbalestra nickbalestra commented Jan 28, 2018

No description provided.

@codecov
Copy link

codecov bot commented Feb 8, 2018

Codecov Report

Merging #252 into master will decrease coverage by 0.17%.
The diff coverage is 97.89%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #252      +/-   ##
==========================================
- Coverage   98.68%   98.51%   -0.18%     
==========================================
  Files          31       38       +7     
  Lines         381      472      +91     
  Branches       58       70      +12     
==========================================
+ Hits          376      465      +89     
- Misses          5        7       +2
Impacted Files Coverage Δ
packages/oc-template-es6-compiler/index.js 100% <100%> (ø)
...ckages/oc-generic-template-renderer/lib/getInfo.js 100% <100%> (ø) ⬆️
...kages/oc-template-es6-compiler/lib/viewTemplate.js 100% <100%> (ø)
...bstract-base-template-utils/webpackConfigurator.js 100% <100%> (ø)
packages/oc-template-es6/index.js 100% <100%> (ø)
packages/oc-template-es6-compiler/lib/compile.js 100% <100%> (ø)
...-base-template-utils/font-family-unicode-parser.js 100% <100%> (ø)
...ckages/oc-template-es6-compiler/lib/compileView.js 95.74% <95.74%> (ø)
... and 5 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 122b200...229df9d. Read the comment docs.

@matteofigus
Copy link
Member

@nickbalestra can you check what is making Circle fail?

@nickbalestra
Copy link
Contributor Author

There is no setup for circle on this branch, he tries to enfer some stuff but I think it make sense that it won't be able to run properly

Copy link
Member

@matteofigus matteofigus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let's rebase to re-test circle? 👍

@nickbalestra nickbalestra changed the title ES6 template [WIP] ES6 template Feb 9, 2018
@nickbalestra nickbalestra changed the title [WIP] ES6 template [WIP][DX-399] ES6 template Feb 9, 2018
@nickbalestra nickbalestra removed the wip label Feb 9, 2018
@nickbalestra
Copy link
Contributor Author

Rebased! - Cool, its working pretty nice as actually is correct that the node6 build fails but the node8 pass (still waiting for travis.... )

@nickbalestra
Copy link
Contributor Author

All good now :), Out of curiosity I want to see how thing change by checking in the lock file for the cache checksum strategy

@@ -0,0 +1,14 @@
'use strict';
const es6Renderer = require('express-es6-template-engine');
Copy link
Contributor Author

@nickbalestra nickbalestra Feb 9, 2018

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note: For getting started I went with this , rationale:

  • getting up and running quicker,
  • nice api: (template can simply use ${prop}, without having to do ${model.prop}, good for extendibility
  • very small code, well tested (the express specific code is very small, so we could think of a fork, in case we want to clean that down in a second step).
  • allows for some nice thing like precompiling templates (as we do for handlebars), not adding that in in this first iteration but i think is something we might want to explore.

@nickbalestra nickbalestra changed the title [WIP][DX-399] ES6 template [DX-399] ES6 template Feb 9, 2018
@nickbalestra nickbalestra changed the title [DX-399] ES6 template [WIP][DX-399] ES6 template Feb 9, 2018
@matteofigus
Copy link
Member

matteofigus commented Feb 9, 2018

@nickbalestra not a big fan of the templating choice.
I think the goal here is to have es6. This is not es6, it is a templating language that looks like es6 - which for me is kind of against the whole vision.

To clarify, I think the view should be something like

module.exports = ({ name}) => `<div>${name}</div>`;

A couple of pros:

  1. It is actually javascript. It is simpler and easier to understand.
  2. Dependency free so it's smaller
  3. Allows easy composition (partials can just be required and potentially exposed as npm libraries)
  4. The props.prop vs prop can be elegantly achieved with destructuring
  5. Being javascript, it is cleaner to handle presentation related logic. Example:
module.exports = vm => {
  //code
  return `...`;
}
  1. Views can easily unit tested without being in need of extra tooling (test the compiled version)
  2. We could attach VS debugger - with the template engine, we would need the sourcemaps - not sure that is provided

@nickbalestra
Copy link
Contributor Author

nickbalestra commented Feb 9, 2018

Just fiddling with some ideas :) but I agree with your points.

@nickbalestra
Copy link
Contributor Author

Couple of thing I also want achieve with this (still in a wip at the moment).

  • Opinionated on css-in-js exactly in the same way we doing with the react-template
  • allow webpack to bundle/compile the view in case you adding more stuff to it

@nickbalestra nickbalestra changed the title [WIP][DX-399] ES6 template [DX-399] ES6 template Feb 22, 2018
@nickbalestra
Copy link
Contributor Author

@matteofigus This should be now ready to review

@nickbalestra
Copy link
Contributor Author

PS: Once this get merged, I'll rebase all the other outstanding PRs

@nickbalestra
Copy link
Contributor Author

@matteofigus is now rebased to master

Copy link
Member

@matteofigus matteofigus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can we also remove the yarn.lock?

'window.oc = window.oc || {};' +
'oc.cmd = oc.cmd || [];' +
'oc.cmd.push(function(oc){' +
'oc.addStylesToHead(\\'${css}\\');' +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should we move to <style> + event to keep this consistent with the React one?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yepa

@@ -0,0 +1,51 @@
jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000;

jasmine.DEFAULT_TIMEOUT_INTERVAL = 50000;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why is this timeout here twice?

Copy link
Member

@matteofigus matteofigus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just a question

@@ -0,0 +1,3 @@
jasmine.DEFAULT_TIMEOUT_INTERVAL = 100000;
test('', () => {});
// WIP
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This still needs to be completed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🙊

Copy link
Member

@matteofigus matteofigus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

As discussed, this is looking good but we want to handle the empty CSS scenario (similar to React) for when the CSS is not used.

@nickbalestra
Copy link
Contributor Author

@matteofigus give it a look, In this case was possible to reduce the template even further, let me know what ya think

'window.oc = window.oc || {};' +
'oc.cmd = oc.cmd || [];' +
'oc.cmd.push(function(oc){' +
"oc.events.fire(\\'oc:cssDidMount\\', \\'${css}\\');" +
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

${css} this should be outside of that

@matteofigus matteofigus merged commit b01c11e into master Mar 5, 2018
@matteofigus matteofigus deleted the es6-template branch March 5, 2018 16:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants