Conversation
There was a problem hiding this comment.
Pull request overview
Migrates the generated Python smart-contract TypeScript templates from CommonJS to ESM to support modern (ESM) dependencies and keep deploy/test workflows functional under Node 20+.
Changes:
- Switch TypeScript compilation settings to
NodeNextmodule + resolution. - Convert deploy entrypoints to be ESM-safe (
import.meta.url+fileURLToPath) and update dynamic deployer importing to use file URLs. - Update generated package scripts to use
tsx, and migrate Jest config tots-jest’s ESM preset (production template).
Reviewed changes
Copilot reviewed 11 out of 11 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| examples/generators/starter_python_smart_contract_typescript/tsconfig.json | Switch TS module settings to NodeNext for ESM-friendly resolution. |
| examples/generators/starter_python_smart_contract_typescript/smart_contracts/index.ts | Replace __dirname usage and adjust dynamic imports for ESM. |
| examples/generators/starter_python_smart_contract_typescript/package.json | Mark package as ESM and move deploy scripts from ts-node-dev to tsx. |
| examples/generators/production_python_smart_contract_typescript/tsconfig.json | Switch TS module settings to NodeNext for ESM-friendly resolution. |
| examples/generators/production_python_smart_contract_typescript/smart_contracts/index.ts | Replace __dirname usage and adjust dynamic imports for ESM. |
| examples/generators/production_python_smart_contract_typescript/package.json | Mark package as ESM, move deploy to tsx, and run Jest with ESM support flags. |
| examples/generators/production_python_smart_contract_typescript/jest.config.ts | Migrate Jest to ts-jest ESM preset and add ESM-related mappings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
examples/generators/starter_python_smart_contract_typescript/package.json
Show resolved
Hide resolved
examples/generators/production_python_smart_contract_typescript/package.json
Show resolved
Hide resolved
…ssing but the tests were passing because of peer dep on ts-jest
mrcointreau
left a comment
There was a problem hiding this comment.
From my understanding you kept ts-node for making jest work, you should be able to remove ts-node dependency completely by renaming jest.config.ts to jest.config.js and converting the TS syntax into JSDoc, e.g.
/*
* For a detailed explanation regarding each configuration property and type check, visit:
* https://jestjs.io/docs/configuration
*/
/** @type {import('jest').Config} */
const config = {
preset: 'ts-jest/presets/default-esm',
verbose: true,
transform: {
'^.+\\.tsx?$': ['ts-jest', { useESM: true }],
},
extensionsToTreatAsEsm: ['.ts'],
moduleNameMapper: {
'^(\\.{1,2}/.*)\\.js$': '$1',
},
testPathIgnorePatterns: ['node_modules', '.venv', 'coverage'],
testTimeout: 10000,
}
export default config
|
Refactored the jest.config.ts to jest.config.js and used suggested syntax. Removed |
chore: prepare for AlgoKit v4 beta (Python Generator)
This PR updates the Python generator to support the upcoming AlgoKit v4 beta. Following the same pattern as the TypeScript template, I've migrated the generated TypeScript deployment/testing code to be fully ESM-compatible.
Summary of Changes
tsconfig.jsontoNodeNextand added"type": "module"to the generatedpackage.json.ts-jest/presets/default-esmand updated the test script to use--experimental-vm-modules. This fixes the test failures I was seeing in the generated templates.smart_contracts/index.tsto useimport.meta.urlandpathToFileURLfor finding and loading deployer configs, replacing CJS__dirnamelogic.ts-node-devwithtsxin the generated templates and updated the README documentation.@algorandfoundationpackages to the latest v4 alphas (Utilsv10.0.0-alpha.40, etc.) and bumped TypeScript tov5.7.3.Important
Status: Draft
Like the other template PRs, this will remain a draft until the official v4 beta releases are live, at which point I'll update the alpha tags to stable versions.