Skip to content

Commit 7b5c8cf

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

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";

src/module.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1162,7 +1162,7 @@ export class Module {
11621162
var cStr = this.allocStringCached(exportName);
11631163
var k = segments.length;
11641164
var segs = new Array<usize>(k);
1165-
var psvs = new Array<i8>(k);
1165+
var psvs = new Uint8Array(k);
11661166
var offs = new Array<ExpressionRef>(k);
11671167
var sizs = new Array<Index>(k);
11681168
for (let i = 0; i < k; ++i) {

src/parser.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -380,7 +380,7 @@ export class Parser extends DiagnosticEmitter {
380380
/** Obtains the next file to parse. */
381381
nextFile(): string | null {
382382
var backlog = this.backlog;
383-
return backlog.length ? backlog.shift() : null;
383+
return backlog.length ? backlog.shift()! : null;
384384
}
385385

386386
/** Obtains the dependee of the given imported file. */

src/program.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ export class Program extends DiagnosticEmitter {
612612
getElementByDeclaration(declaration: DeclarationStatement): DeclaredElement | null {
613613
var elementsByDeclaration = this.elementsByDeclaration;
614614
return elementsByDeclaration.has(declaration)
615-
? elementsByDeclaration.get(declaration)
615+
? elementsByDeclaration.get(declaration)!
616616
: null;
617617
}
618618

@@ -1123,7 +1123,7 @@ export class Program extends DiagnosticEmitter {
11231123
/** Looks up the element of the specified name in the global scope. */
11241124
lookupGlobal(name: string): Element | null {
11251125
var elements = this.elementsByName;
1126-
if (elements.has(name)) return elements.get(name);
1126+
if (elements.has(name)) return elements.get(name)!;
11271127
return null;
11281128
}
11291129

@@ -2890,7 +2890,7 @@ export class Function extends TypedElement {
28902890
/* @override */
28912891
lookup(name: string): Element | null {
28922892
var locals = this.localsByName;
2893-
if (locals.has(name)) return locals.get(name);
2893+
if (locals.has(name)) return locals.get(name)!;
28942894
return this.parent.lookup(name);
28952895
}
28962896

src/resolver.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -880,7 +880,7 @@ export class Resolver extends DiagnosticEmitter {
880880
} else if (type != Type.void) {
881881
let wrapperClasses = this.program.wrapperClasses;
882882
assert(wrapperClasses.has(type));
883-
return wrapperClasses.get(type);
883+
return wrapperClasses.get(type)!;
884884
}
885885
return null;
886886
}
@@ -2171,15 +2171,15 @@ export class Resolver extends DiagnosticEmitter {
21712171
);
21722172
let wrapperClasses = this.program.wrapperClasses;
21732173
assert(wrapperClasses.has(intType));
2174-
return wrapperClasses.get(intType);
2174+
return wrapperClasses.get(intType)!;
21752175
}
21762176
case LiteralKind.FLOAT: {
21772177
this.currentThisExpression = node;
21782178
this.currentElementExpression = null;
21792179
let fltType = ctxType == Type.f32 ? Type.f32 : Type.f64;
21802180
let wrapperClasses = this.program.wrapperClasses;
21812181
assert(wrapperClasses.has(fltType));
2182-
return wrapperClasses.get(fltType);
2182+
return wrapperClasses.get(fltType)!;
21832183
}
21842184
case LiteralKind.STRING: {
21852185
this.currentThisExpression = node;
@@ -2334,7 +2334,7 @@ export class Resolver extends DiagnosticEmitter {
23342334
): Element | null {
23352335
var wrapperClasses = this.program.wrapperClasses;
23362336
assert(wrapperClasses.has(Type.bool));
2337-
return wrapperClasses.get(Type.bool);
2337+
return wrapperClasses.get(Type.bool)!;
23382338
}
23392339

23402340
/** Resolves an instanceof expression to its static type. */

std/portable.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{
22
"extends": "../tsconfig-base.json",
33
"compilerOptions": {
4-
"target": "es5",
4+
"target": "esnext",
55
"module": "commonjs",
6-
"noLib": true,
76
"allowJs": true,
87
"downlevelIteration": true,
98
"preserveConstEnums": true,

0 commit comments

Comments
 (0)