Skip to content

Commit acfb1b8

Browse files
authored
Use node resolution in asinit-generated tsconfigs if possible (AssemblyScript#1322)
1 parent 42f6c85 commit acfb1b8

File tree

2 files changed

+8
-3
lines changed

2 files changed

+8
-3
lines changed

.eslintrc.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,8 @@ module.exports = {
8787
"es6": true
8888
},
8989
files: [
90-
"**/*.js"
90+
"**/*.js",
91+
"bin/*"
9192
],
9293
rules: {
9394
// Node's support for ESM is still not great, but this rule is likely

bin/asinit

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,11 @@ const compilerDir = path.join(__dirname, "..");
4242
const compilerVersion = require(path.join(compilerDir, "package.json")).version;
4343
const assemblyDir = path.join(projectDir, "assembly");
4444
const tsconfigFile = path.join(assemblyDir, "tsconfig.json");
45-
const tsconfigBase = path.relative(assemblyDir, path.join(compilerDir, "std", "assembly.json"));
45+
let tsconfigBase = path.relative(assemblyDir, path.join(compilerDir, "std", "assembly.json"));
46+
if (/^(\.\.[/\\])*node_modules[/\\]assemblyscript[/\\]/.test(tsconfigBase)) {
47+
// Use node resolution if the compiler is a normal dependency
48+
tsconfigBase = "assemblyscript/std/assembly.json";
49+
}
4650
const entryFile = path.join(assemblyDir, "index.ts");
4751
const buildDir = path.join(projectDir, "build");
4852
const testsDir = path.join(projectDir, "tests");
@@ -247,7 +251,7 @@ function ensureGitignore() {
247251
}
248252

249253
function ensurePackageJson() {
250-
console.log("- Making sure that 'package.json' contains the build commands...")
254+
console.log("- Making sure that 'package.json' contains the build commands...");
251255
const entryPath = path.relative(projectDir, entryFile).replace(/\\/g, "/");
252256
const buildUntouched = "asc " + entryPath + " -b build/untouched.wasm -t build/untouched.wat --sourceMap --debug";
253257
const buildOptimized = "asc " + entryPath + " -b build/optimized.wasm -t build/optimized.wat --sourceMap --optimize";

0 commit comments

Comments
 (0)