Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

esbuild: Unexpected "*" #353

Open
acomagu opened this issue Dec 14, 2024 · 0 comments · May be fixed by #354
Open

esbuild: Unexpected "*" #353

acomagu opened this issue Dec 14, 2024 · 0 comments · May be fixed by #354

Comments

@acomagu
Copy link
Contributor

acomagu commented Dec 14, 2024

This is most likely not the bug of unplugin-typia. I'm sorry if you feel annoying(feel free to close, of cource).

I experienced errors occurs in executing esbuild with this plugin multiple times:


 ╭──────────────────────────────────╮
 │                                  │
 │  [unplugin-typia] Cache enabled  │
 │                                  │
 ╰──────────────────────────────────╯

✔ [unplugin-typia] Cache hit: /home/yuki/.local/src/github.com/TheDesignium/maas-payment-service/app/repository/purchase.ts
✔ [unplugin-typia] Cache hit: /home/yuki/.local/src/github.com/TheDesignium/maas-payment-service/app/dataloader/purchase.ts
✔ [unplugin-typia] Cache hit: /home/yuki/.local/src/github.com/TheDesignium/maas-payment-service/app/dataloader/ticket.ts
✔ [unplugin-typia] Cache hit: /home/yuki/.local/src/github.com/TheDesignium/maas-payment-service/app/dataloader/user.ts
✔ [unplugin-typia] Cache hit: /home/yuki/.local/src/github.com/TheDesignium/maas-payment-service/app/repository/ticket.ts
✔ [unplugin-typia] Cache hit: /home/yuki/.local/src/github.com/TheDesignium/maas-payment-service/app/resolver/mutation-migration/fill-purchase-payment-intent-ids.ts
✔ [unplugin-typia] Cache hit: /home/yuki/.local/src/github.com/TheDesignium/maas-payment-service/consty/schema-and-root-type.ts
✔ [unplugin-typia] Cache hit: /home/yuki/.local/src/github.com/TheDesignium/maas-payment-service/app/model/lincoln_reservation.ts
✔ [unplugin-typia] Cache hit: /home/yuki/.local/src/github.com/TheDesignium/maas-payment-service/app/model/ticket.ts
✔ [unplugin-typia] Cache hit: /home/yuki/.local/src/github.com/TheDesignium/maas-payment-service/app/model/aizu_coin_purchase_backend.ts
✘ [ERROR] Unexpected "*"

    model/ticket.ts:450:303:
      450 │ ...ugin-typia-7.3.0-model_ticket.ts_e6ede381b115506269147adde4691638 *// * unplugin-typia-7.3.0-model_ticket.ts_e6ede381b115506269147adde4691638 */
          ╵                                                                          ^

✔ [unplugin-typia] Cache hit: /home/yuki/.local/src/github.com/TheDesignium/maas-payment-service/app/model/hotel_reservation.ts
✔ [unplugin-typia] Cache hit: /home/yuki/.local/src/github.com/TheDesignium/maas-payment-service/app/model/selfdriving2410_reservation.ts
✔ [unplugin-typia] Cache hit: /home/yuki/.local/src/github.com/TheDesignium/maas-payment-service/app/model/inputs.ts
✔ [unplugin-typia] Cache hit: /home/yuki/.local/src/github.com/TheDesignium/maas-payment-service/app/lib/ip-fixed-fetch.ts
✔ [unplugin-typia] Cache hit: /home/yuki/.local/src/github.com/TheDesignium/maas-payment-service/app/model/pricing-rules/tl_lincoln.ts
✔ [unplugin-typia] Cache hit: /home/yuki/.local/src/github.com/TheDesignium/maas-payment-service/app/model/pricing-rules/fare_classes_with_quantity.ts
✔ [unplugin-typia] Cache hit: /home/yuki/.local/src/github.com/TheDesignium/maas-payment-service/app/model/pricing-rules/fixed.ts
✔ [unplugin-typia] Cache hit: /home/yuki/.local/src/github.com/TheDesignium/maas-payment-service/app/model/pricing-rules/quantity.ts
Error: Build failed with 1 error:
model/ticket.ts:450:378: ERROR: Unexpected "*"
    at failureErrorWithLog (/home/yuki/.local/src/github.com/TheDesignium/maas-payment-service/node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:1472:15)
    at /home/yuki/.local/src/github.com/TheDesignium/maas-payment-service/node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:945:25
    at runOnEndCallbacks (/home/yuki/.local/src/github.com/TheDesignium/maas-payment-service/node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:1315:45)
    at buildResponseToResult (/home/yuki/.local/src/github.com/TheDesignium/maas-payment-service/node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:943:7)
    at /home/yuki/.local/src/github.com/TheDesignium/maas-payment-service/node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:970:16
    at responseCallbacks.<computed> (/home/yuki/.local/src/github.com/TheDesignium/maas-payment-service/node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:622:9)
    at handleIncomingPacket (/home/yuki/.local/src/github.com/TheDesignium/maas-payment-service/node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:677:12)
    at Socket.readFromStdout (/home/yuki/.local/src/github.com/TheDesignium/maas-payment-service/node_modules/.pnpm/esbuild@0.21.5/node_modules/esbuild/lib/main.js:600:7)
    at Socket.emit (node:events:507:28)
    at addChunk (node:internal/streams/readable:559:12)

