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
I am importing js classes as modules to other js files and import them to my angular 5 ts project like this:
if (typeof module !== 'undefined') {
var CPE = {};
CPE.a1 = require('./a1');
}
CPE.a2 = class a2 extends a1 {}
if (typeof module !== 'undefined') {
var CPE = {};
CPE.a3 = require('../a/a3.js');
CPE.a4 = require('../a/a4.js');
}
CPE.a5 = class Curve{
constructor (params = {}) {
params.className = 'a5';
super(params);
this.modifiers = {
a3: new CPE.a3(this),
a4: new CPE.a4(this)
};
}
....
In ts file:
import * as CPE from '../../../../../app/aa/a/a1';
When ng build --prod and transpile to ES5, some of js class are still 'class', not transpiled at all. Also weird thing is each time the files not transpiled properly are not same.
Here is the file main.XXX.bundle.js after build:
if (typeof module !== 'undefined') {
var CPE = {};
CPE.a3 = require('../a/a3.js');
CPE.a4 = require('../a/a4.js');
}
CPE.a5 = class Curve{
constructor (params = {}) {
params.className = 'a5';
super(params);
this.modifiers = {
a3: new CPE.a3(this),
a4: new CPE.a4(this)
};
}
....
it is literally the original js class, not transpiled at all.
The CLI does not transpile Javascript code. Third-party code is expected to be in the appropriate format.
For project files that are javascript and imported in TypeScript files, the allowJs option may allow the javascript files to be processed by the TypeScript compiler. Please note that this is untested and not officially supported.
I am importing js classes as modules to other js files and import them to my angular 5 ts project like this:
In ts file:
When
ng build --prod
and transpile to ES5, some of js class are still 'class', not transpiled at all. Also weird thing is each time the files not transpiled properly are not same.Here is the file main.XXX.bundle.js after build:
it is literally the original js class, not transpiled at all.
Versions
tsconfig,json:
package.json
The log given by the failure
Not build errors. But the 'class' keyword fails on IE11
Is there anyone has clue what is happening and how to fix it? Thanks.
The text was updated successfully, but these errors were encountered: