Skip to content

Commit

Permalink
Fix for the deployment procedure of zkApps that use o1js of version…
Browse files Browse the repository at this point in the history
… < `v1.0.1` and that use local imports without the `.js` extension. (#654)
  • Loading branch information
shimkiv authored May 20, 2024
1 parent 5d6eeb4 commit f6b2cfc
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -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": [
Expand Down
14 changes: 12 additions & 2 deletions src/lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit f6b2cfc

Please sign in to comment.