diff --git a/CHANGELOG.md b/CHANGELOG.md index 40fd479c..8d5cf756 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -17,6 +17,12 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm ## Unreleased +## [0.21.3](https://github.com/o1-labs/zkapp-cli/compare/0.21.2...0.21.3) - 2024-05-20 + +### Fixed + +- Fixed the deployment procedure for zkApps that use `o1js` of version < `v1.0.1` and that use local imports without the `.js` extension. [#654](https://github.com/o1-labs/zkapp-cli/pull/654) + ## [0.21.2](https://github.com/o1-labs/zkapp-cli/compare/0.21.0...0.21.2) - 2024-05-20 ### Changed diff --git a/package-lock.json b/package-lock.json index 8b81cda2..01c032d7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "zkapp-cli", - "version": "0.21.2", + "version": "0.21.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "zkapp-cli", - "version": "0.21.2", + "version": "0.21.3", "license": "Apache-2.0", "dependencies": { "acorn": "^8.11.3", diff --git a/package.json b/package.json index ad29957a..ff422e3a 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "zkapp-cli", - "version": "0.21.2", + "version": "0.21.3", "description": "CLI to create zkApps (zero-knowledge apps) for Mina Protocol", "homepage": "https://github.com/o1-labs/zkapp-cli/", "keywords": [ diff --git a/src/lib/helpers.js b/src/lib/helpers.js index a0205f72..964a3780 100644 --- a/src/lib/helpers.js +++ b/src/lib/helpers.js @@ -224,15 +224,25 @@ function resolveModulePath(moduleName, basePath) { // Resolve relative or absolute paths based on the current file's directory if (path.isAbsolute(moduleName) || moduleName.startsWith('.')) { - return path.resolve(basePath, moduleName); + let modulePath = path.resolve(basePath, moduleName); + if (!fs.existsSync(modulePath) && !modulePath.endsWith('.js')) { + modulePath += '.js'; + } + return modulePath; } else { // Module is a node_modules dependency const packagePath = path.join('node_modules', moduleName); const packageJsonPath = path.join(packagePath, 'package.json'); + // Try to resolve the main file using the package.json if (fs.existsSync(packageJsonPath)) { const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8')); - // Try to resolve the main file using the package.json + // Skip the primary entry point for the 'o1js' module + // This is necessary if the 'o1js' module is of < v1.0.1 + // https://github.com/o1-labs/o1js/commit/0a56798210e9e6678a2b18ca0cecd683b05ba6e5 + if (moduleName === 'o1js') { + delete packageJson['main']; + } let mainFile = packageJson.main || packageJson?.exports?.node?.import || 'index.js'; return path.join(packagePath, mainFile);