feat: webpack typescript logic to support imports#50
Draft
dselman wants to merge 3 commits into
Draft
Conversation
Signed-off-by: dselman <danscode@selman.org>
Signed-off-by: dselman <danscode@selman.org>
Contributor
|
This PR is stale because it has been open with no activity. Remove the stale label or comment to keep it active. Only items with maintainer engagement are auto-closed. |
…optional variables Update template-engine to the TypeScript markdown-transform 1.0.1 stack and add compile-time detection of unguarded optional variables (issue #11). markdown-transform / cicero-core integration: - @accordproject/cicero-core 0.28.0 -> 1.0.1 (markdown-transform now dedupes to 1.0.1; the stale 0.18.0 dual-version tree and the "window is not defined" failure from cicero-core's old webpack main bundle are gone) - TemplateArchiveProcessor: fix the deep import (cicero-core/types/src/script -> cicero-core/lib/script) and drop the bogus `{ options }` arg to the now-typed fromMarkdownTemplate (it only accepts `{ verbose? }`) - update test archive cicero range ^0.25.0 -> ^1.0.0; refresh TypeScriptCompiler / TypeScriptCompilationContext snapshots Issue #11 - unguarded optional variables: - TemplateMarkInterpreter.checkTypes now flags variable definitions that reference an optional model property and are not enclosed by an {{#optional}} / {{#if}} guard - guard the optional `age` in the playground template; update snapshots BREAKING CHANGE: using an optional property without a guard now throws a compile-time error instead of silently drafting null. Templates must add {{#optional x}} or {{#if x}} guards around optional variables. Co-Authored-By: Chibuezem Marvinrose <rozzeymarvin32@gmail.com> Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com> Signed-off-by: dselman <danscode@selman.org>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Adds support for importing third-party modules in Template Logic code.
See
test/archives/latedeliveryandpenalty-typescript/logic/logic.tsfor an updated template logic archive that uses Dayjs and Decimal.This PR refines the notion of the runtime that is required for an AP template archive. The runtime for the archive is specified in the package.json for the archive, under the
accordproject.runtimekey. Two values are currently supported:Static / Offline Compilation
Compilation of a TS archive to bundled JS archive (the logic is bundled into an ESM module) is best done offline and within your IDE, so you benefit from full type-checking and editor support.
For example, cd into
test/archives/latedeliveryandpenalty-typescriptand runnpm run buildwhich will compile the TypeScript logic for the template and create a bundled logic.js file inside the template logic directory using Webpack and tic (the Typescript compiler). You can then change the package.json from a TS archive:To a JS archive:
Just-In-Time Compilation
There is also experimental support for JIT compiling TS template archives to executable JS archives. If you attempt to trigger/init a TS archive it will be JIT compiled to a JS archive before execution.
You can use the
TemplateArchiveProcessor.transpileLogicToJavaScriptto transpile and bundle the logic of a TS archive to JS. See theTemplateArchiveProcessor.test.tsfile for details. Note that there is an option to save the output logic and updated package.json to disk.