-
-
Notifications
You must be signed in to change notification settings - Fork 670
First-class package management support #448
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
See my library https://github.com/as2d/as2d. Also, they need to add an included glue.ts source file in their compilation. |
Agreed, that seems like something we can do by means of implementing actual include paths with a node-like |
It will be great also support URL as path to source like deno does (may be in future) |
I think the best would be if module resolver is abstracted out. So that I can provide custom function which for a given module path / URL returns module contents. |
@dcodeIO @MaxGraey is it possible to prioritize this? Another related question:
|
@vgrichina AssemblyScript support |
@MaxGraey nice, I didn't realize that's a thing. What if there is any error during parsing. e.g. some of dependencies cannot be resolved? |
In particular I'm thinking of following:
What's the best way to implement this? At what stage is |
The idea of transforms is that you can hook into anything you'd like to, with the only hook implemented currently being afterParse. We can add more such hooks of course, like one that is called once the program has been created with all compile-time information being present, one that is called to intercept command line arguments, you name it.
That should be possible using some sort of hook as well, like one that intercepts any imports or a fallback that is called if an import is not found, so it can be filled in by the transform. I think we should start by implementing node-like module resolve and once that's done add a suitable set of hooks for your use case. |
@dcodeIO When we talked about module resolving last time we decide use |
We should make a decision that is forward thinking and gives us options later. Some kind of asconfig might be useful. |
Not specifically. Initially I planned to focus on this one next, but then decided to tackle #535 first which aims at getting a managed runtime up and running. Turned out runtime is quite a hard nut to crack, and it's taking longer than expected :( Sorry! |
@vgrichina I could deal with this issue, but after finished research about new better candidate for our sorting algorithm which use currently unstable approach for non-references and temporary slow fallback insertion-sort for reference elements which is not good. |
@MaxGraey https://en.wikipedia.org/wiki/Timsort is pretty solid. |
@vgrichina I compared GrailSort (it's block sort family), Timsort, nearly optimal mergesort family (one of the latest research paper) and one of the new algorithm from Gregorius van den Hoven. And I can say that |
@vgrichina
So as we see TimSort is not fastest. I'll share my bench code after porting |
@MaxGraey which algorithm is fastest highly depends on what data is sorted. E.g. different algorithms win on partly pre-sorted vs randomly shuffled data. In most of real world use cases you don't deal with randomly shuffled data. |
yes, I know, so that's why I mentioned about early results. But 100% random shuffled array is usually hardest case. I'll add different bench cases. btw I really happy about all rest cases as well. |
Any update on this? We have to go into ridiculous hacks without this feature: |
I think the best way to handle this to add to the compiler that if a file isn't found to call out to a plugin that uses the same method that typescript does to resolve the dependency. |
@willemneal yeah, probably even can use something like https://github.com/paulirish/node-resolve |
Personally I like putting my source inside the Everything outside of What I've been toying with so far is having I'm currently trying out I'm also not sure I want to keep It might make sense to have
What about falling back to Another options could be |
Well, VS Code can be configured to have file type associations for unknown file extensions, which also adds IntelliSense to files with said extensions. |
The respective PR #594 has been merged (thanks @willemneal !). The compiler will now search through |
Tried it out here: https://github.com/perlin-network/smart-contract-as Testing an example project, including
Example source code: import {Parameters, Tag, Transfer, send_transaction} from "smart-contract-as";
export function _contract_init(): void {}
export function _contract_on_money_received(): void {
const params = new Parameters();
const tx = new Transfer(params.sender_id, params.amount / 2);
send_transaction(Tag.TRANSFER, tx.marshal());
} Might I be missing anything? The library's code is within a single file in |
Hmm weird. I just cloned your repo and added a test project and ran the following:
This was using my global asc, which is the most up to date one. I then tried using the assemblyscript in your main repo and got the same error. I then ran |
Thank you for that! Looks like getting the dependency by default via |
What is the best way to add package management support to AssemblyScript?
I think that using existing package structure created by
asinit
(i.e. root of sources inassembly
withinnpm
package) is pretty good and we can go with it.However I don't think there is any support for actually using the package without specifying whole path.
E.g. let's say I use https://github.com/MaxGraey/bignum.wasm. My understanding is that currently I'll have to specify full path to the module I need, i.e. something like:
I want to be able to do something like:
What is the best way to achieve this? Is there any way to specify module search paths when calling compiler?
The text was updated successfully, but these errors were encountered: