How to use the assemblyscript/bin/asc.js.main function in assemblyscript

To help you get started, we’ve selected a few assemblyscript examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github SinaMFE / assemblyscript-typescript-loader / lib / index.js View on Github external
function AssemblyScriptLoader(source) {
  var options4me = loaderUtils.getOptions(this) || {};
  var innerCallback = this.async();
  validateOptions(require("./options"), options4me, "URL Loader");
  if (this.cacheable) {
    this.cacheable();
  }
  var me = this;
  var targetPath = this._compiler.outputPath;
  var buildTempPath = path.join(this._compiler.context,"/temp/assembly/");
  targetPath = path.join(
    buildTempPath, path.parse(this.resourcePath).name + ".wasm"
  );
  mkdirsSync(buildTempPath);
  asc.main(
    [
      path.relative(process.cwd(), this.resourcePath),
      // "./src/view/index/ass/test.ts",
      "-o",
      path.relative(process.cwd(), targetPath),
      "--optimize",
      "--validate",
      "--sourceMap"
    ],
    function(err) {
      if (err) throw err;
      var distStates = fs.statSync(targetPath);
      var distFile = fs.readFileSync(targetPath);
      // Options `dataUrlLimit` is backward compatibility with first loader versions
      var limit =
        options4me.limit ||