Skip to content

Commit 7b5c8cf

Browse files
authored
More publish fixes (AssemblyScript#945)
1 parent 1503f4d commit 7b5c8cf

File tree

19 files changed

+58
-377
lines changed

19 files changed

+58
-377
lines changed

.github/workflows/publish.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Publish
22
on:
33
schedule:
4-
- cron: '0 0 * * *'
4+
- cron: '0 4 * * *'
55
jobs:
66
publish:
77
name: "Publish packages"

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
npm-debug.*
2+
dist/
23
docs/
34
node_modules/
45
out/
56
raw/
6-
.history
7+
.history

index.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
import "./src/glue/js"
12
export * from "./src";

index.release.d.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/// <reference path="./dist/assemblyscript.d.ts" />
2+
export * from "assemblyscript";

index.release.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
module.exports = require("./dist/assemblyscript");

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,9 @@
4343
"scripts": {
4444
"build": "npm run build:bundle && npm run build:dts",
4545
"build:bundle": "webpack --mode production --display-modules",
46-
"build:dts": "node scripts/build-dts && tsc --noEmit tests/dts/index",
46+
"build:dts": "node scripts/build-dts && tsc --noEmit --target ESNEXT --module commonjs --experimentalDecorators tests/require/index-release",
4747
"clean": "node scripts/clean",
48-
"check": "npm run check:config && npm run check:compiler",
48+
"check": "npm run check:config && npm run check:compiler && tsc --noEmit --target ESNEXT --module commonjs --experimentalDecorators tests/require/index",
4949
"check:config": "tsc --noEmit -p src --diagnostics --listFiles",
5050
"check:compiler": "tslint -c tslint.json --project src --formatters-dir lib/lint/formatters --format as",
5151
"test": "npm run test:parser && npm run test:compiler && npm run test:packages",

scripts/build-dts.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,9 @@ const result = ts.transform(sourceFile, [
488488
]);
489489
console.log(" replaced " + numReplaced + " AS types with JS types");
490490

491+
if (!fs.existsSync(path.join(__dirname, "..", "dist"))) {
492+
fs.mkdirSync(path.join(__dirname, "..", "dist"));
493+
}
491494
fs.writeFileSync(
492495
path.resolve(__dirname, "..", "dist", "assemblyscript.d.ts"),
493496
ts.createPrinter().printFile(result.transformed[0]),

scripts/release.js

Lines changed: 12 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,15 +14,17 @@ fs.writeFileSync(path.join(__dirname, "..", "package.json"), [
1414
JSON.stringify(pkg, null, 2), '\n'
1515
].join(""));
1616

17-
console.log("Updating index.js ...");
18-
fs.writeFileSync(path.join(__dirname, "..", "index.js"), [
19-
'module.exports = require("./dist/assemblyscript");\n'
20-
].join(""));
17+
console.log("Copying index.release.js -> index.js ...");
18+
fs.copyFileSync(
19+
path.join(__dirname, "..", "index.release.js"),
20+
path.join(__dirname, "..", "index.js")
21+
);
2122

22-
console.log("Updating index.d.ts ...");
23-
fs.writeFileSync(path.join(__dirname, "..", "index.d.ts"), [
24-
'/// <reference path="./dist/assemblyscript.d.ts" />\n',
25-
'export * from "assemblyscript";\n'
26-
].join(""));
23+
console.log("Copying index.release.d.ts -> index.d.ts ...");
24+
fs.copyFileSync(
25+
path.join(__dirname, "..", "index.release.d.ts"),
26+
path.join(__dirname, "..", "index.d.ts")
27+
);
2728

28-
console.log("OK");
29+
// We are going to use these immediately, so, to be sure:
30+
setTimeout(() => console.log("OK"), 2000);

src/flow.ts

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -345,7 +345,7 @@ export class Flow {
345345
local = parentFunction.addLocal(type);
346346
} else {
347347
if (temps && temps.length) {
348-
local = temps.pop();
348+
local = temps.pop()!;
349349
local.type = type;
350350
local.flags = CommonFlags.NONE;
351351
} else {
@@ -404,7 +404,7 @@ export class Flow {
404404
/** Gets the scoped local of the specified name. */
405405
getScopedLocal(name: string): Local | null {
406406
var scopedLocals = this.scopedLocals;
407-
if (scopedLocals && scopedLocals.has(name)) return scopedLocals.get(name);
407+
if (scopedLocals && scopedLocals.has(name)) return scopedLocals.get(name)!;
408408
return null;
409409
}
410410

@@ -478,9 +478,9 @@ export class Flow {
478478
lookupLocal(name: string): Local | null {
479479
var current: Flow | null = this;
480480
var scope: Map<String,Local> | null;
481-
do if ((scope = current.scopedLocals) && (scope.has(name))) return scope.get(name);
481+
do if ((scope = current.scopedLocals) && (scope.has(name))) return scope.get(name)!;
482482
while (current = current.parent);
483-
return this.parentFunction.localsByName.get(name);
483+
return this.parentFunction.localsByName.get(name)!;
484484
}
485485

486486
/** Looks up the element with the specified name relative to the scope of this flow. */
@@ -868,7 +868,7 @@ export class Flow {
868868
// overflows if the conversion does (globals are wrapped on set)
869869
case ExpressionId.GlobalGet: {
870870
// TODO: this is inefficient because it has to read a string
871-
let global = assert(this.parentFunction.program.elementsByName.get(assert(getGlobalGetName(expr))));
871+
let global = assert(this.parentFunction.program.elementsByName.get(assert(getGlobalGetName(expr)))!);
872872
assert(global.kind == ElementKind.GLOBAL);
873873
return canConversionOverflow(assert((<Global>global).type), type);
874874
}

src/glue/js/index.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
* @preferred
55
*//***/
66

7-
/// <reference path="./node.d.ts" />
8-
97
import "./binaryen"; // must be first so portable can pick up the memory implementation
108
import "../../../std/portable/index";
119
import "./float";

0 commit comments

Comments
 (0)