Skip to content

Commit f6b2cfc

Browse files
authored
Fix for the deployment procedure of zkApps that use o1js of version < v1.0.1 and that use local imports without the .js extension. (#654)
1 parent 5d6eeb4 commit f6b2cfc

File tree

4 files changed

+21
-5
lines changed

4 files changed

+21
-5
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,12 @@ This project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.htm
1717

1818
## Unreleased
1919

20+
## [0.21.3](https://github.com/o1-labs/zkapp-cli/compare/0.21.2...0.21.3) - 2024-05-20
21+
22+
### Fixed
23+
24+
- 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)
25+
2026
## [0.21.2](https://github.com/o1-labs/zkapp-cli/compare/0.21.0...0.21.2) - 2024-05-20
2127

2228
### Changed

package-lock.json

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "zkapp-cli",
3-
"version": "0.21.2",
3+
"version": "0.21.3",
44
"description": "CLI to create zkApps (zero-knowledge apps) for Mina Protocol",
55
"homepage": "https://github.com/o1-labs/zkapp-cli/",
66
"keywords": [

src/lib/helpers.js

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,15 +224,25 @@ function resolveModulePath(moduleName, basePath) {
224224

225225
// Resolve relative or absolute paths based on the current file's directory
226226
if (path.isAbsolute(moduleName) || moduleName.startsWith('.')) {
227-
return path.resolve(basePath, moduleName);
227+
let modulePath = path.resolve(basePath, moduleName);
228+
if (!fs.existsSync(modulePath) && !modulePath.endsWith('.js')) {
229+
modulePath += '.js';
230+
}
231+
return modulePath;
228232
} else {
229233
// Module is a node_modules dependency
230234
const packagePath = path.join('node_modules', moduleName);
231235
const packageJsonPath = path.join(packagePath, 'package.json');
232236

237+
// Try to resolve the main file using the package.json
233238
if (fs.existsSync(packageJsonPath)) {
234239
const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf-8'));
235-
// Try to resolve the main file using the package.json
240+
// Skip the primary entry point for the 'o1js' module
241+
// This is necessary if the 'o1js' module is of < v1.0.1
242+
// https://github.com/o1-labs/o1js/commit/0a56798210e9e6678a2b18ca0cecd683b05ba6e5
243+
if (moduleName === 'o1js') {
244+
delete packageJson['main'];
245+
}
236246
let mainFile =
237247
packageJson.main || packageJson?.exports?.node?.import || 'index.js';
238248
return path.join(packagePath, mainFile);

0 commit comments

Comments
 (0)