Skip to content

Commit 1f790ed

Browse files
authored
fix(core): bundle entry points and global handling (NativeScript#8884)
1 parent 9ec1939 commit 1f790ed

File tree

7 files changed

+9
-21
lines changed

7 files changed

+9
-21
lines changed

packages/core/application/application-common.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
// Require globals first so that snapshot takes __extends function.
2-
const nsGlobals = require('../globals');
3-
if (!global.NativeScriptHasInitGlobal) {
4-
nsGlobals.initGlobal();
5-
}
2+
import '../globals';
63

74
// Types
85
import { AndroidApplication, iOSApplication } from '.';

packages/core/bundle-entry-points.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
const g = require('./globals');
2-
g.initGlobal();
1+
// using import is important to ensure webpack keep it in order
2+
import './globals';
33

44
// Register "dynamically" loaded module that need to be resolved by the
55
// XML/component builders.

packages/core/globals/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,4 +360,4 @@ export function initGlobal() {
360360
}
361361
if (!global.NativeScriptHasInitGlobal) {
362362
initGlobal();
363-
}
363+
}

packages/core/index.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
/// <reference path="./global-types.d.ts" />
2-
// Init globals first (use require to ensure it's always at the top)
3-
const nsGlobals = require('./globals');
4-
nsGlobals.initGlobal();
2+
// Init globals first (use import to ensure it's always at the top)
3+
import './globals';
54

65
export { iOSApplication, AndroidApplication } from './application';
76
export type { ApplicationEventData, LaunchEventData, OrientationChangedEventData, UnhandledErrorEventData, DiscardedErrorEventData, CssChangedEventData, LoadAppCSSEventData, AndroidActivityEventData, AndroidActivityBundleEventData, AndroidActivityRequestPermissionsEventData, AndroidActivityResultEventData, AndroidActivityNewIntentEventData, AndroidActivityBackPressedEventData, SystemAppearanceChangedEventData } from './application';

packages/core/inspector_modules.ios.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
console.log('Loading inspector modules...');
2-
import { initGlobal } from './globals';
3-
if (!global.NativeScriptHasInitGlobal) {
4-
initGlobal();
5-
}
2+
import './globals';
63
require('./debugger/webinspector-network');
74
require('./debugger/webinspector-dom');
85
require('./debugger/webinspector-css');

packages/core/ui/frame/activity.android.ts

Lines changed: 1 addition & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,7 @@
1+
import '../../globals';
12
import { setActivityCallbacks, AndroidActivityCallbacks } from '.';
2-
// use requires to ensure import order
3-
const globals = require('../../globals');
43
const appModule = require('../../application');
54

6-
if (global.__snapshot) {
7-
globals.initGlobal();
8-
}
9-
105
/**
116
* NOTE: We cannot use NativeClass here because this is used in appComponents in webpack.config
127
* Whereby it bypasses the decorator transformation, hence pure es5 style written here

packages/webpack/bundle-config-loader.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ const loader: loader.Loader = function (source, map) {
5252
}
5353

5454
source = `
55-
require("${sourceModule}/bundle-entry-points");
55+
import "${sourceModule}/bundle-entry-points";
5656
${source}
5757
`;
5858

0 commit comments

Comments
 (0)