Repository navigation
fix(concerto-core): remove ESM entrypoint from sideEffects to enable package-level tree shaking #1263
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
fix(concerto-core): remove ESM entrypoint from sideEffects to enable package-level tree shaking #1263
Changes from 3 commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
374393d
feat(concerto): add tree-shakeable package entrypoints
ea7f35c
fix(concerto-core): remove ESM entrypoint from sideEffects to enable …
mttrbrts 3073809
fix(concerto-core): emit dayjs-setup as .mjs and document build order
mttrbrts 63b4dd1
fix(concerto): address Copilot review on ESM tree-shaking PR
mttrbrts 6250541
fix(concerto): stub Node builtins in browser ESM instead of bare imports
mttrbrts 14cb981
fix(concerto-core): export Decorated from public API
mttrbrts cab5fc7
chore: remove stray issues.jsonl and add to .gitignore
mttrbrts f452b4c
fix(concerto): map ./types/* in exports to preserve deep-import compat
mttrbrts File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| node_modules/ | ||
| test-results/ | ||
| playwright-report/ | ||
| playwright/.cache/ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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" | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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'] } }, | ||
| ], | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| /* | ||
| * 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, Page } from '@playwright/test'; | ||
| import * as path from 'path'; | ||
|
|
||
| const CTO_BUNDLE = path.resolve(__dirname, '../../packages/concerto-cto/dist/concerto-cto.js'); | ||
| const CORE_BUNDLE = path.resolve(__dirname, '../../packages/concerto-core/dist/concerto-core.js'); | ||
|
|
||
| async function injectBundle(page: Page, bundlePath: string): Promise<void> { | ||
| await page.goto('about:blank'); | ||
| await page.addScriptTag({ path: bundlePath }); | ||
| } | ||
|
|
||
| test.describe('Concerto browser bundles', () => { | ||
| test('loads the CTO parser UMD bundle in Chromium', async ({ page }) => { | ||
| await injectBundle(page, CTO_BUNDLE); | ||
|
|
||
| const parsed = await page.evaluate(() => { | ||
| const { Parser } = (window as any)['concerto-cto']; | ||
| const ast = Parser.parse('namespace org.acme.test@1.0.0\nconcept Person { o String name }'); | ||
| return { | ||
| namespace: ast.namespace, | ||
| declarationCount: ast.declarations.length, | ||
| }; | ||
| }); | ||
|
|
||
| expect(parsed).toEqual({ | ||
| namespace: 'org.acme.test@1.0.0', | ||
| declarationCount: 1, | ||
| }); | ||
| }); | ||
|
|
||
| test('loads the core UMD bundle and uses ModelManager in Chromium', async ({ page }) => { | ||
| await injectBundle(page, CORE_BUNDLE); | ||
|
|
||
| const model = await page.evaluate(() => { | ||
| const { ModelManager } = (window as any)['concerto-core']; | ||
| const modelManager = new ModelManager(); | ||
| modelManager.addCTOModel( | ||
| 'namespace org.acme.browser@1.0.0\nasset Vehicle identified by vin { o String vin }', | ||
| 'vehicle.cto', | ||
| true | ||
| ); | ||
| const vehicle = modelManager.getType('org.acme.browser@1.0.0.Vehicle'); | ||
| return { | ||
| fqn: vehicle.getFullyQualifiedName(), | ||
| identifierFieldName: vehicle.getIdentifierFieldName(), | ||
| }; | ||
| }); | ||
|
|
||
| expect(model).toEqual({ | ||
| fqn: 'org.acme.browser@1.0.0.Vehicle', | ||
| identifierFieldName: 'vin', | ||
| }); | ||
| }); | ||
|
|
||
| test('keeps dayjs plugins available through the core bundle', async ({ page }) => { | ||
| await injectBundle(page, CORE_BUNDLE); | ||
|
|
||
| const currentTime = await page.evaluate(() => { | ||
| const { DateTimeUtil } = (window as any)['concerto-core']; | ||
| const result = DateTimeUtil.setCurrentTime('2023-03-17T12:30:00.000Z', 0); | ||
| return { | ||
| iso: result.currentTime.toISOString(), | ||
| offset: result.utcOffset, | ||
| }; | ||
| }); | ||
|
|
||
| expect(currentTime).toEqual({ | ||
| iso: '2023-03-17T12:30:00.000Z', | ||
| offset: 0, | ||
| }); | ||
| }); | ||
| }); | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.