Преглед изворни кода

chore: attempting to fix the component-library typescript config for building

benduran пре 1 месец
родитељ
комит
8b0abce915

+ 2 - 1
.gitignore

@@ -25,4 +25,5 @@ __pycache__
 .turbo/
 .cursorrules
 .corepack
-justfile
+justfile
+.tshy*

+ 13 - 2
README.md

@@ -149,8 +149,19 @@ New packages should be configured with a few requirements in mind:
 3. If you are writing a package that will be published:
 
    - Make sure you are dual-exporting cjs and esm correctly, see [how the lazer
-     sdk package builds](./lazer/sdk/js/package.json) (in particular look at the
-     `build:cjs` and `build:esm` tasks) for an example for how to do this
+     sdk package builds](./lazer/sdk/js/package.json). This should be as simple as ensuring you have a `tsconfig.build.json` that extends from your baseline `tsconfig.json` file like the following:
+
+     ```jsonc
+     {
+       "extends": "./tsconfig.json",
+       "compilerOptions": {
+         "declaration": true, # writes out TypeScript typings for your library consumers
+         "incremental": false, # ensures the whole project is recompiled, instead of only what's changed
+         "noEmit": false, # ensures building actually writes files to disk
+         "verbatimModuleSyntax": false # ensures all import statements are properly written to CommonJS, the classic Node.js module specification
+       }
+     }
+     ```
 
    - Ensure you have properly configured [subpath
      exports](https://nodejs.org/api/packages.html#subpath-exports) to reference

+ 1 - 3
lazer/contracts/sui/sdk/js/package.json

@@ -26,8 +26,6 @@
   },
   "sideEffects": false,
   "scripts": {
-    "build:cjs": "tsc --project tsconfig.build.json --verbatimModuleSyntax false --module commonjs --outDir ./dist/cjs && echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
-    "build:esm": "tsc --project tsconfig.build.json --outDir ./dist/esm && echo '{\"type\":\"module\"}' > dist/esm/package.json",
     "fix:format": "prettier --write .",
     "fix:lint": "eslint --fix .",
     "test:format": "prettier --check .",
@@ -57,4 +55,4 @@
   "tshy": {
     "project": "tsconfig.build.json"
   }
-}
+}

+ 0 - 2
lazer/sdk/js-solana/package.json

@@ -22,8 +22,6 @@
   },
   "scripts": {
     "update-idl": "cd ../../contracts/solana && RUSTUP_TOOLCHAIN=nightly-2025-04-15 anchor build && cp target/types/pyth_lazer_solana_contract.ts ../../sdk/js-solana/src/idl/pyth-lazer-solana-contract.ts && cp target/idl/pyth_lazer_solana_contract.json ../../sdk/js-solana/src/idl/pyth-lazer-solana-contract.json",
-    "build:cjs": "swc src -d dist/cjs --strip-leading-paths --copy-files -C module.type=commonjs && echo '{\"type\":\"commonjs\"}' > dist/cjs/package.json",
-    "build:esm": "swc src -d dist/esm --strip-leading-paths --copy-files -C jsc.experimental.keepImportAttributes=true && echo '{\"type\":\"module\"}' > dist/esm/package.json",
     "build:types": "tsc --project tsconfig.build.json",
     "fix:lint": "eslint --fix . --max-warnings 0",
     "test:lint": "eslint . --max-warnings 0",

+ 6 - 2
lazer/sdk/js/package.json

@@ -60,7 +60,11 @@
   },
   "packageManager": "pnpm@10.19.0",
   "tshy": {
-    "project": "tsconfig.build.json"
+    "project": "tsconfig.build.json",
+    "exports": {
+      "./package.json": "./package.json",
+      ".": "./src/index.ts"
+    }
   },
   "exports": {
     "./package.json": "./package.json",
@@ -78,4 +82,4 @@
   "main": "./dist/commonjs/index.js",
   "types": "./dist/commonjs/index.d.ts",
   "module": "./dist/esm/index.js"
-}
+}

+ 5 - 2
packages/component-library/package.json

@@ -23,8 +23,8 @@
     "./theme": "./dist/esm/theme.scss"
   },
   "scripts": {
+    "build": "tshy",
     "build:declarations": "tsc --project tsconfig.build.json --outDir ./dist/esm",
-    "build:esm": "babel src --out-dir ./dist/esm --extensions .ts && babel src --out-dir ./dist/esm --extensions .tsx --out-file-extension .jsx",
     "build:scss": "copyfiles -u 1 \"src/**/*.scss\" dist/esm",
     "build:storybook": "storybook build",
     "build:svg": "copyfiles -u 1 \"src/**/*.svg\" dist/esm",
@@ -98,5 +98,8 @@
     "stylelint-config-standard-scss": "catalog:",
     "typescript": "catalog:"
   },
-  "packageManager": "pnpm@10.19.0"
+  "packageManager": "pnpm@10.19.0",
+  "tshy": {
+    "project": "tsconfig.build.json"
+  }
 }

+ 1 - 1
packages/component-library/tsconfig.build.json

@@ -4,7 +4,7 @@
     "noEmit": false,
     "incremental": false,
     "declaration": true,
-    "emitDeclarationOnly": true
+    "verbatimModuleSyntax": false
   },
   "exclude": ["node_modules", "dist", ".storybook", "**/*.stories.tsx"]
 }