From ec7448203f911c64943d96d0ee0ef1596b3f2d5b Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 7 Aug 2023 10:00:50 +1000 Subject: [PATCH 1/3] chore(deps): bump json5 from 1.0.1 to 1.0.2 (#526) Bumps [json5](https://github.com/json5/json5) from 1.0.1 to 1.0.2. - [Release notes](https://github.com/json5/json5/releases) - [Changelog](https://github.com/json5/json5/blob/main/CHANGELOG.md) - [Commits](https://github.com/json5/json5/compare/v1.0.1...v1.0.2) --- updated-dependencies: - dependency-name: json5 dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Lachlan Miller --- yarn.lock | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/yarn.lock b/yarn.lock index dcebc9d..f3258ef 100644 --- a/yarn.lock +++ b/yarn.lock @@ -6530,9 +6530,9 @@ json-stringify-safe@^5.0.1, json-stringify-safe@~5.0.1: integrity sha1-Epai1Y/UXxmg9s4B1lcB4sc1tus= json5@^1.0.1: - version "1.0.1" - resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.1.tgz#779fb0018604fa854eacbf6252180d83543e3dbe" - integrity sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow== + version "1.0.2" + resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.2.tgz#63d98d60f21b313b77c4d6da18bfa69d80e1d593" + integrity sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA== dependencies: minimist "^1.2.0" @@ -7410,9 +7410,9 @@ minimist-options@^3.0.1: is-plain-obj "^1.1.0" minimist@^1.1.3, minimist@^1.2.0, minimist@^1.2.5: - version "1.2.5" - resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.5.tgz#67d66014b66a6a8aaa0c083c5fd58df4e4e97602" - integrity sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw== + version "1.2.7" + resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.7.tgz#daa1c4d91f507390437c6a8bc01078e7000c4d18" + integrity sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g== minipass@^2.3.5, minipass@^2.6.0, minipass@^2.9.0: version "2.9.0" @@ -10860,7 +10860,7 @@ vue-template-es2015-compiler@^1.9.0: "vue2-sass-importer-lib@file:e2e/2.x/sass-importer/lib": version "1.0.0" dependencies: - vue2-sass-importer-sass-lib "file:../../Library/Caches/Yarn/v6/npm-vue2-sass-importer-lib-1.0.0-ccaeac9e-c707-4bf2-843f-2b6514207308-1690815365364/node_modules/sass-lib-v1" + vue2-sass-importer-sass-lib "file:../../../Library/Caches/Yarn/v6/npm-vue2-sass-importer-lib-1.0.0-c8ecb622-3c66-45e7-a49b-7fe0cf212f02-1691365665246/node_modules/sass-lib-v1" "vue2-sass-importer-sass-lib@file:e2e/2.x/sass-importer/sass-lib-v1": version "1.0.0" @@ -10871,7 +10871,7 @@ vue-template-es2015-compiler@^1.9.0: "vue3-sass-importer-lib@file:e2e/3.x/sass-importer/lib": version "1.0.0" dependencies: - vue3-sass-importer-sass-lib "file:../../Library/Caches/Yarn/v6/npm-vue3-sass-importer-lib-1.0.0-32edd869-08a1-4b33-835d-626fdeb0344c-1690815365364/node_modules/sass-lib-v1" + vue3-sass-importer-sass-lib "file:../../../Library/Caches/Yarn/v6/npm-vue3-sass-importer-lib-1.0.0-8ffc19e9-f75c-4094-8154-77cbd93d14ce-1691365665246/node_modules/sass-lib-v1" "vue3-sass-importer-sass-lib@file:e2e/3.x/sass-importer/sass-lib-v1": version "1.0.0" From b0c843a5e71d259df51dee23ba4390085f244db2 Mon Sep 17 00:00:00 2001 From: Pierre-Michel Brown Date: Thu, 7 Sep 2023 00:47:51 +0200 Subject: [PATCH 2/3] fix: allow importing relative paths in global resources (#548) --- e2e/2.x/style/colors.less | 1 + e2e/2.x/style/colors.scss | 1 + e2e/2.x/style/variables.less | 4 +++- e2e/2.x/style/variables.scss | 4 +++- e2e/3.x/style/colors.less | 1 + e2e/3.x/style/colors.scss | 1 + e2e/3.x/style/variables.less | 4 +++- e2e/3.x/style/variables.scss | 4 +++- packages/vue2-jest/lib/process-style.js | 19 ++++++++++++++----- packages/vue3-jest/lib/process-style.js | 19 ++++++++++++++----- 10 files changed, 44 insertions(+), 14 deletions(-) create mode 100644 e2e/2.x/style/colors.less create mode 100644 e2e/2.x/style/colors.scss create mode 100644 e2e/3.x/style/colors.less create mode 100644 e2e/3.x/style/colors.scss diff --git a/e2e/2.x/style/colors.less b/e2e/2.x/style/colors.less new file mode 100644 index 0000000..7b9ea3f --- /dev/null +++ b/e2e/2.x/style/colors.less @@ -0,0 +1 @@ +@primary-color: "red"; diff --git a/e2e/2.x/style/colors.scss b/e2e/2.x/style/colors.scss new file mode 100644 index 0000000..d7cf8ed --- /dev/null +++ b/e2e/2.x/style/colors.scss @@ -0,0 +1 @@ +$primary-color: #333; diff --git a/e2e/2.x/style/variables.less b/e2e/2.x/style/variables.less index 7b9ea3f..57319a4 100644 --- a/e2e/2.x/style/variables.less +++ b/e2e/2.x/style/variables.less @@ -1 +1,3 @@ -@primary-color: "red"; +@import "./colors.less"; + +@font-size: 16px; diff --git a/e2e/2.x/style/variables.scss b/e2e/2.x/style/variables.scss index d7cf8ed..4f8d906 100644 --- a/e2e/2.x/style/variables.scss +++ b/e2e/2.x/style/variables.scss @@ -1 +1,3 @@ -$primary-color: #333; +@import './colors.scss'; + +$font-size: 16px; diff --git a/e2e/3.x/style/colors.less b/e2e/3.x/style/colors.less new file mode 100644 index 0000000..7b9ea3f --- /dev/null +++ b/e2e/3.x/style/colors.less @@ -0,0 +1 @@ +@primary-color: "red"; diff --git a/e2e/3.x/style/colors.scss b/e2e/3.x/style/colors.scss new file mode 100644 index 0000000..d7cf8ed --- /dev/null +++ b/e2e/3.x/style/colors.scss @@ -0,0 +1 @@ +$primary-color: #333; diff --git a/e2e/3.x/style/variables.less b/e2e/3.x/style/variables.less index 7b9ea3f..57319a4 100644 --- a/e2e/3.x/style/variables.less +++ b/e2e/3.x/style/variables.less @@ -1 +1,3 @@ -@primary-color: "red"; +@import "./colors.less"; + +@font-size: 16px; diff --git a/e2e/3.x/style/variables.scss b/e2e/3.x/style/variables.scss index d7cf8ed..4f8d906 100644 --- a/e2e/3.x/style/variables.scss +++ b/e2e/3.x/style/variables.scss @@ -1 +1,3 @@ -$primary-color: #333; +@import './colors.scss'; + +$font-size: 16px; diff --git a/packages/vue2-jest/lib/process-style.js b/packages/vue2-jest/lib/process-style.js index 538705b..049e0c6 100644 --- a/packages/vue2-jest/lib/process-style.js +++ b/packages/vue2-jest/lib/process-style.js @@ -1,5 +1,4 @@ const path = require('path') -const fs = require('fs') const cssTree = require('css-tree') const getVueJestConfig = require('./utils').getVueJestConfig const compileStyle = require('@vue/component-compiler-utils').compileStyle @@ -12,14 +11,23 @@ function getGlobalResources(resources, lang) { let globalResources = '' if (resources && resources[lang]) { globalResources = resources[lang] - .map(resource => path.resolve(process.cwd(), resource)) - .filter(resourcePath => fs.existsSync(resourcePath)) - .map(resourcePath => fs.readFileSync(resourcePath).toString()) - .join('\n') + .map(resource => { + const absolutePath = path.resolve(process.cwd(), resource) + return `${getImportLine(lang, absolutePath)}\n` + }) + .join('') } return globalResources } +function getImportLine(lang, filePath) { + const importLines = { + default: `@import "${filePath}";`, + sass: `@import "${filePath}"` + } + return importLines[lang] || importLines.default +} + function extractClassMap(cssCode) { const ast = cssTree.parse(cssCode) @@ -35,6 +43,7 @@ function extractClassMap(cssCode) { function getPreprocessOptions(lang, filePath, jestConfig) { if (lang === 'scss' || lang === 'sass') { return { + filename: filePath, importer: (url, prev, done) => ({ file: applyModuleNameMapper( url, diff --git a/packages/vue3-jest/lib/process-style.js b/packages/vue3-jest/lib/process-style.js index 578c949..93adb48 100644 --- a/packages/vue3-jest/lib/process-style.js +++ b/packages/vue3-jest/lib/process-style.js @@ -1,6 +1,5 @@ const { compileStyle } = require('@vue/compiler-sfc') const path = require('path') -const fs = require('fs') const cssTree = require('css-tree') const getVueJestConfig = require('./utils').getVueJestConfig const applyModuleNameMapper = require('./module-name-mapper-helper') @@ -12,14 +11,23 @@ function getGlobalResources(resources, lang) { let globalResources = '' if (resources && resources[lang]) { globalResources = resources[lang] - .map(resource => path.resolve(process.cwd(), resource)) - .filter(resourcePath => fs.existsSync(resourcePath)) - .map(resourcePath => fs.readFileSync(resourcePath).toString()) - .join('\n') + .map(resource => { + const absolutePath = path.resolve(process.cwd(), resource) + return `${getImportLine(lang, absolutePath)}\n` + }) + .join('') } return globalResources } +function getImportLine(lang, filePath) { + const importLines = { + default: `@import "${filePath}";`, + sass: `@import "${filePath}"` + } + return importLines[lang] || importLines.default +} + function extractClassMap(cssCode) { const ast = cssTree.parse(cssCode) @@ -35,6 +43,7 @@ function extractClassMap(cssCode) { function getPreprocessOptions(lang, filePath, jestConfig) { if (lang === 'scss' || lang === 'sass') { return { + filename: filePath, importer: (url, prev) => ({ file: applyModuleNameMapper( url, From d61d430c8f673cb4576afc91e85479ab4f7e6b34 Mon Sep 17 00:00:00 2001 From: Lachlan Miller Date: Thu, 7 Sep 2023 08:57:53 +1000 Subject: [PATCH 3/3] publish: 29.2.6 --- packages/vue2-jest/package.json | 2 +- packages/vue3-jest/package.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/packages/vue2-jest/package.json b/packages/vue2-jest/package.json index f26c9a5..dd3f45a 100644 --- a/packages/vue2-jest/package.json +++ b/packages/vue2-jest/package.json @@ -1,6 +1,6 @@ { "name": "@vue/vue2-jest", - "version": "29.2.5", + "version": "29.2.6", "description": "Jest transformer for Vue 2", "main": "lib/index.js", "files": [ diff --git a/packages/vue3-jest/package.json b/packages/vue3-jest/package.json index c56199a..4281999 100644 --- a/packages/vue3-jest/package.json +++ b/packages/vue3-jest/package.json @@ -1,6 +1,6 @@ { "name": "@vue/vue3-jest", - "version": "29.2.5", + "version": "29.2.6", "description": "Jest Vue transform", "main": "lib/index.js", "files": [