Possibility to change the order of @swc/helpers

Hello, I'm working on some legacy project that is using ng-annotate package. I have a problem resulting from swc compilation, namely in the case of class definitions (and perhaps also in other situations that I have not encountered), the order of the JSDoc comment is shifted by placing the helper definition or helper import. And this makes ng-annotate unable to process this structure. Furthermore, I suspect this state of affairs can also generate other problems, such as incorrect typing using jsdoc. Is there any way to fix this bug, or force SWC to place these imports at the very top of the files rather than directly above the classes?
/** @ngInject */
class TestClass {
constructor (private testField) {}
}
/** @ngInject */
class TestClass {
constructor (private testField) {}
}
output:
/** @ngInject */ import { _ as _define_property } from "@swc/helpers/_/_define_property";
class TestClass {
constructor(testField){
_define_property(this, "testField", void 0);
this.testField = testField;
}
}
/** @ngInject */ import { _ as _define_property } from "@swc/helpers/_/_define_property";
class TestClass {
constructor(testField){
_define_property(this, "testField", void 0);
this.testField = testField;
}
}
My config:
{
"jsc": {
"parser": {
"syntax": "typescript",
"tsx": false,
"decorators": true
},
"target": "es2015",
"loose": false,
"minify": {
"compress": false,
"mangle": false
},
"transform": {
"decoratorVersion": "2022-03"
},
"preserveAllComments": true,
"externalHelpers": true
},
"module": {
"type": "es6"
},
"minify": false,
"isModule": true
}
{
"jsc": {
"parser": {
"syntax": "typescript",
"tsx": false,
"decorators": true
},
"target": "es2015",
"loose": false,
"minify": {
"compress": false,
"mangle": false
},
"transform": {
"decoratorVersion": "2022-03"
},
"preserveAllComments": true,
"externalHelpers": true
},
"module": {
"type": "es6"
},
"minify": false,
"isModule": true
}
2 Replies
.414.
.414.OP14h ago
What's interesting is that this does not happen when we have anything before jsdoc:
const x = 42;
/** @ngInject */
class TestClass {
constructor (private testField) {}
}
const x = 42;
/** @ngInject */
class TestClass {
constructor (private testField) {}
}
import { _ as _define_property } from "@swc/helpers/_/_define_property";
const x = 42;
/** @ngInject */ class TestClass {
constructor(testField){
_define_property(this, "testField", void 0);
this.testField = testField;
}
}
import { _ as _define_property } from "@swc/helpers/_/_define_property";
const x = 42;
/** @ngInject */ class TestClass {
constructor(testField){
_define_property(this, "testField", void 0);
this.testField = testField;
}
}
kdy1
kdy18h ago
Can you file an issue instead? This is a bug related to span.lo=0

Did you find this page helpful?