Skip to content

[Package Management] Resolve `main` file when only the package name is provided in `#import`/`#include`

Melwyn Saldanha requested to merge melwyn95/support-main-file-in-import into dev

Motivation and Context

While importing a package it was necessary to provide the path to file inside that package you want to use,

This led to cumersome DX.

Description

The above mentioned problem can be solved by allowing users to import just that package name, and

ModRes behind the scenes will resolve the path to the file specifed by main field in the LIGO manifest.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Performance improvement (non-breaking change that improves performance)
  • None (change with no changelog)

Changelog

For a file like

#import "@ligo/bigarray" "BA"

let test = BA.concat [1 ; 2 ; 3] [4 ; 5 ; 6]

Before change

$ ligo.55 run test main.mligo 
File "main.mligo", line 1, characters 0-29:
  1 | #import "@ligo/bigarray" "BA"
  2 | 
File "@ligo/bigarray" not found.

After change

$ ligo run test main.mligo
Everything at the top-level was executed.
- test exited with value [1 ; 2 ; 3 ; 4 ; 5 ; 6].

Checklist:

  • Changes follow the existing coding style (use dune @fmt to check).
  • Tests for the changes have been added (for bug fixes / feature).
  • Documentation has been updated.
  • Changelog description has been added (if appropriate).
  • Start titles under ## Changelog section with #### (if appropriate).
  • There is no image or uploaded file in changelog
  • Examples in changed behaviour have been added to the changelog (for breaking change / feature).
Edited by Melwyn Saldanha

Merge request reports

Loading