mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
Change target to ES5 for targeting Hermes Engine, disable noEmitHelpers, don't crash if registerOnGlobalContext fails, and disable the special transform for NativeClass decorator
This commit is contained in:
@@ -15,23 +15,27 @@ interface ExtensionMap {
|
||||
}
|
||||
|
||||
function registerOnGlobalContext(moduleName: string, exportName: string): void {
|
||||
Object.defineProperty(global, exportName, {
|
||||
get: function () {
|
||||
// We do not need to cache require() call since it is already cached in the runtime.
|
||||
const m = global.loadModule(moduleName);
|
||||
try {
|
||||
Object.defineProperty(global, exportName, {
|
||||
get: function () {
|
||||
// We do not need to cache require() call since it is already cached in the runtime.
|
||||
const m = global.loadModule(moduleName);
|
||||
|
||||
// Redefine the property to make sure the above code is executed only once.
|
||||
const resolvedValue = m[exportName];
|
||||
Object.defineProperty(global, exportName, {
|
||||
value: resolvedValue,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
});
|
||||
// Redefine the property to make sure the above code is executed only once.
|
||||
const resolvedValue = m[exportName];
|
||||
Object.defineProperty(global, exportName, {
|
||||
value: resolvedValue,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
});
|
||||
|
||||
return resolvedValue;
|
||||
},
|
||||
configurable: true,
|
||||
});
|
||||
return resolvedValue;
|
||||
},
|
||||
configurable: true,
|
||||
});
|
||||
} catch (_e) {
|
||||
// TODO: On Hermes, some globals are non-configurable and we cannot override them.
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"extends": "./tsconfig.json",
|
||||
"compilerOptions": {
|
||||
"noEmitOnError": true,
|
||||
"noEmitHelpers": true,
|
||||
"noEmitHelpers": false,
|
||||
"declaration": true,
|
||||
"ignoreDeprecations": "5.0",
|
||||
"removeComments": false,
|
||||
|
||||
@@ -2,7 +2,8 @@
|
||||
* @internal Util used for exporting opposing platform utils and warning the user if they are trying to access them.
|
||||
*/
|
||||
export function platformCheck(parent?: string) {
|
||||
if (__DEV__) {
|
||||
// @ts-ignore
|
||||
if (globalThis.__DEV__) {
|
||||
return new Proxy(
|
||||
{},
|
||||
{
|
||||
|
||||
@@ -274,7 +274,7 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||
},
|
||||
getCustomTransformers() {
|
||||
return {
|
||||
before: [require('../transformers/NativeClass').default],
|
||||
before: [],
|
||||
};
|
||||
},
|
||||
});
|
||||
|
||||
@@ -5,6 +5,8 @@ import ts from 'typescript';
|
||||
*/
|
||||
export default function (ctx: ts.TransformationContext) {
|
||||
function isNativeClassExtension(node: ts.ClassDeclaration) {
|
||||
return false;
|
||||
|
||||
let decorators: Readonly<ts.Decorator[]>;
|
||||
|
||||
if ('canHaveDecorators' in ts && ts.canHaveDecorators(node)) {
|
||||
@@ -35,7 +37,7 @@ export default function (ctx: ts.TransformationContext) {
|
||||
node.getText().replace(/@NativeClass(\((.|\n)*?\))?/gm, ''),
|
||||
{
|
||||
compilerOptions: {
|
||||
noEmitHelpers: true,
|
||||
noEmitHelpers: false,
|
||||
module: ts.ModuleKind.ESNext,
|
||||
target: ts.ScriptTarget.ES5,
|
||||
experimentalDecorators: true,
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
"compilerOptions": {
|
||||
"rootDir": ".",
|
||||
"baseUrl": ".",
|
||||
"target": "es2017",
|
||||
"target": "es5",
|
||||
"module": "commonjs",
|
||||
"outDir": "./dist",
|
||||
"declaration": true,
|
||||
|
||||
@@ -2,15 +2,16 @@
|
||||
"compileOnSave": false,
|
||||
"compilerOptions": {
|
||||
"rootDir": ".",
|
||||
"target": "ES2020",
|
||||
"target": "ES5",
|
||||
"module": "esnext",
|
||||
"downlevelIteration": true,
|
||||
"sourceMap": true,
|
||||
"declaration": true,
|
||||
"moduleResolution": "node",
|
||||
"emitDecoratorMetadata": true,
|
||||
"experimentalDecorators": true,
|
||||
"noEmitOnError": true,
|
||||
"noEmitHelpers": true,
|
||||
"noEmitHelpers": false,
|
||||
"diagnostics": true,
|
||||
"skipLibCheck": true,
|
||||
"skipDefaultLibCheck": true,
|
||||
|
||||
Reference in New Issue
Block a user