Skip to content
This repository was archived by the owner on Nov 22, 2024. It is now read-only.

feat(common): add UniversalEngine to encapsulate rendering#912

Closed
CaerusKaru wants to merge 1 commit intomasterfrom
fabian/common
Closed

feat(common): add UniversalEngine to encapsulate rendering#912
CaerusKaru wants to merge 1 commit intomasterfrom
fabian/common

Conversation

@CaerusKaru
Copy link
Copy Markdown
Member

@CaerusKaru CaerusKaru commented Feb 25, 2018

  • Abstract the common rendering patterns and caching into
    a UniversalEngine
  • Update build parameters to reflect dependency on
    common for existing engines

BREAKING CHANGE:

  • The ASP.NET Core, Express, and Hapi engines now have
    the Common package as a peer dependency
  • The tokens for all engines are now exported from
    @nguniversal/common

E.g.

BEFORE:
import {REQUEST, RESPONSE} from '@nguniversal/express-engine/tokens';

AFTER:
import {REQUEST, RESPONSE} from '@nguniversal/common';

@CaerusKaru
Copy link
Copy Markdown
Member Author

Full credit to @Toxicable for getting this together. Removed from the commit history because the clabot is evil.

Copy link
Copy Markdown

@Toxicable Toxicable left a comment

Choose a reason for hiding this comment

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

A couple of things that need to be applied to all engines

Comment thread modules/aspnetcore-engine/tsconfig.json Outdated
@@ -0,0 +1,12 @@
// Configuration for IDEs only.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

this was left over from the factor, should be removed

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I think it's important to note that this file should not be extended, and is not being used to build the package

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

What's it being used for then?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

IDEs, as noted by the comment. It's so that the imports are not considered invalid while editing files.

"baseUrl": "."
"baseUrl": ".",
"paths": {
"@nguniversal/common": ["../../dist/packages/common"]
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should point to ../common - the src not the output, unless this was the fix to the issue I had

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This was exactly the fix to the issue you had

/**
* ResourceLoader implimentation for loading files
*/
export class FileLoader implements ResourceLoader {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Should be @Interval along with the other ones under UniversalEngine

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

This file is not exported in the public api so is by default internal

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Unless you mean I should just add an internal comment? In which case sure

import {FileLoader} from './file-loader';
import {RenderOptions} from './interfaces';

export class UniversalEngine {
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

should be @internal

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Same as above

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Also, I don't think this should be internal. I think the whole point is to encourage usage, even outside of the nguniversal-scope engines.

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

That wasn't my original plan. I think for now we should keep it internal, we can always externalize it later on, we cannot internalize it once it's already external

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Alright I've marked it and its methods internal for now, but we really should look at this soon to externalize

Comment thread modules/common/tsconfig.json Outdated
@@ -0,0 +1,9 @@
// Configuration for IDEs only.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

also unneeded

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Same as above

Comment thread modules/express-engine/tsconfig.json Outdated
@@ -0,0 +1,12 @@
// Configuration for IDEs only.
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

same here

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Same as above

@CaerusKaru
Copy link
Copy Markdown
Member Author

Setting to blocked while we decide when this should be merged.

@Toxicable Toxicable added this to the 6.0 milestone Mar 7, 2018
@Toxicable Toxicable added the target: minor target: minor This PR is targeted for the next minor release label Mar 8, 2018
@CaerusKaru CaerusKaru force-pushed the fabian/common branch 4 times, most recently from ef0e48a to 5d50a23 Compare April 6, 2018 20:07
Comment thread build-config.js Outdated
const libNames = [
'aspnetcore-engine',
'common',
'aspnetcore-engine',
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

any reason for this?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Not anymore, was leftover from when we used the pre-Material build system. The rationale being that common needed to be built before everything else

Comment thread WORKSPACE
node_repositories(package_json = ["//:package.json"])


local_repository(
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

This is easier to leave as is since it'll use the one that Angular core depends on, otherwise we could get out of sync

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Point taken

Comment thread modules/common/public_api.ts Outdated
export { StateTransferInitializerModule } from './src/state-transfer-initilizer/module';
export { UniversalEngine as ɵUniversalEngine } from './src/universal-engine/universal-engine';
export { NgSetupOptions } from './src/universal-engine/interfaces';
export { REQUEST, RESPONSE, ORIGIN_URL } from './src/tokens/index';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Tokens should be a secondary entry point here.
Otherwise we'll get size regressions

*/
export * from './public_api';
export * from './interfaces';
export {UniversalEngine as ɵUniversalEngine} from './universal-engine';
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

could you make a private export file for common and do the renaming there

Copy link
Copy Markdown

@Toxicable Toxicable left a comment

Choose a reason for hiding this comment

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

Just the secondary entry on tokens then should be good.
But blocking the merge for now till we do a release with our current status

@CaerusKaru CaerusKaru force-pushed the fabian/common branch 3 times, most recently from 4c2a51d to 763bc2e Compare April 6, 2018 21:24
"*.ts",
"src/**/*.ts",
]),
module_name = "@nguniversal/express-engine",
Copy link
Copy Markdown

Choose a reason for hiding this comment

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

put this back in

@Toxicable
Copy link
Copy Markdown

There's a regression here with TransferHttpCacheModule
Since it's bundled into the same bundle as the Universal Engine, it causes the TransferHttpCacheModule import to bring domino and other server side symbols with it.

I propose we make a secondary entry for the Engine to avoid any more API changes

@Toxicable
Copy link
Copy Markdown

We should reexport the tokens from their old locations but depricate them so this isn't a breaking change, to be removed in v7

* Abstract the common rendering patterns and caching into
  a UniversalEngine
* Update build parameters to reflect dependency on
  common for existing engines

BREAKING CHANGE:

* The ASP.NET Core, Express, and Hapi engines now have
  the Common package as a peer dependency
* The tokens for all engines are now exported from
  `@nguniversal/common`

E.g.

BEFORE:
`import {REQUEST, RESPONSE} from '@nguniversal/express-engine/tokens';`

AFTER:
`import {REQUEST, RESPONSE} from '@nguniversal/common';`
@CaerusKaru
Copy link
Copy Markdown
Member Author

Closed in favor of #996

@CaerusKaru CaerusKaru closed this May 19, 2018
@CaerusKaru CaerusKaru deleted the fabian/common branch May 19, 2018 04:01
@angular-automatic-lock-bot
Copy link
Copy Markdown

This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.

Read more about our automatic conversation locking policy.

This action has been performed automatically by a bot.

@angular-automatic-lock-bot angular-automatic-lock-bot Bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

state: blocked state: WIP target: minor target: minor This PR is targeted for the next minor release

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants