From 029fc02cfca9013607507125532e2ba1e60b5181 Mon Sep 17 00:00:00 2001 From: Markus Padourek Date: Fri, 17 Aug 2018 11:49:44 +0200 Subject: [PATCH 1/5] Require babelrc rather than json parse. --- lib/load-babel-config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/load-babel-config.js b/lib/load-babel-config.js index cff4ecf8..d51fee1a 100644 --- a/lib/load-babel-config.js +++ b/lib/load-babel-config.js @@ -14,7 +14,7 @@ module.exports = function getBabelConfig (vueJestConfig) { let babelConfig if (vueJestConfig.babelRcFile) { - babelConfig = JSON.parse(readFileSync(vueJestConfig.babelRcFile)) + babelConfig = require(vueJestConfig.babelRcFile) } else if (existsSync('babel.config.js')) { babelConfig = require(path.resolve('babel.config.js')) } else { From 3cabdcf3c97c4bdab116a1b39e63ca8928847b40 Mon Sep 17 00:00:00 2001 From: Markus Padourek Date: Fri, 17 Aug 2018 12:04:10 +0200 Subject: [PATCH 2/5] allow for inline babelConfig --- lib/load-babel-config.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/load-babel-config.js b/lib/load-babel-config.js index d51fee1a..c08ead2c 100644 --- a/lib/load-babel-config.js +++ b/lib/load-babel-config.js @@ -14,7 +14,9 @@ module.exports = function getBabelConfig (vueJestConfig) { let babelConfig if (vueJestConfig.babelRcFile) { - babelConfig = require(vueJestConfig.babelRcFile) + babelConfig = JSON.parse(readFileSync(vueJestConfig.babelRcFile)) + } else if (vueJestConfig.babelConfig) { + babelConfig = vueJestConfig.babelConfig } else if (existsSync('babel.config.js')) { babelConfig = require(path.resolve('babel.config.js')) } else { From cb9015b52b5c8db9e64e860122034a6ad50965df Mon Sep 17 00:00:00 2001 From: Markus Padourek Date: Fri, 17 Aug 2018 12:12:37 +0200 Subject: [PATCH 3/5] Allow babelInlineConfig to be passed through --- lib/process.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/process.js b/lib/process.js index ae8c16dc..08ea8b6c 100644 --- a/lib/process.js +++ b/lib/process.js @@ -13,7 +13,7 @@ const join = path.join const logger = require('./logger') const splitRE = /\r?\n/g -function processScript (scriptPart, vueJestConfig) { +function processScript (scriptPart, vueJestConfig, babelInlineConfig) { if (!scriptPart) { return { code: '' } } @@ -26,10 +26,10 @@ function processScript (scriptPart, vueJestConfig) { return compileCoffeeScript(scriptPart.content, vueJestConfig) } - return compileBabel(scriptPart.content, undefined, undefined, vueJestConfig) + return compileBabel(scriptPart.content, undefined, babelInlineConfig, vueJestConfig) } -module.exports = function (src, filePath, jestConfig) { +module.exports = function (src, filePath, jestConfig, babelInlineConfig) { const vueJestConfig = getVueJestConfig(jestConfig) var parts = vueCompiler.parseComponent(src, { pad: true }) @@ -38,7 +38,7 @@ module.exports = function (src, filePath, jestConfig) { parts.script.content = fs.readFileSync(join(filePath, '..', parts.script.src), 'utf8') } - const result = processScript(parts.script, vueJestConfig) + const result = processScript(parts.script, vueJestConfig, babelInlineConfig) const script = result.code const inputMap = result.sourceMap From 5f35de9a538c56bc0bc261bfe22613c77770fb00 Mon Sep 17 00:00:00 2001 From: Markus Padourek Date: Fri, 17 Aug 2018 13:27:30 +0200 Subject: [PATCH 4/5] Remove old code. --- lib/load-babel-config.js | 2 -- 1 file changed, 2 deletions(-) diff --git a/lib/load-babel-config.js b/lib/load-babel-config.js index c08ead2c..cff4ecf8 100644 --- a/lib/load-babel-config.js +++ b/lib/load-babel-config.js @@ -15,8 +15,6 @@ module.exports = function getBabelConfig (vueJestConfig) { if (vueJestConfig.babelRcFile) { babelConfig = JSON.parse(readFileSync(vueJestConfig.babelRcFile)) - } else if (vueJestConfig.babelConfig) { - babelConfig = vueJestConfig.babelConfig } else if (existsSync('babel.config.js')) { babelConfig = require(path.resolve('babel.config.js')) } else { From 78dbb8138aefb405c48fda54ab93daa1b2646aaa Mon Sep 17 00:00:00 2001 From: Globegitter Date: Thu, 30 Aug 2018 22:45:58 +0200 Subject: [PATCH 5/5] Add missing parameter to exported function. --- lib/process.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/process.js b/lib/process.js index 08ea8b6c..fa991c48 100644 --- a/lib/process.js +++ b/lib/process.js @@ -29,7 +29,7 @@ function processScript (scriptPart, vueJestConfig, babelInlineConfig) { return compileBabel(scriptPart.content, undefined, babelInlineConfig, vueJestConfig) } -module.exports = function (src, filePath, jestConfig, babelInlineConfig) { +module.exports = function (src, filePath, jestConfig, _, babelInlineConfig) { const vueJestConfig = getVueJestConfig(jestConfig) var parts = vueCompiler.parseComponent(src, { pad: true })