Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
81e4d09
feat(concerto): add tree-shakeable package entrypoints
Jun 14, 2026
fdb6c23
fix(concerto-core): remove ESM entrypoint from sideEffects to enable …
mttrbrts Jun 14, 2026
516d086
fix(concerto-core): emit dayjs-setup as .mjs and document build order
mttrbrts Aug 28, 2026
1fa8daa
fix(concerto): address Copilot review on ESM tree-shaking PR
mttrbrts Aug 28, 2026
adbe8e8
fix(concerto): stub Node builtins in browser ESM instead of bare imports
mttrbrts Aug 28, 2026
27500e7
fix(concerto-core): export Decorated from public API
mttrbrts Aug 28, 2026
68f0ff5
chore: remove stray issues.jsonl and add to .gitignore
mttrbrts Aug 28, 2026
8a6e9f9
feat(concerto-core): ESM pilot — modelfile.ts + securityexception.ts …
mttrbrts Aug 28, 2026
d1344b1
feat(concerto-core): native ESM migration — model batch (#1304)
mttrbrts Aug 28, 2026
87db5c0
feat(concerto-core): native ESM migration — serializer batch (#1304)
mttrbrts Aug 28, 2026
4a642cf
feat(concerto-core): native ESM migration — introspect-b batch (#1304)
mttrbrts Aug 28, 2026
081acec
feat(concerto-util): native ESM migration — util batch (#1304)
mttrbrts Aug 28, 2026
2d7b2a2
feat(concerto-core): native ESM migration — introspect-a batch (#1304)
mttrbrts Aug 28, 2026
92ec07b
feat(concerto-core): native ESM migration — core-root batch (#1304)
mttrbrts Aug 28, 2026
1d1b86e
Merge branch 'esm/core-model' into esm/integration
mttrbrts Aug 28, 2026
ebdd6b6
Merge branch 'esm/core-serializer' into esm/integration
mttrbrts Aug 28, 2026
00f1a8b
Merge branch 'esm/core-introspect-a' into esm/integration
mttrbrts Aug 28, 2026
8f9287f
Merge branch 'esm/core-introspect-b' into esm/integration
mttrbrts Aug 28, 2026
fc43d52
Merge branch 'esm/util' into esm/integration
mttrbrts Aug 28, 2026
5e90dc0
Merge branch 'esm/core-root' into esm/integration
mttrbrts Aug 28, 2026
31b6830
fix(esm): resolve integration seam type errors after native-ESM migra…
mttrbrts Aug 28, 2026
d9a6f78
fix(esm): use namespace import for uuid in factory (no ESM default ex…
mttrbrts Aug 28, 2026
7a010ce
docs(esm): add #1304 plan + cross-session handoff
mttrbrts Aug 28, 2026
c747d9a
test(esm): migrate deep source requires to named exports (#1304)
mttrbrts Aug 28, 2026
b9fadcf
feat(concerto-cto,concerto-vocabulary): native ESM migration (#1304)
mttrbrts Aug 28, 2026
1285e83
fix(build): emit ESM as a module graph so packages actually tree-shake
mttrbrts Aug 28, 2026
f2742cd
docs(esm): add MIGRATION.md for v5 and record the Option B decision
mttrbrts Aug 28, 2026
f78226c
fix(concerto-core): restore \u200C/\u200D escapes in ID_REGEX
mttrbrts Aug 28, 2026
3cb7b87
fix(build): emit separate node and browser ESM builds
mttrbrts Aug 28, 2026
27c05dc
fix(build): bind process in the browser ESM build
claude Aug 28, 2026
36f50be
test(esm): add a Node ESM smoke test and run it in CI
claude Aug 28, 2026
b1df6ff
docs(esm): document the two ESM graphs and the dual-package hazard
claude Aug 28, 2026
f9601c9
docs(esm): drop the #1304 planning document from the repo
mttrbrts Aug 28, 2026
dceada5
fix(build): keep runtime dependencies external in the node ESM build
mttrbrts Aug 29, 2026
886e915
build: run the ESM smoke test as part of the build
mttrbrts Aug 29, 2026
7a8cd60
feat(concerto)!: drop the UMD browser bundles
mttrbrts Aug 29, 2026
0489053
docs(esm): correct the browser-resolution notes for the UMD removal
mttrbrts Aug 29, 2026
ada293d
build: externalise concerto-metamodel now that 3.17.0 is lexable
mttrbrts Aug 29, 2026
f3c0650
docs(esm): re-measure the tree-shaking table under one consistent method
mttrbrts Aug 29, 2026
00c4046
refactor(types)!: tighten introspect and model types, drop redeclared…
mttrbrts Aug 31, 2026
a6a5688
fix(esm): address type-safety review comments on PR #1306
claude Sep 4, 2026
1a002d8
refactor(types)!: fix the signatures the casts were hiding
claude Sep 4, 2026
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
52 changes: 52 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,58 @@ jobs:
parallel: true
fail-on-error: false

e2e:
name: Browser E2E (Chromium)
runs-on: ubuntu-latest
needs:
- build

steps:
- name: git checkout
uses: actions/checkout@v4

- name: Use Node.js 22.x
uses: actions/setup-node@v4
with:
node-version: 22.x
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Build packages and browser bundles
run: npm run build

- name: Get Playwright version
id: playwright-version
run: echo "version=$(node -p 'require(\"@playwright/test/package.json\").version')" >> "$GITHUB_OUTPUT"

- name: Cache Playwright browsers
id: playwright-cache
uses: actions/cache@v4
with:
path: ~/.cache/ms-playwright
key: playwright-${{ runner.os }}-${{ steps.playwright-version.outputs.version }}

- name: Install Playwright Chromium
if: steps.playwright-cache.outputs.cache-hit != 'true'
run: npx playwright install --with-deps chromium

- name: Install Playwright system deps only (cache hit)
if: steps.playwright-cache.outputs.cache-hit == 'true'
run: npx playwright install-deps chromium

- name: Run browser e2e tests
run: npx playwright test --config e2e/playwright.config.ts --reporter=list

- name: Upload Playwright report on failure
if: failure()
uses: actions/upload-artifact@v4
with:
name: playwright-report
path: e2e/playwright-report
retention-days: 7

notify:
needs:
- build
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -77,3 +77,6 @@ umd

# TypeScript build folder
dist

# beads issue tracker data (local only)
issues.jsonl
2 changes: 2 additions & 0 deletions DEVELOPERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ npm run test

> **Note:** The build step is required because some packages (like `concerto-linter`) depend on other workspace packages that need to be compiled first. The CI workflows follow this same pattern: build first, then test.

> **Note:** Always build the whole monorepo with `npm run build` (which builds in dependency order), not a single package in isolation. Because each package's `exports.import` condition resolves to its `dist/esm/index.mjs`, building one package alone can fail if a workspace dependency's ESM output does not yet exist. `npm run build:ordered` (the default `build` script) handles this ordering; CI relies on it too.

If you're working on a specific package, you can run tests for just that package:

```shell
Expand Down
468 changes: 468 additions & 0 deletions MIGRATION.md

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions e2e/.eslintrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
root: true
env:
es6: true
node: true
parser: '@typescript-eslint/parser'
plugins:
- '@typescript-eslint'
extends:
- 'eslint:recommended'
- 'plugin:@typescript-eslint/recommended'
parserOptions:
ecmaVersion: 2020
sourceType: module
rules:
indent:
- error
- 4
linebreak-style:
- error
- unix
quotes:
- error
- single
semi:
- error
- always
no-unused-vars: 'off'
'@typescript-eslint/no-unused-vars':
- error
- args: none
no-console: warn
curly: error
eqeqeq: error
no-throw-literal: error
no-var: error
dot-notation: error
no-tabs: error
no-trailing-spaces: error
4 changes: 4 additions & 0 deletions e2e/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
node_modules/
test-results/
playwright-report/
playwright/.cache/
13 changes: 13 additions & 0 deletions e2e/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"name": "concerto-e2e",
"version": "1.0.0",
"private": true,
"description": "End-to-end browser tests for Concerto web bundles.",
"scripts": {
"pretest:e2e": "npm --prefix .. run build",
"test:e2e": "playwright test"
},
"devDependencies": {
"@playwright/test": "^1.60.0"
}
}
30 changes: 30 additions & 0 deletions e2e/playwright.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { defineConfig, devices } from '@playwright/test';

export default defineConfig({
testDir: './tests',
fullyParallel: true,
forbidOnly: !!process.env.CI,
retries: process.env.CI ? 1 : 0,
workers: process.env.CI ? 1 : undefined,
reporter: 'list',
use: {
trace: 'on-first-retry',
},
projects: [
{ name: 'chromium', use: { ...devices['Desktop Chrome'] } },
],
});
187 changes: 187 additions & 0 deletions e2e/tests/browser-bundles.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,187 @@
/*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import { test, expect, type Page } from '@playwright/test';
import * as path from 'path';
import { startEsmServer, type EsmServer } from './support/esm-static-server';

// The `browser` export condition (see each package's package.json "exports")
// resolves consumers to dist/esm-browser/index.mjs. That file is not a single
// bundle: it is a module graph that imports sibling `./chunk-*.mjs` files by
// relative path, and (for concerto-core and concerto-cto) imports its
// workspace dependencies as bare specifiers ("@accordproject/concerto-util",
// "@accordproject/concerto-cto") because those packages are external to the
// browser build. These tests exercise exactly that graph, the way a real
// browser consumer resolving through the "browser" condition would load it.
const PACKAGES_ROOT = path.resolve(__dirname, '../../packages');

const MOUNTS = [
{ prefix: '/concerto-core/', dir: path.join(PACKAGES_ROOT, 'concerto-core/dist/esm-browser') },
{ prefix: '/concerto-cto/', dir: path.join(PACKAGES_ROOT, 'concerto-cto/dist/esm-browser') },
{ prefix: '/concerto-util/', dir: path.join(PACKAGES_ROOT, 'concerto-util/dist/esm-browser') },
];

let server: EsmServer;

test.beforeAll(async () => {
server = await startEsmServer(MOUNTS);
});

test.afterAll(async () => {
await server.close();
});

/**
* Installs an import map so that the bare workspace specifiers the browser
* ESM graph imports ("@accordproject/concerto-util", "@accordproject/concerto-cto")
* resolve to the sibling packages' served browser ESM graphs, then navigates
* to a blank page ready to `import()` from `server`.
*
* This is the crux of testing the browser ESM graph in isolation: outside of
* a bundler, nothing else tells the browser how to resolve those bare
* specifiers, so an import map standing in for "the bundler's resolution
* step" is required for concerto-core and concerto-cto to load at all.
*
* @param {Page} page - the Playwright page to prepare.
* @returns {Promise<void>} resolves once the import map is installed.
*/
async function withWorkspaceImportMap(page: Page): Promise<void> {
// Navigate to a same-origin page served by our own server rather than
// about:blank: Chromium's Private Network Access check blocks a page
// with an opaque origin from fetching loopback addresses, which is
// exactly what dynamically importing our served modules requires.
await page.goto(server.baseUrl);
await page.addScriptTag({
type: 'importmap',
content: JSON.stringify({
imports: {
'@accordproject/concerto-util': `${server.baseUrl}/concerto-util/index.mjs`,
'@accordproject/concerto-cto': `${server.baseUrl}/concerto-cto/index.mjs`,
},
}),
});
}

test.describe('Concerto browser ESM graph', () => {
test('parses a CTO model via the concerto-cto browser ESM graph', async ({ page }) => {
await withWorkspaceImportMap(page);

const parsed = await page.evaluate(async (moduleUrl) => {
const { Parser } = await import(moduleUrl);
const ast = Parser.parse('namespace org.acme.test@1.0.0\nconcept Person { o String name }');
return {
namespace: ast.namespace,
declarationCount: ast.declarations.length,
declarationName: ast.declarations[0].name,
};
}, `${server.baseUrl}/concerto-cto/index.mjs`);

expect(parsed).toEqual({
namespace: 'org.acme.test@1.0.0',
declarationCount: 1,
declarationName: 'Person',
});
});

test('builds a ModelManager and round-trips a resource via the concerto-core browser ESM graph', async ({ page }) => {
await withWorkspaceImportMap(page);

const result = await page.evaluate(async (moduleUrl) => {
const { ModelManager, Factory, Serializer } = await import(moduleUrl);

const modelManager = new ModelManager();
modelManager.addCTOModel(
'namespace org.acme.browser@1.0.0\nasset Vehicle identified by vin { o String vin o String colour }',
'vehicle.cto',
true
);

const vehicleType = modelManager.getType('org.acme.browser@1.0.0.Vehicle');

const factory = new Factory(modelManager);
const resource = factory.newResource('org.acme.browser@1.0.0', 'Vehicle', 'VIN-123');
resource.colour = 'red';

const serializer = new Serializer(factory, modelManager);
const json = serializer.toJSON(resource);
const revived = serializer.fromJSON(json);

return {
fqn: vehicleType.getFullyQualifiedName(),
identifierFieldName: vehicleType.getIdentifierFieldName(),
json,
revivedVin: revived.vin,
revivedColour: revived.colour,
};
}, `${server.baseUrl}/concerto-core/index.mjs`);

expect(result).toEqual({
fqn: 'org.acme.browser@1.0.0.Vehicle',
identifierFieldName: 'vin',
json: {
$class: 'org.acme.browser@1.0.0.Vehicle',
$identifier: 'VIN-123',
vin: 'VIN-123',
colour: 'red',
},
revivedVin: 'VIN-123',
revivedColour: 'red',
});
});

// This is the highest-value test in the file. dayjs plugin registration
// (dayjs.extend(...) in dayjs-setup.ts) is the one genuine module-level
// side effect in the dependency tree, and therefore the piece most at
// risk of being dropped by tree-shaking when going from a UMD bundle
// (where the whole thing is always evaluated) to an ESM graph (where a
// bundler is free to prune anything it decides is unused). If either the
// `utc` or `quarterOfYear` dayjs plugin failed to register, the calls
// below would throw or return wrong values instead of round-tripping.
test('keeps dayjs plugins registered through the concerto-core browser ESM graph', async ({ page }) => {
await withWorkspaceImportMap(page);

const result = await page.evaluate(async ({ coreUrl, dayjsSetupUrl }) => {
const { DateTimeUtil } = await import(coreUrl);
// dayjs-setup.mjs is the module that calls dayjs.extend(utc) and
// dayjs.extend(quarterOfYear); import it directly to assert the
// registration itself survived, not just code that happens to
// depend on it.
const { default: dayjs } = await import(dayjsSetupUrl);

// Exercises the `utc` plugin end-to-end through the public
// DateTimeUtil API, mirroring how ModelManager/Resource use it.
const currentTime = DateTimeUtil.setCurrentTime('2023-03-17T12:30:00.000Z', 0);

// Exercises the `quarterOfYear` plugin directly: it is registered
// but never exercised by any other code path in concerto-core,
// so this is the only thing that would catch a bundler dropping it.
const quarter = dayjs.utc('2023-03-17T12:30:00.000Z').quarter();

return {
iso: currentTime.currentTime.toISOString(),
offset: currentTime.utcOffset,
quarter,
};
}, {
coreUrl: `${server.baseUrl}/concerto-core/index.mjs`,
dayjsSetupUrl: `${server.baseUrl}/concerto-core/dayjs-setup.mjs`,
});

expect(result).toEqual({
iso: '2023-03-17T12:30:00.000Z',
offset: 0,
quarter: 1,
});
});
});
Loading
Loading