Skip to content

Commit

Permalink
fix: loader-utils ^3.0.0 (#237)
Browse files Browse the repository at this point in the history
Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Co-authored-by: Felix Habib <[email protected]>
Co-authored-by: Adam Skoufis <[email protected]>
  • Loading branch information
3 people authored Oct 7, 2024
1 parent a0ff065 commit b74686d
Show file tree
Hide file tree
Showing 7 changed files with 36 additions and 69 deletions.
5 changes: 5 additions & 0 deletions .changeset/new-adults-drum.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'virtual-resource-loader': major
---

Remove `loader-utils` dependency and drop support for Webpack v4.x
5 changes: 5 additions & 0 deletions .changeset/proud-starfishes-wash.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@vocab/webpack': patch
---

URI-encode virtual language module data for compatibility with Webpack v5's `this.getOptions` API
8 changes: 1 addition & 7 deletions packages/virtual-resource-loader/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,5 @@
},
"files": [
"dist"
],
"dependencies": {
"loader-utils": "^2.0.0"
},
"devDependencies": {
"@types/loader-utils": "^2.0.1"
}
]
}
4 changes: 1 addition & 3 deletions packages/virtual-resource-loader/src/index.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import { getOptions } from 'loader-utils';

export default function virtualResourceLoader(this: any) {
const { source } = getOptions(this);
const { source } = this.getOptions();

return Buffer.from(source as string, 'base64').toString('utf-8');
}
4 changes: 3 additions & 1 deletion packages/webpack/src/loader.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,9 @@ function createIdentifier(
'base64',
);

const unloader = `${virtualResourceLoader}?source=${base64}`;
const unloader = `${virtualResourceLoader}?source=${encodeURIComponent(
base64,
)}`;
const fileIdent = path.basename(resourcePath, 'translations.json');

return `./${fileIdent}-${lang}-virtual.json!=!${unloader}!`;
Expand Down
39 changes: 1 addition & 38 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

