Closed bamossza closed 5 years ago
I solved the problem solution below.
Look at devDependencies
I downgrade @angular-devkit/build-angular
version from 0.13.9
to 0.8.9
I think @angular/fire
part of firebase/messaging
not compatible build by TerserPlugin
Because version 0.13.9
using build by TerserPlugin
, but version 0.8.9
using build by UglifyJSPlugin
I'm not sure this is the best way but it make me able to continue to work
Everyone can recommend me.
Thanks for the new knowledge
I think this should be reopened. While downgrading @angular-devkit/build-angular
lets my project compile, there's webpack errors in the browser at runtime:
TypeError: __webpack_require__.e is not a function
at vendor.js:83865
at ZoneDelegate.push../node_modules/zone.js/dist/zone.js.ZoneDelegate.invoke (polyfills.js:9624)
at Zone.push../node_modules/zone.js/dist/zone.js.Zone.run (polyfills.js:9374)
at NgZone.push../node_modules/@angular/core/fesm5/core.js.NgZone.runOutsideAngular (vendor.js:76386)
at new UserTrackingService (vendor.js:83864)
at _createClass (vendor.js:80104)
at _createProviderInstance (vendor.js:80072)
at initNgModule (vendor.js:80005)
at new NgModuleRef_ (vendor.js:80732)
at createNgModuleRef (vendor.js:80721)
Version info
How it occurred ?
My project use Firebase Cloud Message(FCM) during system development, no problems were found. But have the problem when I build to the production(
ng build --prod --progress
)How to reproduce these conditions
File: package.json
Steps to set up and reproduce
Create file: src/manifest.json and encode below.
Create file: src/firebase-messaging-sw.js and encode below.
// Initialize the Firebase app in the service worker by passing in the // messagingSenderId. firebase.initializeApp({ 'messagingSenderId': '123' });
// Retrieve an instance of Firebase Messaging so that it can handle background // messages. const messaging = firebase.messaging();
"assets": [ "src/assets", "src/i18n", "src/favicon.ico", "src/manifest.json", "src/firebase-messaging-sw.js" ],
<!doctype html>
export const environment = { ... ... firebase: { apiKey: "*O8qR***", authDomain: "**.firebaseapp.com", databaseURL: "https://******.firebaseio.com", projectId: "message-*", storageBucket: "message-****.appspot.com", messagingSenderId: "911**", } };
imports: [ ... AngularFireModule.initializeApp(environment.firebase), AngularFireAuthModule, AngularFireMessagingModule ],
import {Injectable} from '@angular/core'; import {BehaviorSubject} from 'rxjs'; import {AngularFireAuth} from '@angular/fire/auth'; import {AngularFireMessaging} from '@angular/fire/messaging'; import {take} from 'rxjs/operators'; import {AppProfileService} from '../app-profile/app-profile.service'; import {HttpClient, HttpParams} from '@angular/common/http'; import {SuccessResponse} from '../common-interface/SuccessResponse';
@Injectable({ providedIn: 'root' }) export class MessagingService {
}
ERROR in ./node_modules/@angular/fire/messaging/messaging.js 14:40 Module parse failed: Unexpected token (14:40) You may need an appropriate loader to handle this file type. | var _this = this; | if (!isPlatformServer(platformId)) {
Expected behavior
No error and build to production successfully.
> ng build --prod --progress
How do I fix it?
Thank you so much.