Skip to content

Commit b43b58e

Browse files
authored
Merge pull request #7 from LuanRoger/fix/references
2 parents 5b82ef8 + 77658a5 commit b43b58e

File tree

10 files changed

+49
-15
lines changed

10 files changed

+49
-15
lines changed

src/bin/commands/build.ts

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@ async function buildAction(inputPath: string, options: any) {
1414
const { cwd, inputPath: parsedInputPath, config, output } = result;
1515

1616
const resolvedCwd = path.resolve(cwd);
17-
const inputPathResolved = path.resolve(resolvedCwd, parsedInputPath);
17+
const inputPathResolved = parsedInputPath
18+
? path.resolve(resolvedCwd, parsedInputPath)
19+
: undefined;
1820
const outputPathResolved = path.resolve(resolvedCwd, output);
1921
const configPathResolved = path.resolve(resolvedCwd, config);
2022

@@ -28,7 +30,7 @@ async function buildAction(inputPath: string, options: any) {
2830
configPath: doesConfigPathExist ? configPathResolved : undefined,
2931
},
3032
false,
31-
true,
33+
true
3234
);
3335

3436
await tsDownExecutor.execute();
@@ -37,13 +39,13 @@ async function buildAction(inputPath: string, options: any) {
3739
export const buildCommand = new Command()
3840
.command("build")
3941
.description("Build the project for production")
40-
.argument("<inputPath>", "Path to the input file or directory.")
42+
.argument("[inputPath]", "Path to the input file or directory.")
4143
.option("--output <path>", "Set the output entrypoint", "./dist")
4244
.option("--show-builder-logs", "Show builder logs", false)
4345
.option(
4446
"-c, --config <configPath>",
4547
"Path to the config file",
46-
"./tsdown.config.ts",
48+
"./tsdown.config.ts"
4749
)
4850
.option("--cwd <path>", "Set the current working directory", process.cwd())
4951
.action(buildAction);

src/bin/commands/schemas/build.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import z from "zod";
22

33
export const buildSchema = z.object({
44
cwd: z.string(),
5-
inputPath: z.string(),
5+
inputPath: z.string().optional(),
66
config: z.string(),
77
output: z.string(),
88
});

src/bin/constants/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,9 @@ export const INIT_TEMPLATES = ["cli", "server"] as const;
33
export const TS_CONFIG = {
44
extends: "onlykit/dev/tsconfig",
55
compilerOptions: {
6-
typeRoots: ["node_modules/@types", "node_modules/assemblyscript/std/types"],
6+
typeRoots: ["node_modules/@types", "node_modules/onlykit/dist"],
77
},
8-
include: ["src/**/*.ts"],
8+
include: ["src/**/*.ts", "./tsdown.config.ts"],
99
};
1010

1111
export const BIOME_CONFIG = {

src/bin/processes/executors/tsdown.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import { normalizePath } from "../../utils/path";
44
import { ExecutorCommand } from "./executor";
55

66
interface TsDownExecutorOptions {
7-
inputPath: string;
7+
inputPath?: string;
88
configPath?: string;
99
}
1010

@@ -30,7 +30,7 @@ export class TsDownBuildExecutor extends ExecutorCommand<TsDownBuildOptions> {
3030

3131
return [
3232
...(watch ? ["--watch"] : []),
33-
normalizePath(inputPath),
33+
...(inputPath ? [normalizePath(inputPath)] : []),
3434
"-d",
3535
normalizePath(outputPath),
3636
...(configPath
Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { tsdownConfig } from "onlykit/dev";
2-
import { defineConfig } from "tsdown";
1+
import { defineConfig, tsdownConfig } from "onlykit/dev";
32

43
export default defineConfig(tsdownConfig);

src/dev/tsconfig/base.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
{
22
"$schema": "https://json.schemastore.org/tsconfig",
3-
"extends": "assemblyscript/std/portable.json",
43
"compilerOptions": {
54
"target": "esnext",
65
"module": "esnext",
@@ -16,7 +15,7 @@
1615
"resolveJsonModule": true,
1716
"experimentalDecorators": true,
1817
"noEmitOnError": true,
19-
"types": ["portable"],
18+
"types": ["types"],
2019
"baseUrl": "."
2120
},
2221
"exclude": ["node_modules", "**/node_modules/*"]

src/dev/tsdown/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
import type { UserConfig } from "tsdown";
1+
import { defineConfig, type UserConfig } from "tsdown";
22
import { wasmSupport } from "@/wasm";
33

44
export const tsdownConfig: UserConfig = {
55
plugins: [wasmSupport()],
66
};
7+
8+
export { defineConfig };

src/dev/types/index.d.ts

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/**
2+
* Environment definitions for compiling AssemblyScript to JavaScript using tsc.
3+
*
4+
* Note that semantic differences require additional explicit conversions for full compatibility.
5+
* For example, when casting an i32 to an u8, doing `<u8>(someI32 & 0xff)` will yield the same
6+
* result when compiling to WebAssembly or JS while `<u8>someI32` alone does nothing in JS.
7+
*
8+
* Note that i64's are not portable (JS numbers are IEEE754 doubles with a maximum safe integer
9+
* value of 2^53-1) and instead require a compatibility layer to work in JS as well, as for example
10+
* {@link glue/js/i64} respectively {@link glue/wasm/i64}.
11+
*
12+
*/
13+
14+
// Types
15+
16+
declare type bool = boolean;
17+
declare type i8 = number;
18+
declare type i16 = number;
19+
declare type i32 = number;
20+
declare type isize = number;
21+
declare type u8 = number;
22+
declare type u16 = number;
23+
declare type u32 = number;
24+
declare type usize = number;
25+
declare type f32 = number;
26+
declare type f64 = number;
27+
28+
/** Special type evaluating the indexed access index type. */
29+
declare type indexof<T extends unknown[]> = keyof T;
30+
/** Special type evaluating the indexed access value type. */
31+
declare type valueof<T extends unknown[]> = T[0];

tsconfig.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,6 @@
2828
"@lib/*": ["./lib/*"]
2929
}
3030
},
31-
"include": ["./src"],
31+
"include": ["./src/**/*", "./tsdown.config.ts"],
3232
"exclude": ["node_modules", "dist"]
3333
}

tsdown.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export default defineConfig({
2727
copy: [
2828
{ from: "src/dev/biome/base.json", to: "dist/dev/biome/base.json" },
2929
{ from: "src/dev/tsconfig/base.json", to: "dist/dev/tsconfig/base.json" },
30+
{ from: "src/dev/types/index.d.ts", to: "dist/types/index.d.ts" },
3031
{
3132
from: "src/bin/templates/cli/index.ts.ejs",
3233
to: "dist/bin/templates/cli/index.ts.ejs",

0 commit comments

Comments
 (0)