Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion apps/api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
"@casl/prisma": "^1.5.1",
"@douglasneuroinformatics/libcrypto": "catalog:",
"@douglasneuroinformatics/libjs": "catalog:",
"@douglasneuroinformatics/libnest": "^8.3.1",
"@douglasneuroinformatics/libnest": "^8.4.1",
"@douglasneuroinformatics/libpasswd": "catalog:",
"@douglasneuroinformatics/libstats": "catalog:",
"@faker-js/faker": "^9.4.0",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "opendatacapture",
"type": "module",
"version": "2.2.0",
"version": "2.2.1",
"private": true,
"packageManager": "pnpm@10.34.3",
"license": "Apache-2.0",
Expand Down
9 changes: 5 additions & 4 deletions packages/instrument-bundler/package.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
{
"name": "@opendatacapture/instrument-bundler",
"type": "module",
"version": "2.2.0",
"sideEffects": [
"**/cli.ts"
],
"version": "2.2.1",
"license": "Apache-2.0",
"publishConfig": {
"access": "public"
Expand All @@ -14,6 +11,10 @@
"url": "https://github.com/DouglasNeuroInformatics/OpenDataCapture.git",
"directory": "packages/instrument-bundler"
},
"sideEffects": [
"**/cli.ts",
"**/vendor/esbuild.ts"
],
"exports": {
".": "./src/index.ts"
},
Expand Down
13 changes: 10 additions & 3 deletions packages/instrument-bundler/src/build.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import * as esbuild from './vendor/esbuild.js';

import type { BundlerInput } from './schemas.js';
import type { BuildOutput } from './types.js';
import type { BuildResult } from './vendor/esbuild.js';
import type { BuildFailure, BuildResult } from './vendor/esbuild.js';

const DEFAULT_REACT_PACKAGE = 'react@19.x';

Expand Down Expand Up @@ -37,6 +37,10 @@ function resolveJsxImportSource(inputs: BundlerInput[]): string {
return `/runtime/v1/${packages.values().next().value ?? DEFAULT_REACT_PACKAGE}`;
}

function describeError(err: unknown): string {
return err instanceof Error ? `${err.name}: ${err.message}` : `${typeof err}: ${String(err)}`;
}

function parseBuildResult(result: BuildResult): BuildOutput {
const cssOutput = result.outputFiles?.find((output) => output.path.endsWith('bundle.css'));
const jsOutput = result.outputFiles?.find((output) => output.path.endsWith('bundle.js'));
Expand Down Expand Up @@ -95,9 +99,12 @@ export async function build({
} catch (err) {
const parseResult = await $BuildFailure.safeParseAsync(err);
if (parseResult.success) {
throw new InstrumentBundlerError('Unknown Error', { cause: err });
// the original error, rather than the parsed copy, so that `cause instanceof Error` holds downstream
throw new InstrumentBundlerError('Failed to Compile', { cause: err as BuildFailure, kind: 'ESBUILD_FAILURE' });
}
throw new InstrumentBundlerError('Failed to Compile', { cause: parseResult.error, kind: 'ESBUILD_FAILURE' });
// anything esbuild did not report as a compilation failure is a fault in the bundler itself, not in the
// instrument, so name it here instead of discarding it in favor of the schema mismatch that detected it
throw new InstrumentBundlerError(`Unexpected error while invoking esbuild: ${describeError(err)}`, { cause: err });
}
return parseBuildResult(result);
}
5 changes: 5 additions & 0 deletions packages/instrument-bundler/src/vendor/esbuild.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,11 @@ declare module 'esbuild-wasm' {
}
}

/**
* The exports below are assigned by a side effect, so this file must stay listed in the `sideEffects`
* field of package.json: a bundler permitted to treat it as pure drops the assignments while inlining
* the imports of it, leaving consumers with a bare `ReferenceError: build is not defined` at runtime.
*/
if (typeof window === 'undefined') {
var { build, transform } = await import('esbuild');
} else {
Expand Down
2 changes: 1 addition & 1 deletion packages/instrument-guidelines/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@opendatacapture/instrument-guidelines",
"type": "module",
"version": "2.2.0",
"version": "2.2.1",
"description": "Guidelines for authoring Open Data Capture instruments, intended to be read by an AI agent (e.g. Claude Code).",
"license": "Apache-2.0",
"publishConfig": {
Expand Down
2 changes: 1 addition & 1 deletion packages/playground-url/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@opendatacapture/playground-url",
"type": "module",
"version": "2.2.0",
"version": "2.2.1",
"sideEffects": [
"**/cli.ts"
],
Expand Down
2 changes: 1 addition & 1 deletion packages/serve-instrument/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@opendatacapture/serve-instrument",
"type": "module",
"version": "2.2.0",
"version": "2.2.1",
"license": "Apache-2.0",
"publishConfig": {
"access": "public"
Expand Down
10 changes: 5 additions & 5 deletions pnpm-lock.yaml

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

2 changes: 1 addition & 1 deletion runtime/v1/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "@opendatacapture/runtime-v1",
"type": "module",
"version": "2.2.0",
"version": "2.2.1",
"author": {
"name": "Douglas Neuroinformatics",
"email": "support@douglasneuroinformatics.ca"
Expand Down
Loading