tomoyanakano / shopify-app-template-node-typescript

🧩 Shopify App Template with Typescript
23 stars 6 forks source link

web/intex.ts import ts files with .js path #1

Closed Kcin1993 closed 1 year ago

Kcin1993 commented 1 year ago

Hi, thank you for creating this template.

I noticed that the files imported in web/index.ts imported .js file, while the files in the directory, such as shopify.ts, product-creator.ts, and gdpr.ts all have a .ts extension. What is the reason for this?

Also, I noticed that if I remove the .js in the import path, it causes web/index.ts to fail to import the files properly.

Thank you again for creating the TypeScript version of this app.

tomoyanakano commented 1 year ago

@Kcin1993 Hi, thank you for your comment.

Yes, as you mentioned it is required to add .js even though the file is .ts. It is the problem of Tyepscript + Nodejs ESM.

Related https://github.com/TypeStrong/ts-node/issues/1777 https://stackoverflow.com/questions/63742790/unable-to-import-esm-ts-module-in-node https://www.typescriptlang.org/docs/handbook/esm-node.html https://github.com/nodejs/node/issues/46006

I think it could be solved with next Typescript version (Typescript v5).

Kcin1993 commented 1 year ago

Thanks for your information 👍