From 62d816402c6ddccf22c9ac68822cf100f61662d6 Mon Sep 17 00:00:00 2001 From: Kristóf Marussy Date: Thu, 30 Dec 2021 12:05:27 +0100 Subject: build: Use shared packages through modules By running the build for the shared packages only once, errors in them are reported only once in watch mode. We still have to point jest to the original source files (and rebuild the shared source files as part of the test), because it won't load the "module" entry of the shared packages. However, as a benefit, jest can now run even if the shared packages haven't been built yet. --- packages/service-shared/esbuild.config.js | 21 +++++++++++++++++++++ packages/service-shared/package.json | 2 +- packages/shared/package.json | 1 - 3 files changed, 22 insertions(+), 2 deletions(-) create mode 100644 packages/service-shared/esbuild.config.js (limited to 'packages') diff --git a/packages/service-shared/esbuild.config.js b/packages/service-shared/esbuild.config.js new file mode 100644 index 0000000..ce57cd7 --- /dev/null +++ b/packages/service-shared/esbuild.config.js @@ -0,0 +1,21 @@ +// @ts-check + +const { chrome } = require('../../config/build-common'); +const { getConfig } = require('../../config/esbuild-config'); + +module.exports = getConfig({ + absWorkingDir: __dirname, + entryPoints: [ + 'src/index.ts', + ], + outfile: 'dist/index.mjs', + format: 'esm', + // The package that includes this one will have a header comment, + // no need to have an additional one here. + banner: {}, + platform: 'node', + target: chrome, + external: [ + 'zod', + ], +}); diff --git a/packages/service-shared/package.json b/packages/service-shared/package.json index 6f34a9d..e812e4a 100644 --- a/packages/service-shared/package.json +++ b/packages/service-shared/package.json @@ -3,7 +3,7 @@ "version": "0.1.0", "private": true, "sideEffects": false, - "main": "src/index.ts", + "module": "dist/index.mjs", "types": "dist/index.d.ts", "scripts": { "typecheck": "tsc" diff --git a/packages/shared/package.json b/packages/shared/package.json index e2b2c77..e4b57b0 100644 --- a/packages/shared/package.json +++ b/packages/shared/package.json @@ -3,7 +3,6 @@ "version": "0.1.0", "private": true, "sideEffects": false, - "main": "src/index.ts", "module": "dist/index.mjs", "types": "dist/index.d.ts", "scripts": { -- cgit v1.2.3-54-g00ecf