From 4855375fb32d929df29ef1ce3ba3c5518a1ef058 Mon Sep 17 00:00:00 2001 From: Nogic <24802730+nogic1008@users.noreply.github.com> Date: Tue, 23 Aug 2022 10:50:37 +0900 Subject: [PATCH] fix(vue3-jest): reduce `getTypeScriptConfig` calls (#491) * fix(vue3-jest): reduce `getTypeScriptConfig` calls * test(vue3-basic): update snapshot typescript -> @babel/preset-env --- e2e/3.x/basic/__snapshots__/test.js.snap | 60 ++++++++++++++---------- packages/vue3-jest/lib/process.js | 37 ++++++++------- 2 files changed, 57 insertions(+), 40 deletions(-) diff --git a/e2e/3.x/basic/__snapshots__/test.js.snap b/e2e/3.x/basic/__snapshots__/test.js.snap index 35be5e19..41ac9f12 100644 --- a/e2e/3.x/basic/__snapshots__/test.js.snap +++ b/e2e/3.x/basic/__snapshots__/test.js.snap @@ -32,19 +32,25 @@ var _default = { }; exports[\\"default\\"] = _default; \\"use strict\\"; -Object.defineProperty(exports, \\"__esModule\\", { value: true }); -exports.render = void 0; -var vue_1 = require(\\"vue\\"); -var _hoisted_1 = { class: \\"hello\\" }; -function render(_ctx, _cache) { - return ((0, vue_1.openBlock)(), (0, vue_1.createElementBlock)(\\"div\\", _hoisted_1, [ - (0, vue_1.createElementVNode)(\\"h1\\", { - class: (0, vue_1.normalizeClass)(_ctx.headingClasses) - }, (0, vue_1.toDisplayString)(_ctx.msg), 3 /* TEXT, CLASS */) - ])); -} + +Object.defineProperty(exports, \\"__esModule\\", { + value: true +}); exports.render = render; -;exports.default = {...exports.default, render};;exports.default = {...exports.default, __cssModules: {\\"css\\":{\\"testA\\":\\"testA\\"},\\"$style\\":{\\"testB\\":\\"testB\\"}}}" + +var _vue = require(\\"vue\\"); + +var _hoisted_1 = { + \\"class\\": \\"hello\\" +}; + +function render(_ctx, _cache) { + return (0, _vue.openBlock)(), (0, _vue.createElementBlock)(\\"div\\", _hoisted_1, [(0, _vue.createElementVNode)(\\"h1\\", { + \\"class\\": (0, _vue.normalizeClass)(_ctx.headingClasses) + }, (0, _vue.toDisplayString)(_ctx.msg), 3 + /* TEXT, CLASS */ + )]); +};exports.default = {...exports.default, render};;exports.default = {...exports.default, __cssModules: {\\"css\\":{\\"testA\\":\\"testA\\"},\\"$style\\":{\\"testB\\":\\"testB\\"}}}" `; exports[`generates source maps using src attributes 1`] = ` @@ -79,17 +85,23 @@ var _default = { }; exports[\\"default\\"] = _default; \\"use strict\\"; -Object.defineProperty(exports, \\"__esModule\\", { value: true }); -exports.render = void 0; -var vue_1 = require(\\"vue\\"); -var _hoisted_1 = { class: \\"hello\\" }; -function render(_ctx, _cache) { - return ((0, vue_1.openBlock)(), (0, vue_1.createElementBlock)(\\"div\\", _hoisted_1, [ - (0, vue_1.createElementVNode)(\\"h1\\", { - class: (0, vue_1.normalizeClass)(_ctx.headingClasses) - }, (0, vue_1.toDisplayString)(_ctx.msg), 3 /* TEXT, CLASS */) - ])); -} + +Object.defineProperty(exports, \\"__esModule\\", { + value: true +}); exports.render = render; -;exports.default = {...exports.default, render};" + +var _vue = require(\\"vue\\"); + +var _hoisted_1 = { + \\"class\\": \\"hello\\" +}; + +function render(_ctx, _cache) { + return (0, _vue.openBlock)(), (0, _vue.createElementBlock)(\\"div\\", _hoisted_1, [(0, _vue.createElementVNode)(\\"h1\\", { + \\"class\\": (0, _vue.normalizeClass)(_ctx.headingClasses) + }, (0, _vue.toDisplayString)(_ctx.msg), 3 + /* TEXT, CLASS */ + )]); +};exports.default = {...exports.default, render};" `; diff --git a/packages/vue3-jest/lib/process.js b/packages/vue3-jest/lib/process.js index 735546a1..a8d1c5c9 100644 --- a/packages/vue3-jest/lib/process.js +++ b/packages/vue3-jest/lib/process.js @@ -71,6 +71,12 @@ function processScriptSetup(descriptor, filePath, config) { return result } +/** + * Process SFC