Closed
Description
The interface for the compiler wrapped the util module into an exported namespace.
I'm sure there was a reason to do this, but given the semver semantics breaking changes should increment the middle version number.
Is it bad practices to have the middle number go above 9? If not, then we should consider upgrading to 0.10.0.
For those who might stumble upon this here is how I fixed my custom transformer's dependency on the compiler.
//@ts-ignore
const path = require("path");
//@ts-ignore
let assemblyscriptPath = Object.getOwnPropertyNames(require.cache)
.filter(s => s.endsWith("assemblyscript.js"))[0];
let transformerPath;
if (assemblyscriptPath) {
let splitPath = assemblyscriptPath.split(path.sep).slice(0, -2);
transformerPath = splitPath.concat([ "cli", "transform"]).join(path.sep);
} else {
assemblyscriptPath = require.resolve("assemblyscript");
transformerPath = require.resolve("assemblyscript/cli/transform");
}
const assemblyscript = require(assemblyscriptPath);
//@ts-ignore
module.exports.Transform = require(transformerPath).Transform;
module.exports = {
...module.exports,
...assemblyscript,
// Need to add because newer version adds namespace
...assemblyscript.util
};
then an accompanying .d.t.s file:
export * from "assemblyscript";
export * from "assemblyscript/cli/transform";