mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-16 03:31:45 +08:00
fix(webpack): exclude files starting with _ from require.context (#9596)
This commit is contained in:
@ -318,6 +318,10 @@ exports[`javascript configuration for android 1`] = `
|
||||
{
|
||||
'__jest__/src/__@nativescript_webpack_virtual_entry_javascript__': '// VIRTUAL ENTRY START\\\\nrequire(\\\\'@nativescript/core/bundle-entry-points\\\\')\\\\nconst context = require.context(\\"~/\\", /* deep: */ true, /* filter: */ /.(xml|js|s?css)$/);\\\\nglobal.registerWebpackModules(context);\\\\n// VIRTUAL ENTRY END'
|
||||
}
|
||||
),
|
||||
/* config.plugin('ContextExclusionPlugin|exclude_files') */
|
||||
new ContextExclusionPlugin(
|
||||
/\\\\b_.+\\\\./
|
||||
)
|
||||
],
|
||||
entry: {
|
||||
@ -651,6 +655,10 @@ exports[`javascript configuration for ios 1`] = `
|
||||
{
|
||||
'__jest__/src/__@nativescript_webpack_virtual_entry_javascript__': '// VIRTUAL ENTRY START\\\\nrequire(\\\\'@nativescript/core/bundle-entry-points\\\\')\\\\nconst context = require.context(\\"~/\\", /* deep: */ true, /* filter: */ /.(xml|js|s?css)$/);\\\\nglobal.registerWebpackModules(context);\\\\n// VIRTUAL ENTRY END'
|
||||
}
|
||||
),
|
||||
/* config.plugin('ContextExclusionPlugin|exclude_files') */
|
||||
new ContextExclusionPlugin(
|
||||
/\\\\b_.+\\\\./
|
||||
)
|
||||
],
|
||||
entry: {
|
||||
|
@ -318,6 +318,10 @@ exports[`typescript configuration for android 1`] = `
|
||||
{
|
||||
'__jest__/src/__@nativescript_webpack_virtual_entry_typescript__': '// VIRTUAL ENTRY START\\\\nrequire(\\\\'@nativescript/core/bundle-entry-points\\\\')\\\\nconst context = require.context(\\"~/\\", /* deep: */ true, /* filter: */ /\\\\\\\\.(xml|js|(?<!\\\\\\\\.d\\\\\\\\.)ts|s?css)$/);\\\\nglobal.registerWebpackModules(context);\\\\n// VIRTUAL ENTRY END'
|
||||
}
|
||||
),
|
||||
/* config.plugin('ContextExclusionPlugin|exclude_files') */
|
||||
new ContextExclusionPlugin(
|
||||
/\\\\b_.+\\\\./
|
||||
)
|
||||
],
|
||||
entry: {
|
||||
@ -651,6 +655,10 @@ exports[`typescript configuration for ios 1`] = `
|
||||
{
|
||||
'__jest__/src/__@nativescript_webpack_virtual_entry_typescript__': '// VIRTUAL ENTRY START\\\\nrequire(\\\\'@nativescript/core/bundle-entry-points\\\\')\\\\nconst context = require.context(\\"~/\\", /* deep: */ true, /* filter: */ /\\\\\\\\.(xml|js|(?<!\\\\\\\\.d\\\\\\\\.)ts|s?css)$/);\\\\nglobal.registerWebpackModules(context);\\\\n// VIRTUAL ENTRY END'
|
||||
}
|
||||
),
|
||||
/* config.plugin('ContextExclusionPlugin|exclude_files') */
|
||||
new ContextExclusionPlugin(
|
||||
/\\\\b_.+\\\\./
|
||||
)
|
||||
],
|
||||
entry: {
|
||||
|
@ -4,6 +4,7 @@ import { getEntryPath, getEntryDirPath } from '../helpers/platform';
|
||||
import { addVirtualEntry } from '../helpers/virtualModules';
|
||||
import { chainedSetAddAfter } from '../helpers/chain';
|
||||
import { env as _env, IWebpackEnv } from '../index';
|
||||
import { ContextExclusionPlugin } from 'webpack';
|
||||
import base from './base';
|
||||
|
||||
export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||
@ -22,6 +23,11 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||
`
|
||||
);
|
||||
|
||||
// exclude files starting with _ from require.context
|
||||
config
|
||||
.plugin(`ContextExclusionPlugin|exclude_files`)
|
||||
.use(ContextExclusionPlugin, [/\b_.+\./]);
|
||||
|
||||
chainedSetAddAfter(
|
||||
config.entry('bundle'),
|
||||
'@nativescript/core/globals/index.js',
|
||||
|
@ -4,6 +4,7 @@ import { getEntryDirPath, getEntryPath } from '../helpers/platform';
|
||||
import { addVirtualEntry } from '../helpers/virtualModules';
|
||||
import { chainedSetAddAfter } from '../helpers/chain';
|
||||
import { env as _env, IWebpackEnv } from '../index';
|
||||
import { ContextExclusionPlugin } from 'webpack';
|
||||
import base from './base';
|
||||
|
||||
export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||
@ -22,6 +23,11 @@ export default function (config: Config, env: IWebpackEnv = _env): Config {
|
||||
`
|
||||
);
|
||||
|
||||
// exclude files starting with _ from require.context
|
||||
config
|
||||
.plugin(`ContextExclusionPlugin|exclude_files`)
|
||||
.use(ContextExclusionPlugin, [/\b_.+\./]);
|
||||
|
||||
chainedSetAddAfter(
|
||||
config.entry('bundle'),
|
||||
'@nativescript/core/globals/index.js',
|
||||
|
Reference in New Issue
Block a user