mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-15 11:01:21 +08:00
fix(webpack): add virtualEntry before main entry
fixes running with the JSC runtime, fixes #9469
This commit is contained in:
@ -2,6 +2,7 @@ import Config from 'webpack-chain';
|
|||||||
|
|
||||||
import { getEntryPath, getEntryDirPath } from '../helpers/platform';
|
import { getEntryPath, getEntryDirPath } from '../helpers/platform';
|
||||||
import { addVirtualEntry } from '../helpers/virtualModules';
|
import { addVirtualEntry } from '../helpers/virtualModules';
|
||||||
|
import { chainedSetAddAfter } from '../helpers/chain';
|
||||||
import { env as _env, IWebpackEnv } from '../index';
|
import { env as _env, IWebpackEnv } from '../index';
|
||||||
import base from './base';
|
import base from './base';
|
||||||
|
|
||||||
@ -21,9 +22,11 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
|||||||
`
|
`
|
||||||
);
|
);
|
||||||
|
|
||||||
config.entry('bundle').add(virtualEntryPath);
|
chainedSetAddAfter(
|
||||||
|
config.entry('bundle'),
|
||||||
// config.resolve.extensions.add('.xml');
|
'@nativescript/core/globals/index.js',
|
||||||
|
virtualEntryPath
|
||||||
|
);
|
||||||
|
|
||||||
// set up core HMR
|
// set up core HMR
|
||||||
config.module
|
config.module
|
||||||
|
@ -2,6 +2,7 @@ import Config from 'webpack-chain';
|
|||||||
|
|
||||||
import { getEntryDirPath, getEntryPath } from '../helpers/platform';
|
import { getEntryDirPath, getEntryPath } from '../helpers/platform';
|
||||||
import { addVirtualEntry } from '../helpers/virtualModules';
|
import { addVirtualEntry } from '../helpers/virtualModules';
|
||||||
|
import { chainedSetAddAfter } from '../helpers/chain';
|
||||||
import { env as _env, IWebpackEnv } from '../index';
|
import { env as _env, IWebpackEnv } from '../index';
|
||||||
import base from './base';
|
import base from './base';
|
||||||
|
|
||||||
@ -21,9 +22,11 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
|||||||
`
|
`
|
||||||
);
|
);
|
||||||
|
|
||||||
config.entry('bundle').add(virtualEntryPath);
|
chainedSetAddAfter(
|
||||||
|
config.entry('bundle'),
|
||||||
// config.resolve.extensions.add('.xml');
|
'@nativescript/core/globals/index.js',
|
||||||
|
virtualEntryPath
|
||||||
|
);
|
||||||
|
|
||||||
// set up core HMR
|
// set up core HMR
|
||||||
config.module
|
config.module
|
||||||
|
24
packages/webpack5/src/helpers/chain.ts
Normal file
24
packages/webpack5/src/helpers/chain.ts
Normal file
@ -0,0 +1,24 @@
|
|||||||
|
import { ChainedSet } from 'webpack-chain';
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Helper to insert values after a specific item in a ChainedSet.
|
||||||
|
*
|
||||||
|
* @param chainedSet
|
||||||
|
* @param after
|
||||||
|
* @param itemToAdd
|
||||||
|
*/
|
||||||
|
export function chainedSetAddAfter(
|
||||||
|
chainedSet: ChainedSet<any>,
|
||||||
|
after: any,
|
||||||
|
itemToAdd: any
|
||||||
|
) {
|
||||||
|
const values = chainedSet.values();
|
||||||
|
|
||||||
|
if (values.includes(after)) {
|
||||||
|
values.splice(values.indexOf(after) + 1, 0, itemToAdd);
|
||||||
|
} else {
|
||||||
|
values.push(itemToAdd);
|
||||||
|
}
|
||||||
|
|
||||||
|
chainedSet.clear().merge(values);
|
||||||
|
}
|
Reference in New Issue
Block a user