Skip to content
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

Changing source file extension #719

Closed
bobbinth opened this issue Jul 18, 2019 · 8 comments
Closed

Changing source file extension #719

bobbinth opened this issue Jul 18, 2019 · 8 comments
Labels

Comments

@bobbinth
Copy link

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.
@dcodeIO
Copy link
Member

dcodeIO commented Jul 19, 2019

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.

@bobbinth
Copy link
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" />

@dcodeIO
Copy link
Member

dcodeIO commented Jul 19, 2019

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.

@bobbinth
Copy link
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.

@dcodeIO
Copy link
Member

dcodeIO commented Jul 19, 2019

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.

@bobbinth
Copy link
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).

@munrocket
Copy link

munrocket commented Dec 2, 2019

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

@ivanjeremic
Copy link

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
Labels
Projects
None yet
Development

No branches or pull requests

4 participants