From 8fc828e0e2cdea9b9ba822a344bc34bf707711ee Mon Sep 17 00:00:00 2001 From: Ferdinand Thiessen Date: Tue, 11 Jun 2024 00:23:59 +0200 Subject: [PATCH] fix(files): Adjust babel module resolution Signed-off-by: Ferdinand Thiessen --- babel.config.js | 10 ++++ jest.config.ts | 6 +- package-lock.json | 145 ++++++++++++++++++++++++++++++++++++++++++++++ package.json | 1 + 4 files changed, 161 insertions(+), 1 deletion(-) diff --git a/babel.config.js b/babel.config.js index 0cbaa9396cb..044e5a3fed1 100644 --- a/babel.config.js +++ b/babel.config.js @@ -6,6 +6,16 @@ module.exports = { plugins: [ '@babel/plugin-syntax-dynamic-import', '@babel/plugin-proposal-class-properties', + // We need the bundler entry not the web one + // Jest will otherwise resolve the wrong one + [ + "module-resolver", + { + "alias": { + "webdav$": "webdav/dist/node/index.js", + }, + }, + ] ], presets: [ // https://babeljs.io/docs/en/babel-preset-typescript diff --git a/jest.config.ts b/jest.config.ts index 173e541ed70..54b7ee1fd35 100644 --- a/jest.config.ts +++ b/jest.config.ts @@ -9,6 +9,7 @@ const ignorePatterns = [ '@buttercup/fetch', '@juliushaertl', '@mdi/svg', + '@nextcloud/files', '@nextcloud/upload', '@nextcloud/vue', 'ansi-regex', @@ -16,6 +17,7 @@ const ignorePatterns = [ 'char-regex', 'hot-patcher', 'is-svg', + 'layerr', 'mime', 'p-cancelable', 'p-limit', @@ -26,6 +28,7 @@ const ignorePatterns = [ 'strip-ansi', 'tributejs', 'unist-.+', + 'url-join', 'vue-material-design-icons', 'webdav', 'yocto-queue', @@ -49,7 +52,7 @@ const config: Config = { transform: { // process `*.js` files with `babel-jest` - '^.+\\.js$': 'babel-jest', + '^.+\\.c?js$': 'babel-jest', '^.+\\.vue$': '@vue/vue2-jest', '^.+\\.ts$': ['ts-jest', { // @see https://github.com/kulshekhar/ts-jest/issues/4081 @@ -65,6 +68,7 @@ const config: Config = { '^.+\\.svg(\\?raw)?$': '/__mocks__/svg.js', '\\.s?css$': '/__mocks__/css.js', }, + modulePathIgnorePatterns: [ '/apps2/', '/apps-extra/', diff --git a/package-lock.json b/package-lock.json index d267421519f..9be420da72c 100644 --- a/package-lock.json +++ b/package-lock.json @@ -113,6 +113,7 @@ "babel-jest": "^29.6.4", "babel-loader": "^9.1.0", "babel-loader-exclude-node-modules-except": "^1.2.1", + "babel-plugin-module-resolver": "^5.0.2", "colord": "^2.9.3", "css-loader": "^6.8.1", "cypress": "^13.7.2", @@ -7991,6 +7992,61 @@ "node": "^14.15.0 || ^16.10.0 || >=18.0.0" } }, + "node_modules/babel-plugin-module-resolver": { + "version": "5.0.2", + "resolved": "https://registry.npmjs.org/babel-plugin-module-resolver/-/babel-plugin-module-resolver-5.0.2.tgz", + "integrity": "sha512-9KtaCazHee2xc0ibfqsDeamwDps6FZNo5S0Q81dUqEuFzVwPhcT4J5jOqIVvgCA3Q/wO9hKYxN/Ds3tIsp5ygg==", + "dev": true, + "dependencies": { + "find-babel-config": "^2.1.1", + "glob": "^9.3.3", + "pkg-up": "^3.1.0", + "reselect": "^4.1.7", + "resolve": "^1.22.8" + } + }, + "node_modules/babel-plugin-module-resolver/node_modules/glob": { + "version": "9.3.5", + "resolved": "https://registry.npmjs.org/glob/-/glob-9.3.5.tgz", + "integrity": "sha512-e1LleDykUz2Iu+MTYdkSsuWX8lvAjAcs0Xef0lNIu0S2wOAzuTxCJtcd9S3cijlwYF18EsU3rzb8jPVobxDh9Q==", + "dev": true, + "dependencies": { + "fs.realpath": "^1.0.0", + "minimatch": "^8.0.2", + "minipass": "^4.2.4", + "path-scurry": "^1.6.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/babel-plugin-module-resolver/node_modules/minimatch": { + "version": "8.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-8.0.4.tgz", + "integrity": "sha512-W0Wvr9HyFXZRGIDgCicunpQ299OKXs9RgZfaukz4qAW/pJhcpUfupc9c+OObPOFueNy8VSrZgEmDtk6Kh4WzDA==", + "dev": true, + "dependencies": { + "brace-expansion": "^2.0.1" + }, + "engines": { + "node": ">=16 || 14 >=14.17" + }, + "funding": { + "url": "https://github.com/sponsors/isaacs" + } + }, + "node_modules/babel-plugin-module-resolver/node_modules/minipass": { + "version": "4.2.8", + "resolved": "https://registry.npmjs.org/minipass/-/minipass-4.2.8.tgz", + "integrity": "sha512-fNzuVyifolSLFL4NzpF+wEF4qrgqaaKX0haXPQEdQ7NKAN+WecoKMHV09YcuL/DHxrUsYQOK3MiuDf7Ip2OXfQ==", + "dev": true, + "engines": { + "node": ">=8" + } + }, "node_modules/babel-plugin-polyfill-corejs2": { "version": "0.4.8", "resolved": "https://registry.npmjs.org/babel-plugin-polyfill-corejs2/-/babel-plugin-polyfill-corejs2-0.4.8.tgz", @@ -13499,6 +13555,16 @@ "node": ">= 0.8" } }, + "node_modules/find-babel-config": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/find-babel-config/-/find-babel-config-2.1.1.tgz", + "integrity": "sha512-5Ji+EAysHGe1OipH7GN4qDjok5Z1uw5KAwDCbicU/4wyTZY7CqOCzcWbG7J5ad9mazq67k89fXlbc1MuIfl9uA==", + "dev": true, + "dependencies": { + "json5": "^2.2.3", + "path-exists": "^4.0.0" + } + }, "node_modules/find-cache-dir": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-2.1.0.tgz", @@ -21937,6 +22003,79 @@ "node": ">=4" } }, + "node_modules/pkg-up": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/pkg-up/-/pkg-up-3.1.0.tgz", + "integrity": "sha512-nDywThFk1i4BQK4twPQ6TA4RT8bDY96yeuCVBWL3ePARCiEKDRSrNGbFIgUJpLp+XeIR65v8ra7WuJOFUBtkMA==", + "dev": true, + "dependencies": { + "find-up": "^3.0.0" + }, + "engines": { + "node": ">=8" + } + }, + "node_modules/pkg-up/node_modules/find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, + "dependencies": { + "locate-path": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/pkg-up/node_modules/locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, + "dependencies": { + "p-locate": "^3.0.0", + "path-exists": "^3.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/pkg-up/node_modules/p-limit": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.3.0.tgz", + "integrity": "sha512-//88mFWSJx8lxCzwdAABTJL2MyWB12+eIY7MDL2SqLmAkeKU9qxRvWuSyTjm3FUmpBEMuFfckAIqEaVGUDxb6w==", + "dev": true, + "dependencies": { + "p-try": "^2.0.0" + }, + "engines": { + "node": ">=6" + }, + "funding": { + "url": "https://github.com/sponsors/sindresorhus" + } + }, + "node_modules/pkg-up/node_modules/p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, + "dependencies": { + "p-limit": "^2.0.0" + }, + "engines": { + "node": ">=6" + } + }, + "node_modules/pkg-up/node_modules/path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha512-bpC7GYwiDYQ4wYLe+FA8lhRjhQCMcQGuSgGGqDkg/QerRWw9CmGRT0iSOVRSZJ29NMLZgIzqaljJ63oaL4NIJQ==", + "dev": true, + "engines": { + "node": ">=4" + } + }, "node_modules/pluralize": { "version": "8.0.0", "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-8.0.0.tgz", @@ -23461,6 +23600,12 @@ "lodash": "^4.17.21" } }, + "node_modules/reselect": { + "version": "4.1.8", + "resolved": "https://registry.npmjs.org/reselect/-/reselect-4.1.8.tgz", + "integrity": "sha512-ab9EmR80F/zQTMNeneUr4cv+jSwPJgIlvEmVwLerwrWVbpLlBuls9XHzIeTFy4cegU2NHBp3va0LKOzU5qFEYQ==", + "dev": true + }, "node_modules/resolve": { "version": "1.22.8", "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.22.8.tgz", diff --git a/package.json b/package.json index 5e35b89cacd..6b446191396 100644 --- a/package.json +++ b/package.json @@ -140,6 +140,7 @@ "babel-jest": "^29.6.4", "babel-loader": "^9.1.0", "babel-loader-exclude-node-modules-except": "^1.2.1", + "babel-plugin-module-resolver": "^5.0.2", "colord": "^2.9.3", "css-loader": "^6.8.1", "cypress": "^13.7.2",