Skip to content

Commit c907e31

Browse files
committed
fix(webpack): backwards compat with older core versions
1 parent 630ec31 commit c907e31

File tree

3 files changed

+20
-4
lines changed

3 files changed

+20
-4
lines changed
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// VIRTUAL ENTRY START
22
require('@nativescript/core/bundle-entry-points')
33
const context = require.context("~/", /* deep: */ true, /* filter: */ /.(xml|js|s?css)$/);
4-
global.registerBundlerModules(context);
4+
if (typeof global.registerBundlerModules === 'function') {
5+
global.registerBundlerModules(context);
6+
} else {
7+
global.registerWebpackModules(context);
8+
}
59
// VIRTUAL ENTRY END
Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
// VIRTUAL ENTRY START
22
require('@nativescript/core/bundle-entry-points')
33
const context = require.context("~/", /* deep: */ true, /* filter: */ /\.(xml|js|(?<!\.d\.)ts|s?css)$/);
4-
global.registerBundlerModules(context);
4+
if (typeof global.registerBundlerModules === 'function') {
5+
global.registerBundlerModules(context);
6+
} else {
7+
global.registerWebpackModules(context);
8+
}
59
// VIRTUAL ENTRY END

packages/webpack5/src/stubs/virtual-entry-typescript.mjs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,11 @@ if (typeof import.meta.glob !== 'undefined') {
1313
'~/**/*.@(xml|js|ts|scss|css)',
1414
{ eager: true }, // uncomment to import immediately
1515
);
16-
global.registerBundlerModules(modules);
16+
if (typeof global.registerBundlerModules === 'function') {
17+
global.registerBundlerModules(modules);
18+
} else {
19+
global.registerWebpackModules(modules);
20+
}
1721
} else {
1822
const require = createRequire(import.meta.url);
1923
const root = fileURLToPath(new URL('./src', import.meta.url));
@@ -63,6 +67,10 @@ if (typeof import.meta.glob !== 'undefined') {
6367
}
6468
const context = loadContextSync();
6569

66-
global.registerBundlerModules(context);
70+
if (typeof global.registerBundlerModules === 'function') {
71+
global.registerBundlerModules(context);
72+
} else {
73+
global.registerWebpackModules(context);
74+
}
6775
}
6876
// VIRTUAL ENTRY END

0 commit comments

Comments
 (0)