You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Not compatible with Angular 2 AoT (Ahead-of-time compilation) #787
As explained in Angular 2 AoT docs, module MUST be set to es2015 in tsconfig.json. Just in case, I tried commonjs or system: 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 from export default Raven to export = Raven.)
When using import Raven from 'raven-js';, the compiler says:
error TS1192: Module '".../node_modules/raven-js/typescript/raven"' has no default export.
When using import Raven = require('raven-js');:
error TS1202: Import assignment cannot be used when targeting ECMAScript 2015 modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.
And using import * as Raven from 'raven-js'; does not work with:
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.
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 Raven object lives on window in 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, leave systemjs.config.js alone, and let good old typings do the job at compilation time.
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 define modules in their declaration files, so they can be imported in many fashions (including import Raven from 'raven-js';).
I'm working on a rewriting of the .d.ts file, I'd be happy to make a pull-request depending on the output of this dicussion. It would look like:
Activity
benvinegar commentedon Dec 2, 2016
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.
adrienverge commentedon Dec 3, 2016
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:NoNameProvided commentedon Mar 1, 2017
Just a heads up, it's compatible now, so the issue can be closed.
benvinegar commentedon Mar 2, 2017
Sweet.
meta: Add changelog entry for 4.1.0 (getsentry#787)
chore(deps): Bump web-vitals to 6.2.3 (#25062)