mirror of https://github.com/embarklabs/embark.git
pipeline.js dapp config to allow easy toggling of typescript
This commit is contained in:
parent
6534c30200
commit
059635979d
|
@ -20,8 +20,9 @@ const embarkPath = process.env.EMBARK_PATH;
|
||||||
|
|
||||||
const embarkAliases = require(path.join(dappPath, '.embark/embark-aliases.json'));
|
const embarkAliases = require(path.join(dappPath, '.embark/embark-aliases.json'));
|
||||||
const embarkAssets = require(path.join(dappPath, '.embark/embark-assets.json'));
|
const embarkAssets = require(path.join(dappPath, '.embark/embark-assets.json'));
|
||||||
const embarkNodeModules = path.join(embarkPath, 'node_modules');
|
|
||||||
const embarkJson = require(path.join(dappPath, 'embark.json'));
|
const embarkJson = require(path.join(dappPath, 'embark.json'));
|
||||||
|
const embarkNodeModules = path.join(embarkPath, 'node_modules');
|
||||||
|
const embarkPipeline = require(path.join(dappPath, '.embark/embark-pipeline.json'));
|
||||||
|
|
||||||
const buildDir = path.join(dappPath, embarkJson.buildDir);
|
const buildDir = path.join(dappPath, embarkJson.buildDir);
|
||||||
|
|
||||||
|
@ -192,7 +193,7 @@ const baseBabelLoader = base.module.rules[3];
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
// should be false in configs that have isTypeScriptEnabled = true
|
// should be false in configs that have isTypeScriptEnabled = true
|
||||||
const isFlowEnabled = true;
|
const isFlowEnabled = !embarkPipeline.typescript;
|
||||||
if (isFlowEnabled) {
|
if (isFlowEnabled) {
|
||||||
// position @babel/plugin-transform-flow-strip-types per babel-preset-react-app
|
// position @babel/plugin-transform-flow-strip-types per babel-preset-react-app
|
||||||
baseBabelLoader.options.plugins.unshift(
|
baseBabelLoader.options.plugins.unshift(
|
||||||
|
@ -204,7 +205,7 @@ if (isFlowEnabled) {
|
||||||
// -----------------------------------------------------------------------------
|
// -----------------------------------------------------------------------------
|
||||||
|
|
||||||
// should be false in configs that have isFlowEnabled = true
|
// should be false in configs that have isFlowEnabled = true
|
||||||
const isTypeScriptEnabled = false;
|
const isTypeScriptEnabled = !!embarkPipeline.typescript;
|
||||||
if (isTypeScriptEnabled) {
|
if (isTypeScriptEnabled) {
|
||||||
// position @babel/preset-typescript as the last preset (runs first)
|
// position @babel/preset-typescript as the last preset (runs first)
|
||||||
// see: https://blogs.msdn.microsoft.com/typescript/2018/08/27/typescript-and-babel-7/
|
// see: https://blogs.msdn.microsoft.com/typescript/2018/08/27/typescript-and-babel-7/
|
||||||
|
|
|
@ -3,7 +3,16 @@ const fs = require('../core/fs');
|
||||||
const ProcessWrapper = require('../core/processes/processWrapper');
|
const ProcessWrapper = require('../core/processes/processWrapper');
|
||||||
const webpack = require('webpack');
|
const webpack = require('webpack');
|
||||||
const writeFile = require('util').promisify(require('fs').writeFile);
|
const writeFile = require('util').promisify(require('fs').writeFile);
|
||||||
const {errorMessage} = require('../utils/utils');
|
const {errorMessage, recursiveMerge} = require('../utils/utils');
|
||||||
|
|
||||||
|
const defaultPipelineConfig = {
|
||||||
|
typescript: false
|
||||||
|
};
|
||||||
|
|
||||||
|
const pipelineConfigPath = fs.dappPath(
|
||||||
|
require(fs.dappPath('embark.json')).config || 'config/',
|
||||||
|
'pipeline.js'
|
||||||
|
);
|
||||||
|
|
||||||
let webpackProcess;
|
let webpackProcess;
|
||||||
|
|
||||||
|
@ -31,6 +40,18 @@ class WebpackProcess extends ProcessWrapper {
|
||||||
fs.dappPath('.embark/embark-assets.json'),
|
fs.dappPath('.embark/embark-assets.json'),
|
||||||
JSON.stringify(assets)
|
JSON.stringify(assets)
|
||||||
);
|
);
|
||||||
|
let pipelineConfig = defaultPipelineConfig;
|
||||||
|
if (fs.existsSync(pipelineConfigPath)) {
|
||||||
|
delete require.cache[pipelineConfigPath];
|
||||||
|
pipelineConfig = recursiveMerge(
|
||||||
|
recursiveMerge(true, pipelineConfig),
|
||||||
|
require(pipelineConfigPath)
|
||||||
|
);
|
||||||
|
}
|
||||||
|
await writeFile(
|
||||||
|
fs.dappPath('.embark/embark-pipeline.json'),
|
||||||
|
JSON.stringify(pipelineConfig)
|
||||||
|
);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
return callback(errorMessage(e));
|
return callback(errorMessage(e));
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,3 @@
|
||||||
|
module.exports = {
|
||||||
|
typescript: false
|
||||||
|
};
|
|
@ -0,0 +1,3 @@
|
||||||
|
module.exports = {
|
||||||
|
typescript: false
|
||||||
|
};
|
Loading…
Reference in New Issue