surma / rollup-plugin-assemblyscript

A Rollup plugin that allows you to import AssemblyScript files and compiles them on-the-fly.
https://npm.im/rollup-plugin-assemblyscript
Apache License 2.0
74 stars 9 forks source link

Error: Unexpected token (Note that you need plugins to import files... #1

Closed munrocket closed 3 years ago

munrocket commented 4 years ago

Hello! Thank you for the great library!

Here my feedback:

Error:

[!] Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
wasm/mandel.as (1:5)
1: type float = f64;
        ^
2: type int = i32;
3: let LO: float = 0.;
Error: Unexpected token (Note that you need plugins to import files that are not JavaScript)
    at error (/home/munrocket/code/double.js/node_modules/rollup/dist/shared/rollup.js:10116:30)
    at Module.error (/home/munrocket/code/double.js/node_modules/rollup/dist/shared/rollup.js:14550:16)
    at tryParse (/home/munrocket/code/double.js/node_modules/rollup/dist/shared/rollup.js:14443:23)
    at Module.setSource (/home/munrocket/code/double.js/node_modules/rollup/dist/shared/rollup.js:14832:33)
    at /home/munrocket/code/double.js/node_modules/rollup/dist/shared/rollup.js:16692:20
    at async Promise.all (index 0)
    at async Promise.all (index 0)
    at async Promise.all (index 0)
    at async rollupInternal (/home/munrocket/code/double.js/node_modules/rollup/dist/shared/rollup.js:18088:18)
    at async execute (/home/munrocket/code/double.js/node_modules/rollup/dist/bin/rollup:1532:17)

File structure:

├──rollup.config.js
├──wasm
|   ├── mandel.as
|   └── mandel.wasm

Rollup config:

import { asc } from "rollup-plugin-assemblyscript";

//...

export default [
  {
    input: 'wasm/mandel.as',
    //output: { dir: 'wasm' },
    plugins: [
      asc({
        compilerOptions: {
          //outFile: 'wasm/mandel.wasm',
          optimizeLevel: 3,
          shrinkLevel: 2,
          runtime: 'none',
          importMemory: true
        }
      })
    ]
  }
];

I took part of the config in your package: letterboxer Here my repo where I am tried: double.js

Sorry, probably I miss something and I need additional rollup plugin for files.

munrocket commented 3 years ago

Seems .as not supported.