Repository navigation
Not compatible with Angular 2 AoT (Ahead-of-time compilation) #787
Description
Activity
To clarify, your suggestion is put it back the way it was (before 05ebd0)? Or should we have a proper ES2015 module export file for that platform somewhere?
Basically, we're struggling with the TypeScript definition file. I basically kept tweaking things until I could get it loading in every possible loader. But it's becoming harder and harder to keep up with all of this. If someone from the Angular or TypeScript community could give us a definitive best practice for how the typings file should work, we'd be glad to make the requisite changes.
Hi @benvinegar, thanks for your answer.
I've spent a lot of time on this and I now see two points here:
1. Should SystemJS be used to load raven-js bundle?
First, as copied from here, raven-js is a third party global resource. The
Ravenobject lives onwindowin the browser. Therefore it is maybe not correct to import it in an Angular 2 application.So I'm wondering whether it's correct or not to load it from SystemJS using
System.config({ packages: { 'raven-js': { main: 'dist/raven.js' } } ...; maybe the best way is to import it through<script src="/node_modules/raven-js/dist/raven.min.js"></script>in the HTML file, leavesystemjs.config.jsalone, and let good old typings do the job at compilation time.What do you think? @Chuckv01 @NoNameProvided @davorpeic
2. Typings shipped with raven-js
I really don't think
import Raven = require('raven-js');is the "normal" way to import a bundled JS library. Most libs I've seen definemodules in their declaration files, so they can be imported in many fashions (includingimport Raven from 'raven-js';).I'm working on a rewriting of the
.d.tsfile, I'd be happy to make a pull-request depending on the output of this dicussion. It would look like:declare module "raven-js" { export default ravenjs; } declare module ravenjs { interface RavenStatic { ... } interface RavenOptions { ... } ... } declare var Raven: ravenjs.RavenStatic;
Just a heads up, it's compatible now, so the issue can be closed.
Sweet.
- added a commit that references this issue
on Jun 19, 2026 - added a commit that references this issue
on Oct 5, 2026
TL;DR: Angular 2 AoT requires
es2015compilation and raven-js Typescript import is notcompatible with
es2015anymore.Hi,
Before you ask, I've been through #752, #735, #643 and recent changes to raven-js + Angular 2 documentation.
As explained in Angular 2 AoT docs,
moduleMUST be set toes2015intsconfig.json. Just in case, I triedcommonjsorsystem: both failed as expected.The problem is: since commit 05ebd0 (I think), raven-js import method is not compatible with
es2015. (This commit changed the definition file fromexport default Raventoexport = Raven.)When using
import Raven from 'raven-js';, the compiler says:When using
import Raven = require('raven-js');:And using
import * as Raven from 'raven-js';does not work with:I'd be happy to provide more information if needed.