I'm trying to get this project: https://github.com/stormpath/stormpath-angular2-express-example running on webpack. The application starts up, but when the first page loads I'm getting this error:
TypeError: Cannot read property 'getCookie' of null
at CookieXSRFStrategy.configureRequest (app.js:51374)
at XHRBackend.createConnection (app.js:51414)
at httpRequest (app.js:51752)
at StormpathHttp.Http.get (app.js:51863)
at StormpathHttp.get (app.js:78381)
at Stormpath.getAccount (app.js:49917)
at new Stormpath (app.js:49906)
at _View_AppComponent_Host0.createInternal (host.ngfactory.js:20)
at _View_AppComponent_Host0.AppView.create (app.js:42393)
at _View_AppComponent_Host0.DebugAppView.create (app.js:42593)
I have a sample repo setup here: https://github.com/djkrite/ng2-stormpath-webpack-example
I've tried to use:
BrowserDomAdapter.makeCurrent();
before the bootstrap call, but that ends up throwing another error about unexpected token import.
Any help would be appreciated.
Good news! I figured out how to make ng2-stormpath-webpack-example work. I think the root cause of the problem is the typescript configuration (
tsconfig.json) was in the src directory and webpack expects it in the root directory. Here's thetsconfig.jsonfile that works (remember, I moved it to the root directory):I changed the webpack loaders in
webpack.config.jsto be:I also removed the empty resolve extension:
Finally, in
package.json, I added types for Protractor and upgraded to Webpack 2.x.Here's a pull request with the fix: https://github.com/djkrite/ng2-stormpath-webpack-example/pull/1