René's URL Explorer Experiment


Title: "Unexpected token import" with angularfire2 on angular-cli, AOT, SSR, and firebase-functions · Issue #1073 · angular/angularfire · GitHub

Open Graph Title: "Unexpected token import" with angularfire2 on angular-cli, AOT, SSR, and firebase-functions · Issue #1073 · angular/angularfire

X Title: "Unexpected token import" with angularfire2 on angular-cli, AOT, SSR, and firebase-functions · Issue #1073 · angular/angularfire

Description: Has anyone done this? I'm stuck, would love some suggestions, or pointers if I'm missing something obvious or misunderstanding the problem. Version info Angular: 4.2.4 Firebase: 4.1.3 AngularFire: 4.0.0-rc1 Firebase-functions: 0.5.9 How ...

Open Graph Description: Has anyone done this? I'm stuck, would love some suggestions, or pointers if I'm missing something obvious or misunderstanding the problem. Version info Angular: 4.2.4 Firebase: 4.1.3 AngularFire: ...

X Description: Has anyone done this? I'm stuck, would love some suggestions, or pointers if I'm missing something obvious or misunderstanding the problem. Version info Angular: 4.2.4 Firebase: 4.1.3 Angul...

Opengraph URL: https://github.com/angular/angularfire/issues/1073

X: @github

direct link

Domain: github.com

