Skip to content
This repository has been archived by the owner on Jan 6, 2025. It is now read-only.

Universal issue due to packaging format issue #354

Closed
cyrilletuzi opened this issue Jul 31, 2017 · 18 comments
Closed

Universal issue due to packaging format issue #354

cyrilletuzi opened this issue Jul 31, 2017 · 18 comments
Labels
has pr A PR has been created to address this issue P0 Critical issue that needs to be resolved immediately ssr
Milestone

Comments

@cyrilletuzi
Copy link
Contributor

cyrilletuzi commented Jul 31, 2017

I run an app with Material and FlexLayout, server-side rendered with the new option of @angular/cli 1.3.0-rc.

No problem with Material, but FlexLayout generates this error :

/node_modules/@angular/flex-layout/media-query/breakpoints/break-points-token.js:8
import { InjectionToken } from '@angular/core';
^^^^^^

SyntaxError: Unexpected token import

I suspect it's because flex-layout is not distributed in the official way like other Angular modules. Some entry points (main, module, es2015, umd...) are missing compared to other Angular packages.

@ThomasBurleson
Copy link
Contributor

ThomasBurleson commented Jul 31, 2017

@cyrilletuzi: We recently upgraded our build process for Angular (v4.x) and AOT. Please retry with the latest builds on HEAD: see Installing @angular/flex-layout@HEAD

@cyrilletuzi
Copy link
Contributor Author

cyrilletuzi commented Jul 31, 2017

Imports are working now, but I get this error :

/node_modules/@angular/core/bundles/core.umd.js:382
            throw 'reflect-metadata shim is required when using class decorators';
            ^
reflect-metadata shim is required when using class decorators

It's OK if I include the polyfill, but all other librairies stopped using it, and it will be removed soon from @angular/cli.

It may be because flex-layout is not requesting the good format of other Angular packages (like core).

@ThomasBurleson
Copy link
Contributor

@cyrilletuzi - what do you mean "it may be because flex-layout is not requesting the good format of other Angular packages (like core)" ?

@cyrilletuzi
Copy link
Contributor Author

I'm not an expert about how official Angular packages are distributed, but the error seems to show flex-layout is importing core in umd format, and I think now Angular modules are imported via the es2015 entry point. But I see that HEAD version of flex-layout has now the es2015 entry point so I don't know what's the problem...

@ThomasBurleson
Copy link
Contributor

@hansl, @Brocco - any thoughts on the issue with the CLI rc ?

@cyrilletuzi
Copy link
Contributor Author

And I may have been optimist about saying it works with reflect, rendering is not working anymore, but I think it's related to #353

@ThomasBurleson
Copy link
Contributor

@cyrilletuzi - Oh wait... you said SSR above. Yes, you will need the code changes in PR #353.

@ThomasBurleson ThomasBurleson added this to the v2.0.0-beta.9 milestone Jul 31, 2017
@cyrilletuzi
Copy link
Contributor Author

Yes, but I think the reflect issue is a different one. Will see.

@hansl
Copy link

hansl commented Jul 31, 2017

@ThomasBurleson do you use reflect metadata outside of angular decorators?

ThomasBurleson added a commit that referenced this issue Aug 2, 2017
Use getDom() for platform-server/universal fixes
Now gets document object from platform-browser by DI instead of global.

> Thx to @ardatan for PR #346.

Fixes #187, #354. Closes #346.
ThomasBurleson added a commit that referenced this issue Aug 2, 2017
Use getDom() for platform-server/universal fixes
Now gets document object from platform-browser by DI instead of global.

> Thx to @ardatan for PR #346.

Fixes #187, #354. Closes #346.
@ThomasBurleson ThomasBurleson added has pr A PR has been created to address this issue P1 Urgent issue that should be resolved before the next re-lease P0 Critical issue that needs to be resolved immediately and removed P1 Urgent issue that should be resolved before the next re-lease labels Aug 2, 2017
ThomasBurleson added a commit that referenced this issue Aug 3, 2017
Use getDom() for platform-server/universal fixes
Now gets document object from platform-browser by DI instead of global.

> Thx to @ardatan for PR #346.

Fixes #187, #354. Closes #346.
ThomasBurleson added a commit that referenced this issue Aug 4, 2017
Use getDom() for platform-server/universal fixes
Now gets document object from platform-browser by DI instead of global.

> Thx to @ardatan for PR #346.

Fixes #187, #354. Closes #346.
tinayuangao pushed a commit that referenced this issue Aug 4, 2017
Use getDom() for platform-server/universal fixes
Now gets document object from platform-browser by DI instead of global.

> Thx to @ardatan for PR #346.

Fixes #187, #354. Closes #346.
@CaerusKaru
Copy link
Member

CaerusKaru commented Aug 4, 2017

This issue persists even with the merge of #353

cc @ThomasBurleson @hansl

@hansl
Copy link

hansl commented Aug 4, 2017

@ThomasBurleson After talking to @chuckjaz, you can fix this by adding an importAs key to your index.metadata.json file. See this PR in Material: angular/components#6132

I suggest talking to Jeremy about it.

@ThomasBurleson
Copy link
Contributor

@hansl - Thx Hans. I will investigate and review with @jelbourn. I do appreciate your help.

@hansl
Copy link

hansl commented Aug 5, 2017

@ThomasBurleson actually after discussion with @chuckjaz and @tbosch it seems like using flatModuleId might be the way to go (see here).

@cyrilletuzi
Copy link
Contributor Author

As a more general perspective, shouldn't be the recommended configuration for building librairies for Angular available for every one ?

There will be similar problem with every third party librairies, and if even official librairies seems to don't know all what is necessary...

It's causing some important issues like angular/angular-cli#7200

@ThomasBurleson
Copy link
Contributor

Depends on angular/components#6132

@cyrilletuzi
Copy link
Contributor Author

Fixed in nightly builds.

@ghost
Copy link

ghost commented Sep 3, 2018

Please check the latest build. Line 79 has an import statement stuck on the end of the line that causes it to error.

@angular-automatic-lock-bot
Copy link

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 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
has pr A PR has been created to address this issue P0 Critical issue that needs to be resolved immediately ssr
Projects
None yet
Development

No branches or pull requests

4 participants