mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-11-05 13:26:48 +08:00
feat: add entryDir helper + update aliases
This commit is contained in:
committed by
Nathan Walker
parent
c9455e67ad
commit
d537fa0e6a
@@ -19,8 +19,8 @@ exports[`angular configuration for android 1`] = `
|
||||
resolve: {
|
||||
symlinks: true,
|
||||
alias: {
|
||||
'~': '<TODO>appFullPath',
|
||||
'@': '<TODO>appFullPath'
|
||||
'~': '__jest__/src',
|
||||
'@': '__jest__/src'
|
||||
},
|
||||
extensions: [
|
||||
'.android.ts',
|
||||
@@ -251,8 +251,8 @@ exports[`angular configuration for ios 1`] = `
|
||||
resolve: {
|
||||
symlinks: true,
|
||||
alias: {
|
||||
'~': '<TODO>appFullPath',
|
||||
'@': '<TODO>appFullPath'
|
||||
'~': '__jest__/src',
|
||||
'@': '__jest__/src'
|
||||
},
|
||||
extensions: [
|
||||
'.ios.ts',
|
||||
|
||||
@@ -0,0 +1,470 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`javascript configuration for android 1`] = `
|
||||
"{
|
||||
mode: 'development',
|
||||
externals: [
|
||||
'package.json',
|
||||
'~/package.json'
|
||||
],
|
||||
devtool: 'inline-source-map',
|
||||
target: 'node',
|
||||
output: {
|
||||
path: '__jest__/platforms/android/app/src/main/assets/app',
|
||||
pathinfo: false,
|
||||
publicPath: '',
|
||||
libraryTarget: 'commonjs',
|
||||
globalObject: 'global'
|
||||
},
|
||||
resolve: {
|
||||
symlinks: true,
|
||||
alias: {
|
||||
'~': '__jest__/src',
|
||||
'@': '__jest__/src'
|
||||
},
|
||||
extensions: [
|
||||
'.android.ts',
|
||||
'.ts',
|
||||
'.android.js',
|
||||
'.js',
|
||||
'.android.css',
|
||||
'.css',
|
||||
'.android.scss',
|
||||
'.scss',
|
||||
'.android.json',
|
||||
'.json'
|
||||
]
|
||||
},
|
||||
resolveLoader: {
|
||||
modules: [
|
||||
'node_modules/@nativescript/webpack/dist/loaders',
|
||||
'node_modules'
|
||||
]
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
/* config.module.rule('ts') */
|
||||
{
|
||||
test: [
|
||||
/\\\\.ts$/
|
||||
],
|
||||
use: [
|
||||
/* config.module.rule('ts').use('ts-loader') */
|
||||
{
|
||||
loader: 'ts-loader',
|
||||
options: {
|
||||
transpileOnly: true,
|
||||
allowTsInNodeModules: true,
|
||||
compilerOptions: {
|
||||
sourceMap: true,
|
||||
declaration: false
|
||||
},
|
||||
getCustomTransformers: function () { /* omitted long function */ }
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
/* config.module.rule('js') */
|
||||
{
|
||||
test: /\\\\.js$/,
|
||||
exclude: [
|
||||
/node_modules/
|
||||
],
|
||||
use: [
|
||||
/* config.module.rule('js').use('babel-loader') */
|
||||
{
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
generatorOpts: {
|
||||
compact: false
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
/* config.module.rule('css') */
|
||||
{
|
||||
test: /\\\\.css$/,
|
||||
use: [
|
||||
/* config.module.rule('css').use('apply-css-loader') */
|
||||
{
|
||||
loader: 'apply-css-loader'
|
||||
},
|
||||
/* config.module.rule('css').use('css2json-loader') */
|
||||
{
|
||||
loader: 'css2json-loader'
|
||||
}
|
||||
]
|
||||
},
|
||||
/* config.module.rule('scss') */
|
||||
{
|
||||
test: /\\\\.scss$/,
|
||||
use: [
|
||||
/* config.module.rule('scss').use('apply-css-loader') */
|
||||
{
|
||||
loader: 'apply-css-loader'
|
||||
},
|
||||
/* config.module.rule('scss').use('css2json-loader') */
|
||||
{
|
||||
loader: 'css2json-loader'
|
||||
},
|
||||
/* config.module.rule('scss').use('sass-loader') */
|
||||
{
|
||||
loader: 'sass-loader'
|
||||
}
|
||||
]
|
||||
},
|
||||
/* config.module.rule('xml') */
|
||||
{
|
||||
test: /\\\\.xml$/,
|
||||
use: [
|
||||
/* config.module.rule('xml').use('xml-namespace-loader') */
|
||||
{
|
||||
loader: 'xml-namespace-loader'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
optimization: {
|
||||
splitChunks: {
|
||||
cacheGroups: {
|
||||
defaultVendor: {
|
||||
test: /[\\\\\\\\/]node_modules[\\\\\\\\/]/,
|
||||
priority: -10,
|
||||
name: 'vendor',
|
||||
chunks: 'all'
|
||||
}
|
||||
}
|
||||
},
|
||||
minimizer: [
|
||||
/* config.optimization.minimizer('TerserPlugin') */
|
||||
new TerserPlugin(
|
||||
{
|
||||
terserOptions: {
|
||||
compress: {
|
||||
collapse_vars: false,
|
||||
sequences: false
|
||||
},
|
||||
keep_fnames: true
|
||||
}
|
||||
}
|
||||
)
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
/* config.plugin('ForkTsCheckerWebpackPlugin') */
|
||||
new ForkTsCheckerWebpackPlugin(
|
||||
{
|
||||
typescript: {
|
||||
memoryLimit: 4096
|
||||
}
|
||||
}
|
||||
),
|
||||
/* config.plugin('CleanWebpackPlugin') */
|
||||
new CleanWebpackPlugin(
|
||||
{
|
||||
cleanOnceBeforeBuildPatterns: [
|
||||
'__jest__/platforms/android/app/src/main/assets/app/**/*'
|
||||
],
|
||||
verbose: false
|
||||
}
|
||||
),
|
||||
/* config.plugin('DefinePlugin') */
|
||||
new DefinePlugin(
|
||||
{
|
||||
__DEV__: true,
|
||||
__NS_WEBPACK__: true,
|
||||
__CSS_PARSER__: '\\"css-tree\\"',
|
||||
__ANDROID__: true,
|
||||
__IOS__: false,
|
||||
'global.isAndroid': true,
|
||||
'global.isIOS': false,
|
||||
process: 'global.process'
|
||||
}
|
||||
),
|
||||
/* config.plugin('CopyWebpackPlugin') */
|
||||
new CopyPlugin(
|
||||
{
|
||||
patterns: [
|
||||
{
|
||||
from: 'assets/**',
|
||||
context: '__jest__/src',
|
||||
noErrorOnMissing: true,
|
||||
globOptions: {
|
||||
dot: false
|
||||
}
|
||||
},
|
||||
{
|
||||
from: 'fonts/**',
|
||||
context: '__jest__/src',
|
||||
noErrorOnMissing: true,
|
||||
globOptions: {
|
||||
dot: false
|
||||
}
|
||||
},
|
||||
{
|
||||
from: '**/*.+(jpg|png)',
|
||||
context: '__jest__/src',
|
||||
noErrorOnMissing: true,
|
||||
globOptions: {
|
||||
dot: false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
),
|
||||
/* config.plugin('WatchStatePlugin') */
|
||||
new WatchStatePlugin(),
|
||||
/* config.plugin('VirtualModulesPlugin') */
|
||||
new VirtualModulesPlugin(
|
||||
{
|
||||
'__jest__/src/__virtual_entry__.js': 'require(\\\\'@nativescript/core/bundle-entry-points\\\\')\\\\nconst context = require.context(\\"~/\\", /* deep: */ true, /* filter: */ /.(xml|js)$/);\\\\nglobal.registerWebpackModules(context);'
|
||||
}
|
||||
)
|
||||
],
|
||||
entry: {
|
||||
bundle: [
|
||||
'@nativescript/core/globals/index.js',
|
||||
'__jest__/src/app.js',
|
||||
'__jest__/src/__virtual_entry__.js'
|
||||
]
|
||||
}
|
||||
}"
|
||||
`;
|
||||
|
||||
exports[`javascript configuration for ios 1`] = `
|
||||
"{
|
||||
mode: 'development',
|
||||
externals: [
|
||||
'package.json',
|
||||
'~/package.json'
|
||||
],
|
||||
devtool: 'inline-source-map',
|
||||
target: 'node',
|
||||
output: {
|
||||
path: '__jest__/platforms/ios/__jest__/app',
|
||||
pathinfo: false,
|
||||
publicPath: '',
|
||||
libraryTarget: 'commonjs',
|
||||
globalObject: 'global'
|
||||
},
|
||||
resolve: {
|
||||
symlinks: true,
|
||||
alias: {
|
||||
'~': '__jest__/src',
|
||||
'@': '__jest__/src'
|
||||
},
|
||||
extensions: [
|
||||
'.ios.ts',
|
||||
'.ts',
|
||||
'.ios.js',
|
||||
'.js',
|
||||
'.ios.css',
|
||||
'.css',
|
||||
'.ios.scss',
|
||||
'.scss',
|
||||
'.ios.json',
|
||||
'.json'
|
||||
]
|
||||
},
|
||||
resolveLoader: {
|
||||
modules: [
|
||||
'node_modules/@nativescript/webpack/dist/loaders',
|
||||
'node_modules'
|
||||
]
|
||||
},
|
||||
module: {
|
||||
rules: [
|
||||
/* config.module.rule('ts') */
|
||||
{
|
||||
test: [
|
||||
/\\\\.ts$/
|
||||
],
|
||||
use: [
|
||||
/* config.module.rule('ts').use('ts-loader') */
|
||||
{
|
||||
loader: 'ts-loader',
|
||||
options: {
|
||||
transpileOnly: true,
|
||||
allowTsInNodeModules: true,
|
||||
compilerOptions: {
|
||||
sourceMap: true,
|
||||
declaration: false
|
||||
},
|
||||
getCustomTransformers: function () { /* omitted long function */ }
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
/* config.module.rule('js') */
|
||||
{
|
||||
test: /\\\\.js$/,
|
||||
exclude: [
|
||||
/node_modules/
|
||||
],
|
||||
use: [
|
||||
/* config.module.rule('js').use('babel-loader') */
|
||||
{
|
||||
loader: 'babel-loader',
|
||||
options: {
|
||||
generatorOpts: {
|
||||
compact: false
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
},
|
||||
/* config.module.rule('css') */
|
||||
{
|
||||
test: /\\\\.css$/,
|
||||
use: [
|
||||
/* config.module.rule('css').use('apply-css-loader') */
|
||||
{
|
||||
loader: 'apply-css-loader'
|
||||
},
|
||||
/* config.module.rule('css').use('css2json-loader') */
|
||||
{
|
||||
loader: 'css2json-loader'
|
||||
}
|
||||
]
|
||||
},
|
||||
/* config.module.rule('scss') */
|
||||
{
|
||||
test: /\\\\.scss$/,
|
||||
use: [
|
||||
/* config.module.rule('scss').use('apply-css-loader') */
|
||||
{
|
||||
loader: 'apply-css-loader'
|
||||
},
|
||||
/* config.module.rule('scss').use('css2json-loader') */
|
||||
{
|
||||
loader: 'css2json-loader'
|
||||
},
|
||||
/* config.module.rule('scss').use('sass-loader') */
|
||||
{
|
||||
loader: 'sass-loader'
|
||||
}
|
||||
]
|
||||
},
|
||||
/* config.module.rule('xml') */
|
||||
{
|
||||
test: /\\\\.xml$/,
|
||||
use: [
|
||||
/* config.module.rule('xml').use('xml-namespace-loader') */
|
||||
{
|
||||
loader: 'xml-namespace-loader'
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
},
|
||||
optimization: {
|
||||
splitChunks: {
|
||||
cacheGroups: {
|
||||
defaultVendor: {
|
||||
test: /[\\\\\\\\/]node_modules[\\\\\\\\/]/,
|
||||
priority: -10,
|
||||
name: 'vendor',
|
||||
chunks: 'all'
|
||||
}
|
||||
}
|
||||
},
|
||||
minimizer: [
|
||||
/* config.optimization.minimizer('TerserPlugin') */
|
||||
new TerserPlugin(
|
||||
{
|
||||
terserOptions: {
|
||||
compress: {
|
||||
collapse_vars: true,
|
||||
sequences: true
|
||||
},
|
||||
keep_fnames: true
|
||||
}
|
||||
}
|
||||
)
|
||||
]
|
||||
},
|
||||
plugins: [
|
||||
/* config.plugin('ForkTsCheckerWebpackPlugin') */
|
||||
new ForkTsCheckerWebpackPlugin(
|
||||
{
|
||||
typescript: {
|
||||
memoryLimit: 4096
|
||||
}
|
||||
}
|
||||
),
|
||||
/* config.plugin('CleanWebpackPlugin') */
|
||||
new CleanWebpackPlugin(
|
||||
{
|
||||
cleanOnceBeforeBuildPatterns: [
|
||||
'__jest__/platforms/ios/__jest__/app/**/*'
|
||||
],
|
||||
verbose: false
|
||||
}
|
||||
),
|
||||
/* config.plugin('DefinePlugin') */
|
||||
new DefinePlugin(
|
||||
{
|
||||
__DEV__: true,
|
||||
__NS_WEBPACK__: true,
|
||||
__CSS_PARSER__: '\\"css-tree\\"',
|
||||
__ANDROID__: false,
|
||||
__IOS__: true,
|
||||
'global.isAndroid': false,
|
||||
'global.isIOS': true,
|
||||
process: 'global.process'
|
||||
}
|
||||
),
|
||||
/* config.plugin('CopyWebpackPlugin') */
|
||||
new CopyPlugin(
|
||||
{
|
||||
patterns: [
|
||||
{
|
||||
from: 'assets/**',
|
||||
context: '__jest__/src',
|
||||
noErrorOnMissing: true,
|
||||
globOptions: {
|
||||
dot: false
|
||||
}
|
||||
},
|
||||
{
|
||||
from: 'fonts/**',
|
||||
context: '__jest__/src',
|
||||
noErrorOnMissing: true,
|
||||
globOptions: {
|
||||
dot: false
|
||||
}
|
||||
},
|
||||
{
|
||||
from: '**/*.+(jpg|png)',
|
||||
context: '__jest__/src',
|
||||
noErrorOnMissing: true,
|
||||
globOptions: {
|
||||
dot: false
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
||||
),
|
||||
/* config.plugin('WatchStatePlugin') */
|
||||
new WatchStatePlugin(),
|
||||
/* config.plugin('VirtualModulesPlugin') */
|
||||
new VirtualModulesPlugin(
|
||||
{
|
||||
'__jest__/src/__virtual_entry__.js': 'require(\\\\'@nativescript/core/bundle-entry-points\\\\')\\\\nconst context = require.context(\\"~/\\", /* deep: */ true, /* filter: */ /.(xml|js)$/);\\\\nglobal.registerWebpackModules(context);'
|
||||
}
|
||||
)
|
||||
],
|
||||
entry: {
|
||||
bundle: [
|
||||
'@nativescript/core/globals/index.js',
|
||||
'__jest__/src/app.js',
|
||||
'__jest__/src/__virtual_entry__.js'
|
||||
],
|
||||
'tns_modules/@nativescript/core/inspector_modules': [
|
||||
'@nativescript/core/inspector_modules'
|
||||
]
|
||||
}
|
||||
}"
|
||||
`;
|
||||
@@ -19,8 +19,8 @@ exports[`react configuration > android > adds ReactRefreshWebpackPlugin when HMR
|
||||
resolve: {
|
||||
symlinks: true,
|
||||
alias: {
|
||||
'~': '<TODO>appFullPath',
|
||||
'@': '<TODO>appFullPath',
|
||||
'~': '__jest__/src',
|
||||
'@': '__jest__/src',
|
||||
'react-dom': 'react-nativescript'
|
||||
},
|
||||
extensions: [
|
||||
@@ -263,8 +263,8 @@ exports[`react configuration > android > base config 1`] = `
|
||||
resolve: {
|
||||
symlinks: true,
|
||||
alias: {
|
||||
'~': '<TODO>appFullPath',
|
||||
'@': '<TODO>appFullPath',
|
||||
'~': '__jest__/src',
|
||||
'@': '__jest__/src',
|
||||
'react-dom': 'react-nativescript'
|
||||
},
|
||||
extensions: [
|
||||
@@ -485,8 +485,8 @@ exports[`react configuration > ios > adds ReactRefreshWebpackPlugin when HMR ena
|
||||
resolve: {
|
||||
symlinks: true,
|
||||
alias: {
|
||||
'~': '<TODO>appFullPath',
|
||||
'@': '<TODO>appFullPath',
|
||||
'~': '__jest__/src',
|
||||
'@': '__jest__/src',
|
||||
'react-dom': 'react-nativescript'
|
||||
},
|
||||
extensions: [
|
||||
@@ -732,8 +732,8 @@ exports[`react configuration > ios > base config 1`] = `
|
||||
resolve: {
|
||||
symlinks: true,
|
||||
alias: {
|
||||
'~': '<TODO>appFullPath',
|
||||
'@': '<TODO>appFullPath',
|
||||
'~': '__jest__/src',
|
||||
'@': '__jest__/src',
|
||||
'react-dom': 'react-nativescript'
|
||||
},
|
||||
extensions: [
|
||||
|
||||
@@ -19,8 +19,8 @@ exports[`svelte configuration for android 1`] = `
|
||||
resolve: {
|
||||
symlinks: true,
|
||||
alias: {
|
||||
'~': '<TODO>appFullPath',
|
||||
'@': '<TODO>appFullPath'
|
||||
'~': '__jest__/src',
|
||||
'@': '__jest__/src'
|
||||
},
|
||||
extensions: [
|
||||
'.android.svelte',
|
||||
@@ -265,8 +265,8 @@ exports[`svelte configuration for ios 1`] = `
|
||||
resolve: {
|
||||
symlinks: true,
|
||||
alias: {
|
||||
'~': '<TODO>appFullPath',
|
||||
'@': '<TODO>appFullPath'
|
||||
'~': '__jest__/src',
|
||||
'@': '__jest__/src'
|
||||
},
|
||||
extensions: [
|
||||
'.ios.svelte',
|
||||
|
||||
@@ -19,8 +19,8 @@ exports[`vue configuration for android 1`] = `
|
||||
resolve: {
|
||||
symlinks: true,
|
||||
alias: {
|
||||
'~': '<TODO>appFullPath',
|
||||
'@': '<TODO>appFullPath',
|
||||
'~': '__jest__/src',
|
||||
'@': '__jest__/src',
|
||||
vue: 'nativescript-vue'
|
||||
},
|
||||
extensions: [
|
||||
@@ -267,8 +267,8 @@ exports[`vue configuration for ios 1`] = `
|
||||
resolve: {
|
||||
symlinks: true,
|
||||
alias: {
|
||||
'~': '<TODO>appFullPath',
|
||||
'@': '<TODO>appFullPath',
|
||||
'~': '__jest__/src',
|
||||
'@': '__jest__/src',
|
||||
vue: 'nativescript-vue'
|
||||
},
|
||||
extensions: [
|
||||
|
||||
17
packages/webpack5/__tests__/configuration/javascript.spec.ts
Normal file
17
packages/webpack5/__tests__/configuration/javascript.spec.ts
Normal file
@@ -0,0 +1,17 @@
|
||||
// @ts-ignore
|
||||
import Config from 'webpack-chain';
|
||||
import javascript from '../../src/configuration/javascript';
|
||||
import { init } from '../../src';
|
||||
|
||||
describe.only('javascript configuration', () => {
|
||||
const platforms = ['ios', 'android'];
|
||||
|
||||
for (let platform of platforms) {
|
||||
it(`for ${platform}`, () => {
|
||||
init({
|
||||
[platform]: true,
|
||||
});
|
||||
expect(javascript(new Config()).toString()).toMatchSnapshot();
|
||||
});
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user