From 99258da2df4aca03b166425d297f1734ef40702a Mon Sep 17 00:00:00 2001 From: Andrew Kingston Date: Wed, 7 Apr 2021 11:31:19 +0100 Subject: [PATCH] Add commonJS fields to package.json for client and standard components so the server can require them --- packages/client/package.json | 4 +++- packages/server/src/utilities/fileSystem/index.js | 8 +++++++- packages/standard-components/package.json | 2 ++ 3 files changed, 12 insertions(+), 2 deletions(-) diff --git a/packages/client/package.json b/packages/client/package.json index 4d420256f0..8cef2379e0 100644 --- a/packages/client/package.json +++ b/packages/client/package.json @@ -3,11 +3,13 @@ "version": "0.8.9", "license": "MPL-2.0", "module": "dist/budibase-client.js", + "main": "dist/budibase-client.js", "type": "module", "svelte": "src/index.js", "exports": { ".": { - "import": "./dist/budibase-client.js" + "import": "./dist/budibase-client.js", + "require": "./dist/budibase-client.js" }, "./package.json": "./package.json" }, diff --git a/packages/server/src/utilities/fileSystem/index.js b/packages/server/src/utilities/fileSystem/index.js index 7d193290d5..d84c6deb8a 100644 --- a/packages/server/src/utilities/fileSystem/index.js +++ b/packages/server/src/utilities/fileSystem/index.js @@ -165,7 +165,13 @@ exports.downloadTemplate = async (type, name) => { exports.getComponentLibraryManifest = async (appId, library) => { const filename = "manifest.json" /* istanbul ignore next */ - if (env.isTest() || env.isDev()) { + // when testing in cypress and so on we need to get the package + // as the environment may not be fully fleshed out for dev or prod + if (env.isTest()) { + const lib = library.split("/")[1] + const path = require.resolve(library).split(lib)[0] + return require(join(path, lib, filename)) + } else if (env.isDev()) { const path = join( NODE_MODULES_PATH, "@budibase", diff --git a/packages/standard-components/package.json b/packages/standard-components/package.json index f2eb720512..f6c958e847 100644 --- a/packages/standard-components/package.json +++ b/packages/standard-components/package.json @@ -1,10 +1,12 @@ { "name": "@budibase/standard-components", "module": "dist/standard-components.es.js", + "main": "dist/standard-components.es.js", "svelte": "src/index.js", "exports": { ".": { "import": "./dist/standard-components.es.js" + "require": "./dist/standard-components.es.js" }, "./package.json": "./package.json", "./manifest.json": "./manifest.json"