Skip to content

Commit

Permalink
Add emit_dts.sh to generate d.ts files
Browse files Browse the repository at this point in the history
  • Loading branch information
thetarnav committed Jan 13, 2024
1 parent c931f3b commit cdb944c
Show file tree
Hide file tree
Showing 6 changed files with 43 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"root": true,
"parser": "@typescript-eslint/parser",
"plugins": ["@typescript-eslint", "no-only-tests", "eslint-comments", "@nothing-but"],
"ignorePatterns": ["node_modules", "dist"],
"ignorePatterns": ["node_modules", "dist", "/types"],
"parserOptions": {
"project": ["./jsconfig.json", "./jsconfig.node.json", "./example/jsconfig.json"],
"tsconfigRootDir": ".",
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
node_modules
dist
/types

.env

Expand Down
11 changes: 11 additions & 0 deletions emit_dts.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Emits d.ts files from the wasm package
# For use in a typescript project.
# .d.ts files that are in the wasm package are linked from the types folder
# Thats because tsc doesn't emits them emtpy for some reason

rm -rf types
mkdir types
pnpm tsc -p ./jsconfig.build.json
cd wasm
find . -name "*.d.ts" -exec ln -srf "{}" "../types/{}" \;
# find . -name "*.d.ts" -exec bash -c 'ln -srf "{}" "../types/{}"; rm "../types/{}.map"' \;
4 changes: 2 additions & 2 deletions jsconfig.base.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
referenced configs cannot have "noEmit": true
which conflicts with allowing js files
*/
"outDir": "dist",
"outDir": "types",

/* JS */
"allowJs": true,
Expand All @@ -30,5 +30,5 @@
"verbatimModuleSyntax": true,
"useDefineForClassFields": true
},
"exclude": ["node_modules", "dist"]
"exclude": ["node_modules", "dist", "/types"]
}
12 changes: 12 additions & 0 deletions jsconfig.build.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"extends": "./jsconfig.base.json",
"compilerOptions": {
"lib": ["ESNext", "DOM"],
"declaration": true,
"emitDeclarationOnly": true,
"declarationMap": true,
"noEmitOnError": false
},
"include": ["wasm"],
"exclude": ["node_modules", "dist", "/types", "**/*.test.*"]
}
16 changes: 16 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,22 @@
"license": "MIT",
"private": true,
"type": "module",
"files": [
"types",
"wasm",
"!**/*.test.*"
],
"exports": {
"./package.json": "./package.json",
".": {
"types": "./types/runtime.d.ts",
"import": "./wasm/runtime.js"
},
"./*": {
"types": "./types/*.d.ts",
"import": "./wasm/*.js"
}
},
"scripts": {
"dev": "node main.js dev",
"server": "node main.js server",
Expand Down

0 comments on commit cdb944c

Please sign in to comment.