Exploring the process of developing a Shopify app using Typescript starting with the shopify-app-cli boilerplate, which utilizes Koa for the server and Nextjs for the frontend in React JavaScript. see
https://github.com/Shopify/shopify-app-cli
Encountering difficulty in compiling the Typescript code for both the server and the Next.js frontend.
Modifications:
Changing all file extensions to either
.tsx
or.ts
instead of.js
In package.json, updating "dev" script to use ts-node instead of
nodemon
Initial Setting:
"dev": "NODE_ENV=development nodemon ./server/index.js --watch ./server/index.js",
Updated Setting:
"dev": "NODE_ENV=development ts-node server/server.ts",
Able to compile the server.ts
file successfully. However, upon changing the Next.js files like pages/_app.js
and pages/index.js
to .tsx
, encountering this error:
[ event ] client pings, but there's no entry for page: /
Here is the content of the tsconfig.json
file being used:
{
"compilerOptions": {
"target": "es6",
"lib": ["dom", "dom.iterable", "esnext"],
"allowJs": true,
"skipLibCheck": true,
"strict": false,
"forceConsistentCasingInFileNames": true,
"noEmit": true,
"esModuleInterop": true,
"module": "commonjs",
"moduleResolution": "node",
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "react"
},
"exclude": ["node_modules"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
}
Link to the server.ts
gist: https://gist.github.com/azrielh/73ac202fcce5ce32f19488e4ef5df263.js