Skip to content

Changing source file extension #719

Closed

Description

@bobbinth

Is it possible to change file extension for AssemblyScript source files to something other than .ts (e.g. .as)?

I tried doing something like:

asc assembly/index.as -b build/optimized.wasm

But getting the following error:

Entry file 'assembly/index.as.ts' not found.

Activity

  1. dcodeIO commented on Jul 19, 2019

    @dcodeIO
    Member

    The .ts extension is the only one recognized currently, but if there's a need for another one, from an AssemblyScript perspective I'd say "why not". Note, though, that adding alternative file extensions to TypeScript (if you'd like to utilize it for example with VSCode for syntax highlighting) appeared to be pretty much impossible without forking it the last time I checked.

  2. bobbinth commented on Jul 19, 2019

    @bobbinth
    Author

    I think you can make it kind of work in VS Code:

    First, set file association settings like so:

    "files.associations": {
      "*.as": "typescript"
    }
    

    Then instead of relying on tsconfig.json file, use /// directives at the top of .as files like so:

    /// <reference path="../../node_modules/assemblyscript/std/assembly/index.d.ts" />
    
  3. dcodeIO commented on Jul 19, 2019

    @dcodeIO
    Member

    Iirc correctly it used to be more complicated than that, perhaps because import statements didn't pick up files with alternative extensions and similar things. If it's somehow possible, though, feel free to investigate further :)

    For a bit of additional background: My stance on this so far was to delay this until there's a dedicated language service for AssemblyScript, which in turn is likely to allow picking whatever file extension(s) we'd like.

  4. bobbinth commented on Jul 19, 2019

    @bobbinth
    Author

    Yeah, import statements don't seem to work for .as extensions. Though, they do work for .tsx extensions.

    btw, the reason for the question in the first place is that I'm trying to create a project that has both AS and TS files, and I'm trying to figure out what's the best way to clearly separate them.

  5. dcodeIO commented on Jul 19, 2019

    @dcodeIO
    Member

    What I've been doing so far is to have two source directories, both with their own tsconfig.json. For example assembly/ for AS and src/ for TS.

  6. bobbinth commented on Jul 20, 2019

    @bobbinth
    Author

    I do the same - but I wanted to have a single TS file with loader code etc. per module. The way I decided to do this is by using .as.ts as file extension for my AS files and then telling TS compiler to ignore any files that end with .as.ts. So, my directory structure looks something like this:

    .
    ├── assembly
    |   ├── fooModule
    |   |   ├── index.ts
    |   |   ├── foo1.as.ts
    |   |   └── foo2.as.ts
    |   └── barModule
    |   |   ├── index.ts
    |   |   ├── bar1.as.ts
    |   |   └── bar2.as.ts
    |   └── index.ts
    

    I'm closing this issue since I don't need it any more, and this is probably better addresses as a part of a bigger issue (e.g. #390).

  7. munrocket commented on Dec 2, 2019

    @munrocket

    @dcodeIO Bump! Can we create support for optional extensions for full file names?

  8. ivanjeremic commented on Jan 16, 2021

    @ivanjeremic

    I follow the discussion around the extension now a bit longer and I want to suggest a total rebrand from AssemblyScript to binode.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions