Skip to content
This repository has been archived by the owner on Apr 8, 2020. It is now read-only.

near-runtime-ts and near-shell should depend on a fixed version of AssemblyScript compiler #85

Closed
MaksymZavershynskyi opened this issue Sep 22, 2019 · 2 comments
Assignees

Comments

@MaksymZavershynskyi
Copy link
Contributor

near-runtime-ts and near-shell should depend on a fixed version of AssemblyScript compiler instead of depending on the master branch.

We push code into https://github.com/nearprotocol/assemblyscript without prior staging and testing as the result, sometimes it breaks things, see https://docs.google.com/document/d/1pzujH0VxMA5aCC2XCgXX7G4o2EaZKfCPgfIP6T-oIVM/edit# Unfortunately, because we do not do versioning the breakage propagates everywhere immediately.

@DanielRX
Copy link
Contributor

I feel like the correct way is to mirror solidity, allow the user to specify the compiler version and make the runtime agnostic

@willemneal
Copy link
Contributor

I agree. The compiler should also be published to npm with a name like near-assemblyscript as to not be confused with the normal assemblyscript compiler. I also think that we shouldn't rely on gulp since the build process doesn't require multiple steps as it did before, instead just create something like asconfig.js in each project which will pass the compiler options and allow users to customize it if they want to have debug builds, etc. near build could then be the entry to compiling the project and would expect this file. We also don't need to implement the readFile, writeFile, etc functions since the compiler has defaults when building on node.

Currently the runtime has assemblyscript as a devDependency and if we made it one for near-shell too then it will just use the local installation of the compiler imported in the asconfig.js.

Also since near-shell depends on the runtime, the only deps a new project would need is near-assemblyscript and near-shell.

Then for NEARStudio we just do what WebAssembly.studio does

  asc.main = (main => (args, options, fn) => {
    if (typeof options === "function") {
      fn = options;
      options = undefined;
    }
    return main(args, options || {
      stdout: asc.createMemoryStream(),
      stderr: asc.createMemoryStream(logLn),
      readFile: (filename, baseDir) => {
        const file = project.getFile(baseDir + "/" + filename.replace(/^\//, ""));
        return file ? file.data : null;
      },
      writeFile: (filename, contents) => {
        const name = filename.startsWith("../") ? filename.substring(3) : filename;
        const type = fileTypeForExtension(name.substring(name.lastIndexOf(".") + 1));
        project.newFile(name, type, true).setData(contents);
      },
      listFiles: () => []
    }, fn);
  })(asc.main);

For now I think the best next step is to publish to npm so that we can start to have versions to pin projects to.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants