mirror of
https://github.com/NativeScript/NativeScript.git
synced 2025-08-18 22:01:42 +08:00
chore: rename things
This commit is contained in:

committed by
Nathan Walker

parent
8f951439e3
commit
ae12ee9324
@ -1,6 +1,6 @@
|
|||||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||||
|
|
||||||
exports[`react configuration for android 1`] = `
|
exports[`react configuration > android > adds ReactRefreshWebpackPlugin when HMR enabled 1`] = `
|
||||||
"{
|
"{
|
||||||
mode: 'development',
|
mode: 'development',
|
||||||
resolve: {
|
resolve: {
|
||||||
@ -142,7 +142,142 @@ exports[`react configuration for android 1`] = `
|
|||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
exports[`react configuration for ios 1`] = `
|
exports[`react configuration > android > base config 1`] = `
|
||||||
|
"{
|
||||||
|
mode: 'development',
|
||||||
|
resolve: {
|
||||||
|
symlinks: true,
|
||||||
|
alias: {
|
||||||
|
'~/package.json': 'package.json',
|
||||||
|
'~': '<TODO>appFullPath',
|
||||||
|
'@': '<TODO>appFullPath',
|
||||||
|
'react-dom': 'react-nativescript'
|
||||||
|
},
|
||||||
|
extensions: [
|
||||||
|
'.tsx'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
resolveLoader: {
|
||||||
|
modules: [
|
||||||
|
'@nativescript/webpack/loaders',
|
||||||
|
'node_modules'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
/* config.module.rule('ts') */
|
||||||
|
{
|
||||||
|
test: [
|
||||||
|
/\\\\.ts$/,
|
||||||
|
/\\\\.tsx$/
|
||||||
|
],
|
||||||
|
use: [
|
||||||
|
/* config.module.rule('ts').use('babel-loader|react-refresh') */
|
||||||
|
{
|
||||||
|
loader: 'babel-loader',
|
||||||
|
options: {
|
||||||
|
sourceMaps: 'inline',
|
||||||
|
babelrc: false,
|
||||||
|
plugins: [
|
||||||
|
'react-refresh/babel'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/* 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$/,
|
||||||
|
use: [
|
||||||
|
/* config.module.rule('js').use('babel-loader') */
|
||||||
|
{
|
||||||
|
loader: 'babel-loader'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
/* config.module.rule('css') */
|
||||||
|
{
|
||||||
|
test: /\\\\.css$/,
|
||||||
|
use: [
|
||||||
|
/* config.module.rule('css').use('css2json-loader') */
|
||||||
|
{
|
||||||
|
loader: 'css2json-loader'
|
||||||
|
},
|
||||||
|
/* config.module.rule('css').use('css-loader') */
|
||||||
|
{
|
||||||
|
loader: 'css-loader'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
/* config.module.rule('scss') */
|
||||||
|
{
|
||||||
|
test: /\\\\.scss$/,
|
||||||
|
use: [
|
||||||
|
/* config.module.rule('scss').use('css2json-loader') */
|
||||||
|
{
|
||||||
|
loader: 'css2json-loader'
|
||||||
|
},
|
||||||
|
/* config.module.rule('scss').use('scss-loader') */
|
||||||
|
{
|
||||||
|
loader: 'scss-loader'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
/* config.plugin('CleanWebpackPlugin') */
|
||||||
|
new CleanWebpackPlugin(
|
||||||
|
{
|
||||||
|
cleanOnceBeforeBuildPatterns: [
|
||||||
|
'platforms/android/app/src/main/assets/app/**/*'
|
||||||
|
],
|
||||||
|
verbose: true
|
||||||
|
}
|
||||||
|
),
|
||||||
|
/* config.plugin('DefinePlugin') */
|
||||||
|
new DefinePlugin(
|
||||||
|
{
|
||||||
|
'global.NS_WEBPACK': true,
|
||||||
|
'global.isAndroid': true,
|
||||||
|
'global.isIOS': false,
|
||||||
|
process: 'global.process',
|
||||||
|
__DEV__: 'true',
|
||||||
|
__TEST__: 'false',
|
||||||
|
'process.env.NODE_ENV': '\\"development\\"'
|
||||||
|
}
|
||||||
|
),
|
||||||
|
/* config.plugin('CopyWebpackPlugin') */
|
||||||
|
new CopyPluginTemp(
|
||||||
|
{
|
||||||
|
patterns: []
|
||||||
|
}
|
||||||
|
),
|
||||||
|
/* config.plugin('WatchStateLoggerPlugin') */
|
||||||
|
new WatchStateLoggerPlugin()
|
||||||
|
],
|
||||||
|
entry: {
|
||||||
|
bundle: [
|
||||||
|
'todo/main'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
|
||||||
|
exports[`react configuration > ios > adds ReactRefreshWebpackPlugin when HMR enabled 1`] = `
|
||||||
"{
|
"{
|
||||||
mode: 'development',
|
mode: 'development',
|
||||||
resolve: {
|
resolve: {
|
||||||
@ -286,3 +421,141 @@ exports[`react configuration for ios 1`] = `
|
|||||||
}
|
}
|
||||||
}"
|
}"
|
||||||
`;
|
`;
|
||||||
|
|
||||||
|
exports[`react configuration > ios > base config 1`] = `
|
||||||
|
"{
|
||||||
|
mode: 'development',
|
||||||
|
resolve: {
|
||||||
|
symlinks: true,
|
||||||
|
alias: {
|
||||||
|
'~/package.json': 'package.json',
|
||||||
|
'~': '<TODO>appFullPath',
|
||||||
|
'@': '<TODO>appFullPath',
|
||||||
|
'react-dom': 'react-nativescript'
|
||||||
|
},
|
||||||
|
extensions: [
|
||||||
|
'.tsx'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
resolveLoader: {
|
||||||
|
modules: [
|
||||||
|
'@nativescript/webpack/loaders',
|
||||||
|
'node_modules'
|
||||||
|
]
|
||||||
|
},
|
||||||
|
module: {
|
||||||
|
rules: [
|
||||||
|
/* config.module.rule('ts') */
|
||||||
|
{
|
||||||
|
test: [
|
||||||
|
/\\\\.ts$/,
|
||||||
|
/\\\\.tsx$/
|
||||||
|
],
|
||||||
|
use: [
|
||||||
|
/* config.module.rule('ts').use('babel-loader|react-refresh') */
|
||||||
|
{
|
||||||
|
loader: 'babel-loader',
|
||||||
|
options: {
|
||||||
|
sourceMaps: 'inline',
|
||||||
|
babelrc: false,
|
||||||
|
plugins: [
|
||||||
|
'react-refresh/babel'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/* 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$/,
|
||||||
|
use: [
|
||||||
|
/* config.module.rule('js').use('babel-loader') */
|
||||||
|
{
|
||||||
|
loader: 'babel-loader'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
/* config.module.rule('css') */
|
||||||
|
{
|
||||||
|
test: /\\\\.css$/,
|
||||||
|
use: [
|
||||||
|
/* config.module.rule('css').use('css2json-loader') */
|
||||||
|
{
|
||||||
|
loader: 'css2json-loader'
|
||||||
|
},
|
||||||
|
/* config.module.rule('css').use('css-loader') */
|
||||||
|
{
|
||||||
|
loader: 'css-loader'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
/* config.module.rule('scss') */
|
||||||
|
{
|
||||||
|
test: /\\\\.scss$/,
|
||||||
|
use: [
|
||||||
|
/* config.module.rule('scss').use('css2json-loader') */
|
||||||
|
{
|
||||||
|
loader: 'css2json-loader'
|
||||||
|
},
|
||||||
|
/* config.module.rule('scss').use('scss-loader') */
|
||||||
|
{
|
||||||
|
loader: 'scss-loader'
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
plugins: [
|
||||||
|
/* config.plugin('CleanWebpackPlugin') */
|
||||||
|
new CleanWebpackPlugin(
|
||||||
|
{
|
||||||
|
cleanOnceBeforeBuildPatterns: [
|
||||||
|
'platforms/ios/[todo]/app/**/*'
|
||||||
|
],
|
||||||
|
verbose: true
|
||||||
|
}
|
||||||
|
),
|
||||||
|
/* config.plugin('DefinePlugin') */
|
||||||
|
new DefinePlugin(
|
||||||
|
{
|
||||||
|
'global.NS_WEBPACK': true,
|
||||||
|
'global.isAndroid': false,
|
||||||
|
'global.isIOS': true,
|
||||||
|
process: 'global.process',
|
||||||
|
__DEV__: 'true',
|
||||||
|
__TEST__: 'false',
|
||||||
|
'process.env.NODE_ENV': '\\"development\\"'
|
||||||
|
}
|
||||||
|
),
|
||||||
|
/* config.plugin('CopyWebpackPlugin') */
|
||||||
|
new CopyPluginTemp(
|
||||||
|
{
|
||||||
|
patterns: []
|
||||||
|
}
|
||||||
|
),
|
||||||
|
/* config.plugin('WatchStateLoggerPlugin') */
|
||||||
|
new WatchStateLoggerPlugin()
|
||||||
|
],
|
||||||
|
entry: {
|
||||||
|
inspector_modules: [
|
||||||
|
'tns_modules/@nativescript/core/inspector_modules'
|
||||||
|
],
|
||||||
|
bundle: [
|
||||||
|
'todo/main'
|
||||||
|
]
|
||||||
|
}
|
||||||
|
}"
|
||||||
|
`;
|
||||||
|
@ -10,12 +10,23 @@ describe('react configuration', () => {
|
|||||||
const platforms = ['ios', 'android'];
|
const platforms = ['ios', 'android'];
|
||||||
|
|
||||||
for (let platform of platforms) {
|
for (let platform of platforms) {
|
||||||
it(`for ${platform}`, () => {
|
describe(`> ${platform} >`, () => {
|
||||||
expect(
|
it(`base config`, () => {
|
||||||
__react({
|
expect(
|
||||||
[platform]: true,
|
__react({
|
||||||
}).toString()
|
[platform]: true,
|
||||||
).toMatchSnapshot();
|
}).toString()
|
||||||
|
).toMatchSnapshot();
|
||||||
|
});
|
||||||
|
|
||||||
|
it(`adds ReactRefreshWebpackPlugin when HMR enabled`, () => {
|
||||||
|
expect(
|
||||||
|
__react({
|
||||||
|
[platform]: true,
|
||||||
|
hmr: true,
|
||||||
|
}).toString()
|
||||||
|
).toMatchSnapshot();
|
||||||
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
@ -41,22 +41,24 @@ export default function (env: IWebpackEnv): Config {
|
|||||||
return args;
|
return args;
|
||||||
});
|
});
|
||||||
|
|
||||||
// todo: conditional + env flag to forceEnable?
|
// todo: env flag to forceEnable?
|
||||||
config.plugin('ReactRefreshWebpackPlugin').use(function ReactRefreshWebpackPlugin() {}, [
|
config.when(env.hmr && !production, (config) => {
|
||||||
{
|
config.plugin('ReactRefreshWebpackPlugin').use(function ReactRefreshWebpackPlugin() {}, [
|
||||||
/**
|
{
|
||||||
* Maybe one day we'll implement an Error Overlay, but the work involved is too daunting for now.
|
/**
|
||||||
* @see https://github.com/pmmmwh/react-refresh-webpack-plugin/issues/79#issuecomment-644324557
|
* Maybe one day we'll implement an Error Overlay, but the work involved is too daunting for now.
|
||||||
*/
|
* @see https://github.com/pmmmwh/react-refresh-webpack-plugin/issues/79#issuecomment-644324557
|
||||||
overlay: false,
|
*/
|
||||||
/**
|
overlay: false,
|
||||||
* If you (temporarily) want to enable HMR on a production build:
|
/**
|
||||||
* 1) Set `forceEnable` to `true`
|
* If you (temporarily) want to enable HMR on a production build:
|
||||||
* 2) Remove the `!production` condition on `tsxRule` to ensure that babel-loader gets used.
|
* 1) Set `forceEnable` to `true`
|
||||||
*/
|
* 2) Remove the `!production` condition on `tsxRule` to ensure that babel-loader gets used.
|
||||||
forceEnable: false,
|
*/
|
||||||
},
|
forceEnable: false,
|
||||||
]);
|
},
|
||||||
|
]);
|
||||||
|
});
|
||||||
|
|
||||||
return config;
|
return config;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user