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

TypeError [ERR_INVALID_ARG_TYPE]: The "from" argument must be of type string. Received undefined #6

Closed aminya closed 3 years ago

aminya commented 3 years ago

I am trying to reproduce the addition example in the readme, but I get this error:

TypeError [ERR_INVALID_ARG_TYPE]: The "from" argument must be of type string. Received undefined
    at new NodeError (node:internal/errors:278:15)
    at validateString (node:internal/validators:123:11)
    at relative (node:path:460:5)
    at referenceId.emitFile.type (C:\Users\aminy\minimap\node_modules\rollup-plugin-assemblyscript\index.js:114:11)
    at new Promise (<anonymous>)
    at Object.load (C:\Users\aminy\minimap\node_modules\rollup-plugin-assemblyscript\index.js:109:13) {
  code: 'ERR_INVALID_ARG_TYPE'
}

C:\Users\aminy\minimap\node_modules\binaryen\index.js:54
function Ka(){var b=a.preRun.shift();Fa.unshift(b)}var L=0,La=null,Ma=null;a.preloadedImages={};a.preloadedAudios={};function q(b){if(a.onAbort)a.onAbort(b);v(b);wa=!0;throw new va("abort("+b+"). Build with
-s ASSERTIONS=1 for more info.");}function Na(b){var d=Oa;return String.prototype.startsWith?b.startsWith(d):0===b.indexOf(d)}var Oa="data:application/octet-stream;base64,",Pa="<<< WASM_BINARY_FILE >>>";if(!
Na(Pa)){var Qa=Pa;Pa=a.locateFile?a.locateFile(Qa,p):p+Qa}var Ra,Sa;
                                                                                                                                                                              ^
Error: abort(TypeError [ERR_INVALID_ARG_TYPE]: The "from" argument must be of type string. Received undefined). Build with -s ASSERTIONS=1 for more info.
    at process.q (C:\Users\aminy\minimap\node_modules\binaryen\index.js:54:175)
    at process.emit (node:events:376:20)
    at process.emit (C:\Users\aminy\minimap\node_modules\source-map-support\source-map-support.js:495:21)
    at emit (node:internal/process/promises:202:22)
    at processPromiseRejections (node:internal/process/promises:223:25)
    at processTicksAndRejections (node:internal/process/task_queues:94:32)
    at printErrorAndExit (C:\Users\aminy\minimap\node_modules\source-map-support\source-map-support.js:479:11)
    at process.emit (C:\Users\aminy\minimap\node_modules\source-map-support\source-map-support.js:491:16)
    at process._fatalException (node:internal/process/execution:163:25)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! minimap@4.37.0 build: `cross-env NODE_ENV=production cross-env BABEL_KEEP_MODULES=true rollup -c `
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the minimap@4.37.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\aminy\AppData\Roaming\npm-cache\_logs\2021-01-07T07_32_57_192Z-debug.log
// lib/a.js

import { wasmUrl } from "asc:./addition.as";

WebAssembly.instantiateStreaming(fetch(wasmUrl), {}).then(({ instance }) =>
  console.log(instance.exports.add(40, 2))
);
// lib/addition.as
export function add(a: i32, b: i32): i32 {
  return a + b;
}

Using:

    "assemblyscript": "^0.17.13",
    "rollup": "2.36.1",
    "rollup-plugin-assemblyscript": "1.2.1"
aminya commented 3 years ago

I ran the tests on WSL (Linux), and now they pass. Something is not working on Windows.

aminya commented 3 years ago

Fixed on master