Skip to content

fix: bundle entry points #8884

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 23, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions packages/core/application/application-common.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
// Require globals first so that snapshot takes __extends function.
const nsGlobals = require('../globals');
if (!global.NativeScriptHasInitGlobal) {
nsGlobals.initGlobal();
}
import '../globals';

// Types
import { AndroidApplication, iOSApplication } from '.';
Expand Down
4 changes: 2 additions & 2 deletions packages/core/bundle-entry-points.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
const g = require('./globals');
g.initGlobal();
// using import is important to ensure webpack keep it in order
import './globals';

// Register "dynamically" loaded module that need to be resolved by the
// XML/component builders.
Expand Down
2 changes: 1 addition & 1 deletion packages/core/globals/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -360,4 +360,4 @@ export function initGlobal() {
}
if (!global.NativeScriptHasInitGlobal) {
initGlobal();
}
}
5 changes: 2 additions & 3 deletions packages/core/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
/// <reference path="./global-types.d.ts" />
// Init globals first (use require to ensure it's always at the top)
const nsGlobals = require('./globals');
nsGlobals.initGlobal();
// Init globals first (use import to ensure it's always at the top)
import './globals';

export { iOSApplication, AndroidApplication } from './application';
export type { ApplicationEventData, LaunchEventData, OrientationChangedEventData, UnhandledErrorEventData, DiscardedErrorEventData, CssChangedEventData, LoadAppCSSEventData, AndroidActivityEventData, AndroidActivityBundleEventData, AndroidActivityRequestPermissionsEventData, AndroidActivityResultEventData, AndroidActivityNewIntentEventData, AndroidActivityBackPressedEventData, SystemAppearanceChangedEventData } from './application';
Expand Down
5 changes: 1 addition & 4 deletions packages/core/inspector_modules.ios.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,5 @@
console.log('Loading inspector modules...');
import { initGlobal } from './globals';
if (!global.NativeScriptHasInitGlobal) {
initGlobal();
}
import './globals';
require('./debugger/webinspector-network');
require('./debugger/webinspector-dom');
require('./debugger/webinspector-css');
Expand Down
7 changes: 1 addition & 6 deletions packages/core/ui/frame/activity.android.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import '../../globals';
import { setActivityCallbacks, AndroidActivityCallbacks } from '.';
// use requires to ensure import order
const globals = require('../../globals');
const appModule = require('../../application');

if (global.__snapshot) {
globals.initGlobal();
}

/**
* NOTE: We cannot use NativeClass here because this is used in appComponents in webpack.config
* Whereby it bypasses the decorator transformation, hence pure es5 style written here
Expand Down
2 changes: 1 addition & 1 deletion packages/webpack/bundle-config-loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const loader: loader.Loader = function (source, map) {
}

source = `
require("${sourceModule}/bundle-entry-points");
import "${sourceModule}/bundle-entry-points";
${source}
`;

Expand Down