I’ve just fired up a new project selecting the built in bundler + requireJs. I’m getting an error running au build
and don’t have the faintest idea where to start looking for the problem!
I’ve set up the paths in tsconfig.json and aurelia.json as per the documentation.
I’m using Yarn
I have two files in the app that refer to firebase:
auth-service.ts
import * as firebase from "firebase/app";
import "firebase/auth";
import { Router } from "aurelia-router";
import { autoinject } from "aurelia-framework";
@autoinject
export class AuthService {
public user: firebase.User;
public userLoggedIn = false;
public authToken = null;
public config: firebase.app.App;
constructor(private readonly router: Router) {
this.config = firebase.initializeApp({
apiKey: "XXXX",
authDomain: "XXX",
databaseURL: "XXX,
projectId: "XXX",
storageBucket: "XXX",
messagingSenderId: "XXX"
});
this.config.auth().onAuthStateChanged(user => {
this.userLoggedIn = user ? true : false;
this.user = user;
});
}
public async login() {
let provider = new firebase.auth.GoogleAuthProvider();
try {
const result = await this.config.auth().signInWithPopup(provider);
this.authToken = (result.credential as any).accessToken;
this.userLoggedIn = true;
console.log(this.user);
} catch (err) {
console.log(err);
}
}
}
and
app.ts
import { AuthService } from "services/auth-service";
import { autoinject } from "aurelia-framework";
@autoinject
export class App {
public user: firebase.User;
public userLoggedIn = false;
constructor(private readonly authService: AuthService) { }
public async login() {
await this.authService.login();
this.user = this.authService.user;
this.userLoggedIn = this.authService.userLoggedIn;
console.log(this.authService.authToken);
}
}
I get the following error running au build
> au build
Starting 'readProjectConfiguration'...
INFO [Bundle] Manually adding package: 2.3.0 aurelia-bootstrapper
INFO [Bundle] Manually adding package: 1.0.4 aurelia-loader-default
INFO [Bundle] Manually adding package: 1.8.0 aurelia-pal-browser
INFO [Bundle] Manually adding package: 1.0.0 aurelia-testing
INFO [Bundle] Manually adding package: 2.0.15 text
Finished 'readProjectConfiguration'
Starting 'processMarkup'...
Starting 'processCSS'...
Starting 'copyFiles'...
Starting 'configureEnvironment'...
Finished 'copyFiles'
Finished 'processCSS'
Finished 'processMarkup'
Finished 'configureEnvironment'
Starting 'buildTypeScript'...
Finished 'buildTypeScript'
Starting 'writeBundles'...
INFO [Bundler] Tracing files ...
INFO [Bundler] Auto tracing package: 1.0.1 aurelia-event-aggregator
INFO [Bundler] Auto tracing package: 1.3.0 aurelia-framework
INFO [Bundler] Auto tracing package: 1.2.0 aurelia-history-browser
INFO [Bundler] Auto tracing package: 1.0.0 aurelia-loader
INFO [Bundler] Auto tracing package: 1.0.0 aurelia-logging-console
INFO [Bundler] Auto tracing package: 1.0.4 aurelia-metadata
INFO [Bundler] Auto tracing package: 1.8.0 aurelia-pal
INFO [Bundler] Auto tracing package: 1.3.0 aurelia-polyfills
INFO [Bundler] Auto tracing package: 1.6.3 aurelia-router
INFO [Bundler] Auto tracing package: 1.5.1 aurelia-templating-binding
INFO [Bundler] Auto tracing package: 1.7.1 aurelia-templating-resources
INFO [Bundler] Auto tracing package: 1.3.3 aurelia-templating-router
INFO [Bundler] Auto tracing package: 5.5.4 firebase
ERROR [Bundler] Failed to do transforms
INFO [Bundler] TypeError: Cannot read property 'toString' of null
{ uid: 9,
name: 'writeBundles',
branch: false,
error:
TypeError: Cannot read property 'toString' of null
at exports.BundledSource.get contents [as contents] (C:\Visual Studio\AtlContracts\Client\node_modules\aurelia-cli\lib\build\bundled-source.js:34:46)
at exports.BundledSource.transform (C:\Visual Studio\AtlContracts\Client\node_modules\aurelia-cli\lib\build\bundled-source.js:204:16)
at items.forEach.item (C:\Visual Studio\AtlContracts\Client\node_modules\aurelia-cli\lib\build\bundler.js:148:26)
at Array.forEach (<anonymous>)
at doTranform (C:\Visual Studio\AtlContracts\Client\node_modules\aurelia-cli\lib\build\bundler.js:145:18)
at Utils.runSequentially.then (C:\Visual Studio\AtlContracts\Client\node_modules\aurelia-cli\lib\build\bundler.js:218:22)
at process._tickCallback (internal/process/next_tick.js:68:7),
duration: [ 0, 111358200 ],
time: 1539630555651 }
{ uid: 0,
name: '<series>',
branch: true,
error:
TypeError: Cannot read property 'toString' of null
at exports.BundledSource.get contents [as contents] (C:\Visual Studio\AtlContracts\Client\node_modules\aurelia-cli\lib\build\bundled-source.js:34:46)
at exports.BundledSource.transform (C:\Visual Studio\AtlContracts\Client\node_modules\aurelia-cli\lib\build\bundled-source.js:204:16)
at items.forEach.item (C:\Visual Studio\AtlContracts\Client\node_modules\aurelia-cli\lib\build\bundler.js:148:26)
at Array.forEach (<anonymous>)
at doTranform (C:\Visual Studio\AtlContracts\Client\node_modules\aurelia-cli\lib\build\bundler.js:145:18)
at Utils.runSequentially.then (C:\Visual Studio\AtlContracts\Client\node_modules\aurelia-cli\lib\build\bundler.js:218:22)
at process._tickCallback (internal/process/next_tick.js:68:7),
duration: [ 2, 530979300 ],
time: 1539630555660 }
TypeError: Cannot read property 'toString' of null
at exports.BundledSource.get contents [as contents] (C:\Visual Studio\AtlContracts\Client\node_modules\aurelia-cli\lib\build\bundled-source.js:34:46)
at exports.BundledSource.transform (C:\Visual Studio\AtlContracts\Client\node_modules\aurelia-cli\lib\build\bundled-source.js:204:16)
at items.forEach.item (C:\Visual Studio\AtlContracts\Client\node_modules\aurelia-cli\lib\build\bundler.js:148:26)
at Array.forEach (<anonymous>)
at doTranform (C:\Visual Studio\AtlContracts\Client\node_modules\aurelia-cli\lib\build\bundler.js:145:18)
at Utils.runSequentially.then (C:\Visual Studio\AtlContracts\Client\node_modules\aurelia-cli\lib\build\bundler.js:218:22)
at process._tickCallback (internal/process/next_tick.js:68:7)