I looked at the problematic cache file and found the following at the end:

/* unplugin-typia-7.3.0-model_ticket.ts_e6ede381b115506269147adde4691638 *//* unplugin-typia-7.3.0-model_ticket.ts_e6ede381b115506269147adde4691638 *//* unplugin-typia-7.3.0-model_ticket.ts_e6ede381b115506269147adde4691638 *//* unplugin-typia-7.3.0-model_ticket.ts_e6ede381b115506269147adde4691638 *//* unplugin-typia-7.3.0-model_ticket.ts_e6ede381b115506269147adde4691638 *//* unplugin-typia-7.3.0-model_ticket.ts_e6ede381b115506269147adde4691638 *//* unplugin-typia-7.3.0-model_ticket.ts_e6ede381b115506269147adde4691638 *//* unplugin-typia-7.3.0-model_ticket.ts_e6ede381b115506269147adde4691638 */

This comment line is not wrong at the syntax, but I guess, any other formatter in esbuild pipeline transforms from //* into // * because it misunderstand // as start of comment.

So, I don't think this behavior is an unplugin-typia bug, but I guess this error can be prevented by stopping to add the hash comment multiple times or inserting newline between the comments.(I haven't tried it yet, but I hope to when I have time)

I'm not entirely sure which formatter (or if it even is a formatter) is at the root of the issue, but after removing every plugin except typia from the tsconfig.json, it appeared to resolve the problem.

diff --git a/app/tsconfig.json b/app/tsconfig.json
index 3d62c428b3..0177294d9d 100644
--- a/app/tsconfig.json
+++ b/app/tsconfig.json
@@ -13,11 +13,7 @@
     "noUncheckedIndexedAccess": true,
     "noUnusedLocals": true,
     "plugins": [
-      { "transform": "typia/lib/transform" },
-      { "name": "@0no-co/graphqlsp" }
+      { "transform": "typia/lib/transform" }
     ],
     "strict": true,
     "target": "es2022"

So the root of cause might be on @0no-co/graphql side. However, since the plugin by itself seems to handle consecutive comments(/* foo *//* foo */) just fine, I'm still not sure. It looks like it could be a compatibility of two plugins issue.

EDIT: @0no-co/graphql didn't seem to be a factor. The error still occurred after uninstalling it and removing all unplugin-typia cache.

I have not been able to create Reproduction yet(I tried hard but I couldn't...), so if I can create a patch that works well in my environment, I'll make it a pull(if you feels good). Anyway, for now, I just wanted to share my experience and findings to other users. Thank you.


typia: 7.3.0
unplugin-typia: 1.1.0
@0no-co/graphqlsp: 1.12.16
esbuild: 0.21.5
typescript: 5.7.2
ts-patch: 3.3.0
acomagu added a commit to acomagu/unplugin-typia that referenced this issue Dec 14, 2024
@acomagu acomagu linked a pull request Dec 14, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant