diff --git a/babel.config.js b/babel.config.js index 1c8d157f0..43e3d5c14 100644 --- a/babel.config.js +++ b/babel.config.js @@ -1,6 +1,6 @@ const path = require('path'); -const frameworkModulePath = path.resolve('./src/framework'); +const kittenPath = path.resolve('./src/framework'); // FIXME: Resolve `transform[stderr]: Could not resolve` command-line warnings. // FIXME: Reproducible when starting with clearing cache (npm start -- -c) @@ -8,8 +8,8 @@ const frameworkModulePath = path.resolve('./src/framework'); const moduleResolverConfig = { root: path.resolve('./'), alias: { - '@kitten/theme': path.resolve(frameworkModulePath, 'theme'), - '@kitten/ui': path.resolve(frameworkModulePath, 'ui'), + '@kitten/theme': path.resolve(kittenPath, 'theme'), + '@kitten/ui': path.resolve(kittenPath, 'ui'), }, }; diff --git a/src/framework/theme/support/tests/mapping.json b/src/framework/theme/support/tests/mapping.json index ea6cd16ae..2a66eff7e 100644 --- a/src/framework/theme/support/tests/mapping.json +++ b/src/framework/theme/support/tests/mapping.json @@ -1,4 +1,5 @@ { + "$schema": "../../../../../node_modules/@eva/core/schema/schema.json", "version": 1.0, "components": { "Radio": { diff --git a/src/framework/ui/support/tests/mapping.json b/src/framework/ui/support/tests/mapping.json index ebeed3dba..f8910bbe0 100644 --- a/src/framework/ui/support/tests/mapping.json +++ b/src/framework/ui/support/tests/mapping.json @@ -1,4 +1,5 @@ { + "$schema": "../../../../../node_modules/@eva/core/schema/schema.json", "version": 1.0, "components": { "Avatar": { diff --git a/src/playground/babel.config.js b/src/playground/babel.config.js index 6d01fa83a..0cb314552 100644 --- a/src/playground/babel.config.js +++ b/src/playground/babel.config.js @@ -1,19 +1,38 @@ const path = require('path'); -const frameworkModulePath = path.resolve('../framework'); +const kittenPath = path.resolve('../framework'); // FIXME: Resolve `transform[stderr]: Could not resolve` command-line warnings. // FIXME: Reproducible when starting with clearing cache (npm start -- -c) -const moduleResolverConfig = { - root: path.resolve('./'), - alias: { - '@kitten/theme': path.resolve(frameworkModulePath, 'theme'), - '@kitten/ui': path.resolve(frameworkModulePath, 'ui'), - }, +const productionConfig = { + mappingPath: path.resolve('./node_modules/@eva/eva'), + themePath: path.resolve('./node_modules/@eva/theme-eva'), }; -module.exports = function(api) { +const developmentConfig = { + mappingPath: path.resolve(__dirname, '../../../eva/packages/mapping/eva'), + themePath: path.resolve(__dirname, '../../../eva/packages/theme/eva'), +}; + +const environment = { + prod: productionConfig, + dev: developmentConfig, +}; + +function moduleResolverConfig(env) { + return { + root: path.resolve('./'), + alias: { + '@kitten/theme': path.resolve(kittenPath, 'theme'), + '@kitten/ui': path.resolve(kittenPath, 'ui'), + '@eva/eva': path.resolve(env.mappingPath), + '@eva/theme-eva': path.resolve(env.themePath), + }, + } +} + +module.exports = function (api) { api.cache(true); const presets = [ @@ -21,7 +40,7 @@ module.exports = function(api) { ]; const plugins = [ - ['module-resolver', moduleResolverConfig], + ['module-resolver', moduleResolverConfig(environment.prod)], ]; const devPlugins = [ diff --git a/src/playground/metro.config.js b/src/playground/metro.config.js index 509b361cb..ff5e09d45 100644 --- a/src/playground/metro.config.js +++ b/src/playground/metro.config.js @@ -1,11 +1,36 @@ const path = require('path'); +const kittenPath = path.resolve('../framework'); + +// FIXME: Resolve `transform[stderr]: Could not resolve` command-line warnings. +// FIXME: Reproducible when starting with clearing cache (npm start -- -c) + +const productionConfig = { + mappingPath: path.resolve('./node_modules/@eva/eva'), + themePath: path.resolve('./node_modules/@eva/theme-eva'), +}; + +const developmentConfig = { + mappingPath: path.resolve(__dirname, '../../../eva/packages/mapping/eva'), + themePath: path.resolve(__dirname, '../../../eva/packages/theme/eva'), +}; + +const environment = { + prod: productionConfig, + dev: developmentConfig, +}; + +function envWatchFolders(env) { + return [ + env.mappingPath, + env.themePath, + ]; +} + module.exports = { resolver: { extraNodeModules: { - // ... - // add needed-to-transform dependencies here - // + '@babel/runtime': path.resolve(__dirname, './node_modules/@babel/runtime'), 'react': path.resolve(__dirname, './node_modules/react'), 'react-native': path.resolve(__dirname, './node_modules/react-native'), }, @@ -20,13 +45,16 @@ module.exports = { }, projectRoot: path.resolve(__dirname), watchFolders: [ - path.resolve(__dirname, '../framework'), - path.resolve(__dirname, '../../node_modules/@babel'), + ...envWatchFolders(environment.prod), + path.resolve(kittenPath, 'ui'), + path.resolve(kittenPath, 'theme'), // FIXME(playground): unable to resolve - path.resolve(__dirname, '../../node_modules/@eva'), + path.resolve(__dirname, '../../node_modules/@eva/processor-kitten'), + path.resolve(__dirname, '../../node_modules/@babel'), path.resolve(__dirname, '../../node_modules/hoist-non-react-statics'), path.resolve(__dirname, '../../node_modules/react-is'), path.resolve(__dirname, '../../node_modules/lodash.merge'), ], }; + diff --git a/src/playground/tsconfig.json b/src/playground/tsconfig.json index e005948c7..ea4dd2c99 100644 --- a/src/playground/tsconfig.json +++ b/src/playground/tsconfig.json @@ -15,7 +15,8 @@ "es2016" ], "paths": { - "@eva/*": ["../../node_modules/eva/packages/*"], + "@eva/eva": ["../../../eva/packages/mapping/eva"], + "@eva/theme-eva": ["../../../eva/packages/theme/eva"], "@kitten/*": ["../framework/*"] } }