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