Skip to content
This repository was archived by the owner on Sep 6, 2022. It is now read-only.

Could not load asc:{path to file}/file.as #2

Closed
ghost opened this issue Aug 30, 2020 · 4 comments
Closed

Could not load asc:{path to file}/file.as #2

ghost opened this issue Aug 30, 2020 · 4 comments

Comments

@ghost
Copy link

ghost commented Aug 30, 2020

I'm super excited to try out assemblyscript in a project. thanks for building this plugin!

when i used this plugin to try the add example, I keep getting:

[!] (plugin assemblyscript) Error: Could not load asc:/correct/path/to/file/file.as (imported by file/using/this/import/service.js)

In the file.as I have

export function add(a: i32, b: i32): i32 {
  return a + b;
}

in the service.js i have:

import {instancePromise} from 'asc:./file.as';
class Service{
  ...
  async doAdd(a, b) {
    const instance = await instancePromise;
    return instance.exports.add(a, b);
  }
}

The only thing that I'm not sure about is that I'm using @open-wc's rollup config, so my rollup config looks like:

import {createSpaConfig} from '@open-wc/building-rollup';
import gzipPlugin from 'rollup-plugin-gzip'
import { asc } from "rollup-plugin-assemblyscript";

const config = createSpaConfig({ legacyBuild: false, injectServiceWorker: false });

export default {
  ...config,
  input: './src/index.html',
  plugins: [
    asc(),
    ...config.plugins,
    gzipPlugin({
      filter: /\.(js|mjs|json|css)$/
    }),
  ],
}

I guess my main question is, am I missing something obvious on the plugin side of things?

Once again, thank you for building the plugin!

@surma
Copy link
Owner

surma commented Aug 31, 2020

Currently on vacation, but if you put a sample into a gist or a GitHub repository, I'll take a look when I'm back next week :)

@ghost
Copy link
Author

ghost commented Sep 5, 2020

nice! i hope it goes well (or was good).

so. i have a repo, but while setting it up, i realized the problem was with me using .as instead of .ts I went ahead and uploaded the repo with the .as if you still wanted to see it. https://github.com./andyricchuiti/as-test.

but if you change the file type to .ts everything works great and is seemless! my guess is the compiler is now strict with the file type?

@surma
Copy link
Owner

surma commented Sep 7, 2020

Yeah, that is the AssemblyScript compiler enforcing .ts extension I think. Glad you figured it out :)

@surma surma closed this as completed Sep 7, 2020
@munrocket
Copy link
Contributor

It has but this flag in another format, --extension .as instead of --extension=.as. Plugin enforcing the old version of AS even if you installed a new one. I created a quick fix for .as support #3 and updated version of AS but should we allow to pass any string to compiler and take AS that stored in your current repo? I can fix this but I don't have any feedback right now.

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

2 participants