Skip to content

Commit

Permalink
build(common): setup playground to watch eva changes
Browse files Browse the repository at this point in the history
  • Loading branch information
artyorsh authored May 17, 2019
1 parent 4410486 commit 1e0b287
Show file tree
Hide file tree
Showing 6 changed files with 69 additions and 19 deletions.
6 changes: 3 additions & 3 deletions babel.config.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
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)

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'),
},
};

Expand Down
1 change: 1 addition & 0 deletions src/framework/theme/support/tests/mapping.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "../../../../../node_modules/@eva/core/schema/schema.json",
"version": 1.0,
"components": {
"Radio": {
Expand Down
1 change: 1 addition & 0 deletions src/framework/ui/support/tests/mapping.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{
"$schema": "../../../../../node_modules/@eva/core/schema/schema.json",
"version": 1.0,
"components": {
"Avatar": {
Expand Down
37 changes: 28 additions & 9 deletions src/playground/babel.config.js
Original file line number Diff line number Diff line change
@@ -1,27 +1,46 @@
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 = [
'babel-preset-expo',
];

const plugins = [
['module-resolver', moduleResolverConfig],
['module-resolver', moduleResolverConfig(environment.prod)],
];

const devPlugins = [
Expand Down
40 changes: 34 additions & 6 deletions src/playground/metro.config.js
Original file line number Diff line number Diff line change
@@ -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'),
},
Expand All @@ -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'),
],
};

3 changes: 2 additions & 1 deletion src/playground/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -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/*"]
}
}
Expand Down

0 comments on commit 1e0b287

Please sign in to comment.