Using NPM

Publishing AS packages to npm and more!

Publishing to NPM

Publishing an AssemblyScript project

Publishing an AS package to NPM is quite simple. We need to delete the main key and provide the types and ascMain keys in our package.json.

Make sure that the main AssemblyScript file is named index.ts. Don't include a ./` in front of your types/ascMain path.

package.json
{
  "name": "as-example",
  "version": "1.0.0",
- "main": "DELETE",
+ "types": "Main AssemblyScript file path",
+ "ascMain": "Main AssemblyScript file path"
  "scripts": {},
  "keywords": [],
  "license": "MIT",
  "dependencies": {}
}

Both ascMain and types MUST point to an index.ts file. If not, AssemblyScript will panic.

Publishing the loader

Publishing the loader file works if you are targeting JS modules. Keep in mind that this will not work with AssemblyScript projects.

package.json
{
  "name": "as-example",
  "version": "1.0.0",
+ "main": "Main JS File",
- "types": "DELETE",
- "ascMain": "DELETE"
  "scripts": {},
  "keywords": [],
  "license": "MIT",
  "dependencies": {}
}

Sometimes, things get really tricky. I'll extend this article further in the future.

Last updated