40 changes: 20 additions & 20 deletions tests/__snapshots__/E2E.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@ module.exports = /*#__PURE__*/JSON.parse('{"hello":"Hello","world":"world"}');
/***/ }),
/***/ "./fixtures/simple/src/client.vocab/translations.json-en-virtual.json!=!./packages/virtual-resource-loader/dist/virtual-resource-loader.cjs.js?source=eyJzcGVjaWFsQ2hhcmFjdGVycyAtICfigJjigJnigJzigJ1cIiFAIyQlXiYqKClfK1xcL2B+XFxcXCI6IuKAmOKAmeKAnOKAnSdcIiFAIyQlXiYqKClfK1xcL2B+XFxcXCIsInZvY2FiUHVibGlzaERhdGUiOiI8c3Ryb25nPlZvY2FiPC9zdHJvbmc+IHdhcyBwdWJsaXNoZWQgb24ge3B1Ymxpc2hEYXRlLCBkYXRlLCBzbWFsbH0ifQ==!":
/*!**************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\\
!*** ./fixtures/simple/src/client.vocab/translations.json-en-virtual.json!=!./packages/virtual-resource-loader/dist/virtual-resource-loader.cjs.js?source=eyJzcGVjaWFsQ2hhcmFjdGVycyAtICfigJjigJnigJzigJ1cIiFAIyQlXiYqKClfK1xcL2B+XFxcXCI6IuKAmOKAmeKAnOKAnSdcIiFAIyQlXiYqKClfK1xcL2B+XFxcXCIsInZvY2FiUHVibGlzaERhdGUiOiI8c3Ryb25nPlZvY2FiPC9zdHJvbmc+IHdhcyBwdWJsaXNoZWQgb24ge3B1Ymxpc2hEYXRlLCBkYXRlLCBzbWFsbH0ifQ==! ***!
\\**************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
/***/ "./fixtures/simple/src/client.vocab/translations.json-en-virtual.json!=!./packages/virtual-resource-loader/dist/virtual-resource-loader.cjs.js?source=eyJzcGVjaWFsQ2hhcmFjdGVycyAtICfigJjigJnigJzigJ1cIiFAIyQlXiYqKClfK1xcL2B%2BXFxcXCI6IuKAmOKAmeKAnOKAnSdcIiFAIyQlXiYqKClfK1xcL2B%2BXFxcXCIsInZvY2FiUHVibGlzaERhdGUiOiI8c3Ryb25nPlZvY2FiPC9zdHJvbmc%2BIHdhcyBwdWJsaXNoZWQgb24ge3B1Ymxpc2hEYXRlLCBkYXRlLCBzbWFsbH0ifQ%3D%3D!":
/*!************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\\
!*** ./fixtures/simple/src/client.vocab/translations.json-en-virtual.json!=!./packages/virtual-resource-loader/dist/virtual-resource-loader.cjs.js?source=eyJzcGVjaWFsQ2hhcmFjdGVycyAtICfigJjigJnigJzigJ1cIiFAIyQlXiYqKClfK1xcL2B%2BXFxcXCI6IuKAmOKAmeKAnOKAnSdcIiFAIyQlXiYqKClfK1xcL2B%2BXFxcXCIsInZvY2FiUHVibGlzaERhdGUiOiI8c3Ryb25nPlZvY2FiPC9zdHJvbmc%2BIHdhcyBwdWJsaXNoZWQgb24ge3B1Ymxpc2hEYXRlLCBkYXRlLCBzbWFsbH0ifQ%3D%3D! ***!
\\************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
/***/ ((module) => {
module.exports = /*#__PURE__*/JSON.parse('{"specialCharacters - \\'‘’“”\\\\"!@#$%^&*()_+\\\\\\\\/\`~\\\\\\\\\\\\\\\\":"‘’“”\\'\\\\"!@#$%^&*()_+\\\\\\\\/\`~\\\\\\\\\\\\\\\\","vocabPublishDate":"<strong>Vocab</strong> was published on {publishDate, date, small}"}');
Expand All @@ -31,20 +31,20 @@ exports[`E2E Simple with plugin should return the expected fr chunk 1`] = `
""use strict";
(self["webpackChunk_vocab_private_monorepo"] = self["webpackChunk_vocab_private_monorepo"] || []).push([["fr-translations"],{
/***/ "./fixtures/simple/src/.vocab/translations.json-fr-virtual.json!=!./packages/virtual-resource-loader/dist/virtual-resource-loader.cjs.js?source=eyJoZWxsbyI6IkJvbmpvdXIiLCJ3b3JsZCI6Im1vbmRlIn0=!":
/*!********************************************************************************************************************************************************************************************************!*\\
!*** ./fixtures/simple/src/.vocab/translations.json-fr-virtual.json!=!./packages/virtual-resource-loader/dist/virtual-resource-loader.cjs.js?source=eyJoZWxsbyI6IkJvbmpvdXIiLCJ3b3JsZCI6Im1vbmRlIn0=! ***!
\\********************************************************************************************************************************************************************************************************/
/***/ "./fixtures/simple/src/.vocab/translations.json-fr-virtual.json!=!./packages/virtual-resource-loader/dist/virtual-resource-loader.cjs.js?source=eyJoZWxsbyI6IkJvbmpvdXIiLCJ3b3JsZCI6Im1vbmRlIn0%3D!":
/*!**********************************************************************************************************************************************************************************************************!*\\
!*** ./fixtures/simple/src/.vocab/translations.json-fr-virtual.json!=!./packages/virtual-resource-loader/dist/virtual-resource-loader.cjs.js?source=eyJoZWxsbyI6IkJvbmpvdXIiLCJ3b3JsZCI6Im1vbmRlIn0%3D! ***!
\\**********************************************************************************************************************************************************************************************************/
/***/ ((module) => {
module.exports = /*#__PURE__*/JSON.parse('{"hello":"Bonjour","world":"monde"}');
/***/ }),
/***/ "./fixtures/simple/src/client.vocab/translations.json-fr-virtual.json!=!./packages/virtual-resource-loader/dist/virtual-resource-loader.cjs.js?source=eyJzcGVjaWFsQ2hhcmFjdGVycyAtICfigJjigJnigJzigJ1cIiFAIyQlXiYqKClfK1xcL2B+XFxcXCI6IuKAmOKAmeKAnOKAnSdcIiFAIyQlXiYqKClfK1xcL2B+XFxcXCIsInZvY2FiUHVibGlzaERhdGUiOiJWb2NhYiBhIMOpdMOpIHB1Ymxpw6kgbGUge3B1Ymxpc2hEYXRlLCBkYXRlLCBtZWRpdW19In0=!":
/*!******************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\\
!*** ./fixtures/simple/src/client.vocab/translations.json-fr-virtual.json!=!./packages/virtual-resource-loader/dist/virtual-resource-loader.cjs.js?source=eyJzcGVjaWFsQ2hhcmFjdGVycyAtICfigJjigJnigJzigJ1cIiFAIyQlXiYqKClfK1xcL2B+XFxcXCI6IuKAmOKAmeKAnOKAnSdcIiFAIyQlXiYqKClfK1xcL2B+XFxcXCIsInZvY2FiUHVibGlzaERhdGUiOiJWb2NhYiBhIMOpdMOpIHB1Ymxpw6kgbGUge3B1Ymxpc2hEYXRlLCBkYXRlLCBtZWRpdW19In0=! ***!
\\******************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
/***/ "./fixtures/simple/src/client.vocab/translations.json-fr-virtual.json!=!./packages/virtual-resource-loader/dist/virtual-resource-loader.cjs.js?source=eyJzcGVjaWFsQ2hhcmFjdGVycyAtICfigJjigJnigJzigJ1cIiFAIyQlXiYqKClfK1xcL2B%2BXFxcXCI6IuKAmOKAmeKAnOKAnSdcIiFAIyQlXiYqKClfK1xcL2B%2BXFxcXCIsInZvY2FiUHVibGlzaERhdGUiOiJWb2NhYiBhIMOpdMOpIHB1Ymxpw6kgbGUge3B1Ymxpc2hEYXRlLCBkYXRlLCBtZWRpdW19In0%3D!":
/*!************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\\
!*** ./fixtures/simple/src/client.vocab/translations.json-fr-virtual.json!=!./packages/virtual-resource-loader/dist/virtual-resource-loader.cjs.js?source=eyJzcGVjaWFsQ2hhcmFjdGVycyAtICfigJjigJnigJzigJ1cIiFAIyQlXiYqKClfK1xcL2B%2BXFxcXCI6IuKAmOKAmeKAnOKAnSdcIiFAIyQlXiYqKClfK1xcL2B%2BXFxcXCIsInZvY2FiUHVibGlzaERhdGUiOiJWb2NhYiBhIMOpdMOpIHB1Ymxpw6kgbGUge3B1Ymxpc2hEYXRlLCBkYXRlLCBtZWRpdW19In0%3D! ***!
\\************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
/***/ ((module) => {
module.exports = /*#__PURE__*/JSON.parse('{"specialCharacters - \\'‘’“”\\\\"!@#$%^&*()_+\\\\\\\\/\`~\\\\\\\\\\\\\\\\":"‘’“”\\'\\\\"!@#$%^&*()_+\\\\\\\\/\`~\\\\\\\\\\\\\\\\","vocabPublishDate":"Vocab a été publié le {publishDate, date, medium}"}');
Expand All @@ -58,20 +58,20 @@ exports[`E2E Simple with plugin should return the expected pseudo chunk 1`] = `
""use strict";
(self["webpackChunk_vocab_private_monorepo"] = self["webpackChunk_vocab_private_monorepo"] || []).push([["pseudo-translations"],{
/***/ "./fixtures/simple/src/.vocab/translations.json-pseudo-virtual.json!=!./packages/virtual-resource-loader/dist/virtual-resource-loader.cjs.js?source=eyJoZWxsbyI6IlvhuKjhur3hur3Gmsaaw7bDtl0iLCJ3b3JsZCI6IlvFtcO2w7bDtsWZxprGjF0ifQ==!":
/*!********************************************************************************************************************************************************************************************************************************************!*\\
!*** ./fixtures/simple/src/.vocab/translations.json-pseudo-virtual.json!=!./packages/virtual-resource-loader/dist/virtual-resource-loader.cjs.js?source=eyJoZWxsbyI6IlvhuKjhur3hur3Gmsaaw7bDtl0iLCJ3b3JsZCI6IlvFtcO2w7bDtsWZxprGjF0ifQ==! ***!
\\********************************************************************************************************************************************************************************************************************************************/
/***/ "./fixtures/simple/src/.vocab/translations.json-pseudo-virtual.json!=!./packages/virtual-resource-loader/dist/virtual-resource-loader.cjs.js?source=eyJoZWxsbyI6IlvhuKjhur3hur3Gmsaaw7bDtl0iLCJ3b3JsZCI6IlvFtcO2w7bDtsWZxprGjF0ifQ%3D%3D!":
/*!************************************************************************************************************************************************************************************************************************************************!*\\
!*** ./fixtures/simple/src/.vocab/translations.json-pseudo-virtual.json!=!./packages/virtual-resource-loader/dist/virtual-resource-loader.cjs.js?source=eyJoZWxsbyI6IlvhuKjhur3hur3Gmsaaw7bDtl0iLCJ3b3JsZCI6IlvFtcO2w7bDtsWZxprGjF0ifQ%3D%3D! ***!
\\************************************************************************************************************************************************************************************************************************************************/
/***/ ((module) => {
module.exports = /*#__PURE__*/JSON.parse('{"hello":"[Ḩẽẽƚƚöö]","world":"[ŵöööřƚƌ]"}');
/***/ }),
/***/ "./fixtures/simple/src/client.vocab/translations.json-pseudo-virtual.json!=!./packages/virtual-resource-loader/dist/virtual-resource-loader.cjs.js?source=eyJzcGVjaWFsQ2hhcmFjdGVycyAtICfigJjigJnigJzigJ1cIiFAIyQlXiYqKClfK1xcL2B+XFxcXCI6IlvigJjigJnigJzigJ0nXCIhQCMkJV4mKigpXytcXC9gflxcXFxdIiwidm9jYWJQdWJsaXNoRGF0ZSI6Ils8c3Ryb25nPuG5vMO2w7bDp8SDxIPDnzwvc3Ryb25nPiDFtcSDxIPEg8WhIMalx5rHmseaw5/GmsOsw6zDrMWh4bip4bq94bq94bq9xowgw7bDtsO24LiB4Li14LmJIHtwdWJsaXNoRGF0ZSwgZGF0ZSwgc21hbGx9XSJ9!":
/*!**********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\\
!*** ./fixtures/simple/src/client.vocab/translations.json-pseudo-virtual.json!=!./packages/virtual-resource-loader/dist/virtual-resource-loader.cjs.js?source=eyJzcGVjaWFsQ2hhcmFjdGVycyAtICfigJjigJnigJzigJ1cIiFAIyQlXiYqKClfK1xcL2B+XFxcXCI6IlvigJjigJnigJzigJ0nXCIhQCMkJV4mKigpXytcXC9gflxcXFxdIiwidm9jYWJQdWJsaXNoRGF0ZSI6Ils8c3Ryb25nPuG5vMO2w7bDp8SDxIPDnzwvc3Ryb25nPiDFtcSDxIPEg8WhIMalx5rHmseaw5/GmsOsw6zDrMWh4bip4bq94bq94bq9xowgw7bDtsO24LiB4Li14LmJIHtwdWJsaXNoRGF0ZSwgZGF0ZSwgc21hbGx9XSJ9! ***!
\\**********************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
/***/ "./fixtures/simple/src/client.vocab/translations.json-pseudo-virtual.json!=!./packages/virtual-resource-loader/dist/virtual-resource-loader.cjs.js?source=eyJzcGVjaWFsQ2hhcmFjdGVycyAtICfigJjigJnigJzigJ1cIiFAIyQlXiYqKClfK1xcL2B%2BXFxcXCI6IlvigJjigJnigJzigJ0nXCIhQCMkJV4mKigpXytcXC9gflxcXFxdIiwidm9jYWJQdWJsaXNoRGF0ZSI6Ils8c3Ryb25nPuG5vMO2w7bDp8SDxIPDnzwvc3Ryb25nPiDFtcSDxIPEg8WhIMalx5rHmseaw5%2FGmsOsw6zDrMWh4bip4bq94bq94bq9xowgw7bDtsO24LiB4Li14LmJIHtwdWJsaXNoRGF0ZSwgZGF0ZSwgc21hbGx9XSJ9!":
/*!**************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************!*\\
!*** ./fixtures/simple/src/client.vocab/translations.json-pseudo-virtual.json!=!./packages/virtual-resource-loader/dist/virtual-resource-loader.cjs.js?source=eyJzcGVjaWFsQ2hhcmFjdGVycyAtICfigJjigJnigJzigJ1cIiFAIyQlXiYqKClfK1xcL2B%2BXFxcXCI6IlvigJjigJnigJzigJ0nXCIhQCMkJV4mKigpXytcXC9gflxcXFxdIiwidm9jYWJQdWJsaXNoRGF0ZSI6Ils8c3Ryb25nPuG5vMO2w7bDp8SDxIPDnzwvc3Ryb25nPiDFtcSDxIPEg8WhIMalx5rHmseaw5%2FGmsOsw6zDrMWh4bip4bq94bq94bq9xowgw7bDtsO24LiB4Li14LmJIHtwdWJsaXNoRGF0ZSwgZGF0ZSwgc21hbGx9XSJ9! ***!
\\**************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************************/
/***/ ((module) => {
module.exports = /*#__PURE__*/JSON.parse('{"specialCharacters - \\'‘’“”\\\\"!@#$%^&*()_+\\\\\\\\/\`~\\\\\\\\\\\\\\\\":"[‘’“”\\'\\\\"!@#$%^&*()_+\\\\\\\\/\`~\\\\\\\\\\\\\\\\]","vocabPublishDate":"[<strong>Ṽööçăăß</strong> ŵăăăš ƥǚǚǚßƚìììšḩẽẽẽƌ öööกี้ {publishDate, date, small}]"}');
Expand Down

0 comments on commit b74686d

Please sign in to comment.