chore(build): enable support for ts declare fields

This commit is contained in:
SleepWalker
2020-10-11 19:33:55 +03:00
committed by ErickSkrauch
parent f7b0c10ba9
commit 79ff3b9410
12 changed files with 1688 additions and 1678 deletions

View File

@@ -21,6 +21,7 @@ const wp = require('@cypress/webpack-preprocessor');
// for some reason loader can not locate babel.config. So we load it manually
const config = require('../../../babel.config');
const babelEnvName = 'browser-development';
module.exports = (on) => {
const options = {
@@ -39,14 +40,31 @@ module.exports = (on) => {
{
loader: 'babel-loader',
options: {
envName: 'webpack',
envName: babelEnvName,
cacheDirectory: true,
// We don't have the webpack's API object, so just provide necessary methods
...config({
env() {
return 'development';
env(value) {
// see @babel/core/lib/config/helpers/config-api.js
switch (typeof value) {
case 'string':
return value === babelEnvName;
case 'function':
return value(babelEnvName);
case 'undefined':
return babelEnvName;
default:
if (Array.isArray(value)) {
throw new Error('Unimplemented env() argument');
}
throw new Error('Invalid env() argument');
}
},
cache: {
using() {},
},
cache() {},
}),
},
},