IPv4 address: 140.82.114.4


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"\"Unexpected token import\" with angularfire2 on angular-cli, AOT, SSR, and firebase-functions","articleBody":"Has anyone done this?  I'm stuck, would love some suggestions, or pointers if I'm missing something obvious or misunderstanding the problem.\r\n\r\n### Version info\r\n\r\n**Angular:** 4.2.4\r\n\r\n**Firebase:** 4.1.3\r\n\r\n**AngularFire:** 4.0.0-rc1\r\n\r\n**Firebase-functions:** 0.5.9\r\n\r\n### How to reproduce these conditions\r\n\r\nUsing AOT compiling, and server-side rendering, as described in this blagpost:\r\nhttps://medium.com/@evertonrobertoauler/angular-4-universal-app-with-angular-cli-db8b53bba07d\r\n\r\nRepo:\r\nhttps://github.com/SparksNetwork/exp-angular-firebase/tree/shared-code\r\n(note I am working from the `shared-code` branch)\r\n(the repo structure is kind of haphazard, everything lives in `/functions` because thats what firebase-functions requires)\r\n\r\n**Steps to set up and reproduce**\r\n\r\nApp runs successfully JIT running `ng serve`.\r\n\r\nCompile client and server with `ng run build`.\r\n\r\nServe via standalone node express server with `ts-node src/server.ts` or via firebase-functions local emulator with `firebase serve --only functions`.\r\n\r\n### Debug output\r\n\r\n```\r\nFirebaseError: Error occurred while parsing your function triggers.\r\n\r\n/Users/sdebaun/exp-angular-firebase/functions/node_modules/angularfire2/app/firebase.app.module.js:1\r\n(function (exports, require, module, __filename, __dirname) { import { InjectionToken, } from '@angular/core';\r\n                                                              ^^^^^^\r\nSyntaxError: Unexpected token import\r\n    at createScript (vm.js:53:10)\r\n    at Object.runInThisContext (vm.js:95:10)\r\n    at Module._compile (module.js:543:28)\r\n    at Object.Module._extensions..js (module.js:580:10)\r\n    at Module.load (module.js:488:32)\r\n    at tryModuleLoad (module.js:447:12)\r\n    at Function.Module._load (module.js:439:3)\r\n    at Module.require (module.js:498:17)\r\n    at require (internal/module.js:20:19)\r\n    at Object.\u003canonymous> (/Users/sdebaun/exp-angular-firebase/functions/fn/dist/dist/ngfactory/src/app/app.server.module.ngfactory.js:23:13)\r\ni  functions: No HTTPS functions emulated. Support for other function types are coming soon.\r\n```\r\n\r\n# Diagnosis\r\n\r\nI suspect it's choking because the angularfire2 npm module is compiled with es2015 syntax which doesn't work in node (which firebase-functions is based on).\r\n\r\n# Possible fix?\r\n\r\nI don’t know a lot about how NPM works, but I’m wondering if I:\r\n1. Fork angularfire2\r\n2. change the `target` and/or `module` settings in forked tsconfig until I find something that works\r\n3. in my app, `npm install` from my forked angularfire2\r\n\r\nOnly thing I don’t know how to do there is: how do I ensure that my forked angularfire2 gets built?  There’s a bunch of stuff in the repo that has to do with the build process that is totally alien to me.\r\n\r\nThe only other thing I can think of is to try to write my own firebase wrapper for angular, ~~with blackjack and hookers~~ that compiles to commonjs.  That sounds like an awful idea.\r\n\r\n# Things I’ve Tried\r\n\r\n## Using DI to swap out AngularFire2 on server\r\n\r\nPer the discussion in this thread (https://github.com/angular/universal-starter/issues/127#issuecomment-287644140), I started writing a fake service that adhered to the angularfire2 interfaces that I could use in my app.server.module.ts.  Quickly I realized that because all my services actually have to import from the real angularfire2 module, it still wouldn’t work, because the error gets thrown when the file is imported, not when it’s run.\r\n\r\n## Copying angularfire2/src into a local lib directory and building it with the project\r\n\r\nWhen I try this, I get all sorts of errors about Zone not being found.  I can’t figure out what needs to be included, or how, in order to get it to compile the ts.\r\n\r\n","author":{"url":"https://github.com/sdebaun","@type":"Person","name":"sdebaun"},"datePublished":"2017-07-16T07:37:58Z","url":"https://github.com/angular/angularfire/issues/1073"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:59d709d9-e328-a384-a0e3-0e94d04a1ad3
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idC1D6:1E74B0:7F8CFF:A20734:6B035C1F
html-safe-nonce693397bdfba3880ee4f4aab220d2eeb40a7ae7561aad7ad6619e909a3cc82140
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJDMUQ2OjFFNzRCMDo3RjhDRkY6QTIwNzM0OjZCMDM1QzFGIiwidmlzaXRvcl9pZCI6IjIxNzg5Mjc5NjQzNjI4NTc1MDMiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ==
visitor-hmac19367e462414df525ee05b1a1a92191bcbc44c05b82d2b79bd00abd2eea47b11
hovercard-subject-tagissue:243223431
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/angular/angularfire/1073/issue_layout
twitter:imagehttps://opengraph.githubassets.com/3ea180dd45da50b1354d2c9fd7c90f1abf65848687c589120e5ae397a8d29006/angular/angularfire/issues/1073
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/3ea180dd45da50b1354d2c9fd7c90f1abf65848687c589120e5ae397a8d29006/angular/angularfire/issues/1073
og:image:altHas anyone done this? I'm stuck, would love some suggestions, or pointers if I'm missing something obvious or misunderstanding the problem. Version info Angular: 4.2.4 Firebase: 4.1.3 AngularFire: ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernamesdebaun
hostnamegithub.com
expected-hostnamegithub.com
None87e774ee7c6b3bee0490394e4d3e57ec9dbc956f74b87ea685dc8996c1676456
turbo-cache-controlno-preview
go-importgithub.com/angular/angularfire git https://github.com/angular/angularfire.git
octolytics-dimension-user_id139426
octolytics-dimension-user_loginangular
octolytics-dimension-repository_id49453413
octolytics-dimension-repository_nwoangular/angularfire
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id49453413
octolytics-dimension-repository_network_root_nwoangular/angularfire
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
release423dbb54c5e7bfecc838eb387c1435eb3d0e760d
ui-targetfull
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/angular/angularfire/issues/1073#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangularfire%2Fissues%2F1073
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fangular%2Fangularfire%2Fissues%2F1073
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=angular%2Fangularfire
Reloadhttps://github.com/angular/angularfire/issues/1073
Reloadhttps://github.com/angular/angularfire/issues/1073
Reloadhttps://github.com/angular/angularfire/issues/1073
angularhttps://github.com/angular
angularfirehttps://github.com/angular/angularfire
Codehttps://github.com/angular/angularfire
Issues162 (162)https://github.com/angular/angularfire/issues
Pull requests5 (5)https://github.com/angular/angularfire/pulls
Discussionshttps://github.com/angular/angularfire/discussions
Actionshttps://github.com/angular/angularfire/actions
Projectshttps://github.com/angular/angularfire/projects
Security and qualityhttps://github.com/angular/angularfire/security
Insightshttps://github.com/angular/angularfire/insights
https://github.com/angular/angularfire
New issuehttps://github.com/login?return_to=https://github.com/angular/angularfire/issues/1073
New issuehttps://github.com/login?return_to=https://github.com/angular/angularfire/issues/1073
"Unexpected token import" with angularfire2 on angular-cli, AOT, SSR, and firebase-functionshttps://github.com/angular/angularfire/issues/1073#top
https://github.com/jamesdaniels
https://github.com/sdebaun
sdebaunhttps://github.com/sdebaun
on Jul 16, 2017https://github.com/angular/angularfire/issues/1073#issue-243223431
https://medium.com/@evertonrobertoauler/angular-4-universal-app-with-angular-cli-db8b53bba07dhttps://medium.com/@evertonrobertoauler/angular-4-universal-app-with-angular-cli-db8b53bba07d
https://github.com/SparksNetwork/exp-angular-firebase/tree/shared-codehttps://github.com/SparksNetwork/exp-angular-firebase/tree/shared-code
angular/universal-starter#127 (comment)https://github.com/angular/universal-starter/issues/127#issuecomment-287644140
Nexthttps://github.com/angular/angularfire/issues/1073?timeline_page=1
https://github.com/davideast
davideasthttps://github.com/davideast
on Jul 21, 2017https://github.com/angular/angularfire/issues/1073#issuecomment-316982493
@sdebaunhttps://github.com/sdebaun
HTTP modulehttps://github.com/angular/angular/blob/master/packages/http/package.json
https://github.com/sdebaun
sdebaunhttps://github.com/sdebaun
on Jul 25, 2017https://github.com/angular/angularfire/issues/1073#issuecomment-317822368
@davideasthttps://github.com/davideast
https://github.com/justingrayston
justingraystonhttps://github.com/justingrayston
on Jul 31, 2017https://github.com/angular/angularfire/issues/1073#issuecomment-319096171
https://github.com/davideast
davideasthttps://github.com/davideast
on Jul 31, 2017https://github.com/angular/angularfire/issues/1073#issuecomment-319098910
@justingraystonhttps://github.com/justingrayston
@sdebaunhttps://github.com/sdebaun
https://github.com/KrGyan
KrGyanhttps://github.com/KrGyan
on Aug 2, 2017https://github.com/angular/angularfire/issues/1073#issuecomment-319591944
@davideasthttps://github.com/davideast
https://github.com/sdebaun
sdebaunhttps://github.com/sdebaun
on Aug 2, 2017https://github.com/angular/angularfire/issues/1073#issuecomment-319742629
@justingraystonhttps://github.com/justingrayston
https://github.com/KrGyan
KrGyanhttps://github.com/KrGyan
on Aug 4, 2017https://github.com/angular/angularfire/issues/1073#issuecomment-320311057
@davideasthttps://github.com/davideast
https://github.com/davideast
davideasthttps://github.com/davideast
on Aug 4, 2017https://github.com/angular/angularfire/issues/1073#issuecomment-320354356
@sdebaunhttps://github.com/sdebaun
@justingraystonhttps://github.com/justingrayston
@KrGyanhttps://github.com/KrGyan
#1088https://github.com/angular/angularfire/pull/1088
@sdebaunhttps://github.com/sdebaun
https://github.com/MichaelSolati
MichaelSolatihttps://github.com/MichaelSolati
on Aug 11, 2017https://github.com/angular/angularfire/issues/1073#issuecomment-321710724
@davideasthttps://github.com/davideast
RxJS websockethttp://reactivex.io/rxjs/class/es6/Observable.js~Observable.html#static-method-webSocket
https://github.com/SpeedoPasanen
SpeedoPasanenhttps://github.com/SpeedoPasanen
on Aug 11, 2017https://github.com/angular/angularfire/issues/1073#issuecomment-321824050
https://github.com/EreckGordon
EreckGordonhttps://github.com/EreckGordon
on Aug 22, 2017https://github.com/angular/angularfire/issues/1073#issuecomment-324090868
@davideasthttps://github.com/davideast
https://github.com/SpeedoPasanen
SpeedoPasanenhttps://github.com/SpeedoPasanen
on Sep 1, 2017https://github.com/angular/angularfire/issues/1073#issuecomment-326667539
https://gist.github.com/funkizer/6d6559787c17a88c60cf2ddc9ca06527https://gist.github.com/funkizer/6d6559787c17a88c60cf2ddc9ca06527
https://gist.github.com/funkizer/e162adff4191cae3c897e6bc5b7fd605https://gist.github.com/funkizer/e162adff4191cae3c897e6bc5b7fd605
https://github.com/AnthonyNahas
AnthonyNahashttps://github.com/AnthonyNahas
on Sep 12, 2017https://github.com/angular/angularfire/issues/1073#issuecomment-328972240
herehttps://github.com/evertonrobertoauler/cli-universal-demo/issues/14#issuecomment-328468083
the full explanationhttps://github.com/SebastianM/angular-google-maps/issues/1052#issuecomment-331150772
https://github.com/iiAtlas
iiAtlashttps://github.com/iiAtlas
on Oct 3, 2017https://github.com/angular/angularfire/issues/1073#issuecomment-333954430
https://github.com/patrickmichalina
patrickmichalinahttps://github.com/patrickmichalina
on Oct 7, 2017https://github.com/angular/angularfire/issues/1073#issuecomment-334947620
@davideasthttps://github.com/davideast
https://github.com/hiepxanh
hiepxanhhttps://github.com/hiepxanh
on Nov 29, 2017https://github.com/angular/angularfire/issues/1073#issuecomment-347721183
https://github.com/khalid-halo
khalid-halohttps://github.com/khalid-halo
on Dec 13, 2017https://github.com/angular/angularfire/issues/1073#issuecomment-351494384
https://github.com/hiepsieuviet
hiepsieuviethttps://github.com/hiepsieuviet
on Dec 14, 2017https://github.com/angular/angularfire/issues/1073#issuecomment-351581809
socket.io with ssr https://github.com/angular/universal/issues/846
ZoneMacroTaskWrapperhttps://github.com/angular/angular/issues/20520
@jamesdanielshttps://github.com/jamesdaniels
Support Angular Universalhttps://github.com/angular/angularfire2/pull/1377
https://github.com/hiepxanh
hiepxanhhttps://github.com/hiepxanh
on Jan 21, 2018https://github.com/angular/angularfire/issues/1073#issuecomment-359254256
https://github.com/kpsrinivas
kpsrinivashttps://github.com/kpsrinivas
on Jan 31, 2018https://github.com/angular/angularfire/issues/1073#issuecomment-361823581
https://cloud.google.com/firestore/docs/reference/rest/https://cloud.google.com/firestore/docs/reference/rest/
https://github.com/doczoidberg
doczoidberghttps://github.com/doczoidberg
on Feb 6, 2018https://github.com/angular/angularfire/issues/1073#issuecomment-363408214
https://github.com/ceolinwill
ceolinwillhttps://github.com/ceolinwill
on Feb 6, 2018https://github.com/angular/angularfire/issues/1073#issuecomment-363410271
@doczoidberghttps://github.com/doczoidberg
#1454https://github.com/angular/angularfire/pull/1454
https://github.com/kpsrinivas
kpsrinivashttps://github.com/kpsrinivas
on Feb 8, 2018https://github.com/angular/angularfire/issues/1073#issuecomment-364004862
https://github.com/andreaaschei
andreaascheihttps://github.com/andreaaschei
on Apr 13, 2018https://github.com/angular/angularfire/issues/1073#issuecomment-381050254
@kpsrinivashttps://github.com/kpsrinivas
https://github.com/kpsrinivas
kpsrinivashttps://github.com/kpsrinivas
on Apr 13, 2018https://github.com/angular/angularfire/issues/1073#issuecomment-381068921
@andreaascheihttps://github.com/andreaaschei
https://github.com/jamesdaniels
jamesdanielshttps://github.com/jamesdaniels
on Apr 13, 2018https://github.com/angular/angularfire/issues/1073#issuecomment-381095674
…https://github.com/angular/angularfire/issues/1073
@andreaascheihttps://github.com/andreaaschei
https://github.com/andreaascheihttps://github.com/andreaaschei
#1073 (comment)https://github.com/angular/angularfire/issues/1073#issuecomment-381068921
https://github.com/notifications/unsubscribe-auth/AACvr1oL7Y9a8gjw9Z3CRMN_yqKFRWvnks5toGY8gaJpZM4OZObkhttps://github.com/notifications/unsubscribe-auth/AACvr1oL7Y9a8gjw9Z3CRMN_yqKFRWvnks5toGY8gaJpZM4OZObk
https://github.com/anasbaddyr
anasbaddyrhttps://github.com/anasbaddyr
on Apr 19, 2018https://github.com/angular/angularfire/issues/1073#issuecomment-382848338
@jamesdanielshttps://github.com/jamesdaniels
https://www.youtube.com/watch?v=wij2-gyG12Ehttps://www.youtube.com/watch?v=wij2-gyG12E
https://github.com/patrickmichalina
patrickmichalinahttps://github.com/patrickmichalina
on Apr 19, 2018https://github.com/angular/angularfire/issues/1073#issuecomment-382851479
https://github.com/jamesdaniels
jamesdanielshttps://github.com/jamesdaniels
on Apr 19, 2018https://github.com/angular/angularfire/issues/1073#issuecomment-382904572
…https://github.com/angular/angularfire/issues/1073
#1073 (comment)https://github.com/angular/angularfire/issues/1073#issuecomment-382851479
https://github.com/notifications/unsubscribe-auth/AACvr3fLZcDVzPtJfciP10YUJJyoKRTbks5tqON9gaJpZM4OZObkhttps://github.com/notifications/unsubscribe-auth/AACvr3fLZcDVzPtJfciP10YUJJyoKRTbks5tqON9gaJpZM4OZObk
jamesdanielshttps://github.com/jamesdaniels
completedhttps://github.com/angular/angularfire/issues?q=is%3Aissue%20state%3Aclosed%20archived%3Afalse%20reason%3Acompleted
on May 4, 2018https://github.com/angular/angularfire/issues/1073#event-1610799815
Sign up for freehttps://github.com/signup?return_to=https://github.com/angular/angularfire/issues/1073
Sign in to commenthttps://github.com/login?return_to=https://github.com/angular/angularfire/issues/1073
jamesdanielshttps://github.com/jamesdaniels
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Response headers:
Servergithub.com
Content-Typetext/html; charset=utf-8
Cache-Controlmax-age=0, private, must-revalidate

Viewport: width=device-width


URLs of crawlers that visited me.