- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我想测试使用 Typescript 构建一个 shopify 应用程序,方法是从 shopify-app-cli 样板文件开始,它使用 Koa 作为服务器,使用 Nextjs 作为前端 react javascript。参见 https://github.com/Shopify/shopify-app-cli
我在为服务器和 nextjs 前端代码编译 typescript 代码时遇到问题。
变化:
所有文件扩展名为 .tsx
或 .ts
。而不是 .js
在 package.json 中,将“dev”脚本更改为使用 ts-node 而不是使用 nodemon
之前
"dev": "NODE_ENV=development nodemon ./server/index.js --watch ./server/index.js",
之后
"dev": "NODE_ENV=development ts-node server/server.ts",
我可以得到它来编译 server.ts
文件,但是如果我更改 nextjs 文件 pages/_app.js
和 pages/index.js
到 .tsx
它找不到它们并出现此错误:
[ event ] client pings, but there's no entry for page: /
这是设置好的tsconfig.json
文件。
{
"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"]
}
也是 server.ts
的要点,https://gist.github.com/azrielh/73ac202fcce5ce32f19488e4ef5df263.js
最佳答案
我基本上可以使用您描述的设置。
它全部按预期运行、编译并查看 TSX 页面。
这是我的 package.json:
{
"name": "shopify-app-node",
"version": "1.0.0",
"description": "Shopify's node app for CLI tool",
"scripts": {
"test": "jest",
"oldDev": "cross-env NODE_ENV=development nodemon ./server/index.js --watch ./server/index.js",
"dev": "NODE_ENV=development ts-node server/server.ts",
"build": "NEXT_TELEMETRY_DISABLED=1 next build",
"start": "cross-env NODE_ENV=production node ./server/index.js"
},
"repository": {
"type": "git",
"url": "git+https://github.com/Shopify/shopify-app-node.git"
},
"author": "Shopify Inc.",
"license": "MIT",
"bugs": {
"url": "https://github.com/shopify/shopify-app-node/issues"
},
"dependencies": {
"@babel/core": "7.12.3",
"@babel/polyfill": "^7.6.0",
"@babel/preset-env": "^7.6.2",
"@babel/register": "^7.6.2",
"@shopify/app-bridge-react": "^1.15.0",
"@shopify/app-cli-node-generator-helper": "^1.1.2",
"@shopify/koa-shopify-auth": "^3.2.0",
"@shopify/koa-shopify-graphql-proxy": "^4.0.2",
"@shopify/koa-shopify-webhooks": "^2.5.3",
"@shopify/polaris": "^5.3.1",
"@zeit/next-css": "^1.0.1",
"apollo-boost": "^0.4.4",
"cross-env": "^7.0.2",
"dotenv": "^8.2.0",
"graphql": "^14.5.8",
"isomorphic-fetch": "^3.0.0",
"koa": "^2.8.2",
"koa-router": "^10.0.0",
"koa-session": "^6.1.0",
"lodash": "^4.17.20",
"next": "^10.0.0",
"next-env": "^1.1.0",
"node-fetch": "^2.6.1",
"react": "^16.10.1",
"react-apollo": "^3.1.3",
"react-dom": "^16.10.1",
"ts-node": "^9.1.1"
},
"devDependencies": {
"@babel/plugin-transform-runtime": "^7.6.2",
"@babel/preset-stage-3": "^7.0.0",
"@types/lodash": "^4.14.165",
"@types/node": "^12.19.5",
"@types/react": "^16.9.56",
"@types/react-dom": "^16.9.8",
"@typescript-eslint/eslint-plugin": "^4.11.1",
"@typescript-eslint/parser": "^4.11.1",
"babel-jest": "26.6.2",
"babel-register": "^6.26.0",
"enzyme": "3.11.0",
"enzyme-adapter-react-16": "1.15.5",
"eslint": "^7.16.0",
"husky": "^4.0.7",
"jest": "26.6.2",
"lint-staged": "^10.0.1",
"nodemon": "^2.0.0",
"prettier": "^2.1.2",
"react-addons-test-utils": "15.6.2",
"react-test-renderer": "16.14.0",
"tsmon": "^0.7.3",
"typescript": "^4.1.3"
},
"husky": {
"hooks": {
"pre-commit": "lint-staged"
}
},
"lint-staged": {
"*.{js,css,json,md}": [
"prettier --write"
]
}
}
关于typescript - 使用 Typescript 的 Shopify CLI,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62203877/
我正在为 Shopify 构建一个应用程序。我的商店以欧元为基础货币,并支持不同的货币,例如美元、新西兰元……(我将其称为活跃货币)。 我可以使用 javascript window.Shopify.
Shopify 的 documentation显示产品句柄中允许的一些字符(URL 中使用的产品标识符)。 Since handles are used for your storefront nav
如何检查当前页面是否是 theme.liquid 中的购物车页面?我试过 page.handle=='cart'但它不起作用。 最佳答案 您不需要 handle过滤器,你可以只使用: {% if te
我正在考虑为 Shopify 开发一个应用程序,它将向商店的结帐页面添加功能。如果用户不必自己将代码复制并粘贴到文件中,那将是理想的,因此我正在考虑使用 ScriptTag API ( http://
我正在为 Shopify 开发一个应用程序。目前处于开发阶段。到目前为止,我已经成功地授权了该应用程序,然后使用嵌入式应用程序 SDK 将其重定向回管理页面。但是,当我返回到管理页面时,它给我一个错误
我想知道 Shopify 中的实体可以拥有的元字段数量有何限制。例如,在产品对象的给定 namespace 下,您可以拥有 1000 个唯一的键值对吗?有硬性限制吗? 请注意,我已经查阅了 Shopi
有没有办法将 Shopify 购物车中的“继续结账”按钮重定向到另一个系统来处理销售?事实上,开发人员/设计师无法参与销售流程的最后一部分,这意味着即使是最轻微的变化也会成为无法克服的问题。有谁知道是
我正在开发一个集成 Shopify 的模块。 所以我想用真实数据测试我的应用程序。 Shopify 是否提供沙盒功能? 最佳答案 如果您创建 partners account您可以设置一个测试商店,让
我想知道 Shopify 中的实体可以拥有的元字段数量有何限制。例如,在产品对象的给定 namespace 下,您可以拥有 1000 个唯一的键值对吗?有硬性限制吗? 请注意,我已经查阅了 Shopi
我正在尝试检索博客上的最新文章。我下面的当前代码不输出任何内容。 {% for article in blogs['myblog'].articles.last %} {{ article.tit
我试图在我的节文件中使用一个变量,但它似乎没有从它的父模板继承。 例如: index.liquid {% assign foo = "bar" %} {% section 'example' %} s
我正在尝试编写一些代码来估计 Shopify 中的发货日期。我一直在学习 liquid,但在用 Ruby 编写一些逻辑时遇到了问题。我不确定 Shopify 模板是使用 Ruby 还是 Ruby on
我正在尝试为我的客户生成一个注销链接,但想为该链接应用一个类。 {{ 'layout.customer.log_out' | t | customer_logout_link }} 上面的liquid
我有 Shopify 商店,客户可以在购买前设计/定制他们的产品。并且根据所选变体的设计/定制价格可能会有所不同。但我认为 Shopify 不便于在添加到购物车时动态更改变体价格。 我可能缺少任何解决
我做了以下事情: 创建合作伙伴帐户 创建了一个开发商店 创建了一个应用。 但我似乎找不到将我的应用程序添加到我的开发商店的方法。有人可以解释一下如何将它添加到我的开发商店而不将其放入应用商店吗? 最佳
当我在 Shopify 中循环访问一个集合时,我想将该产品添加到另一个产品数组中,以便我可以再次循环访问它。 {% assign custom_products = '' %} {% for prod
我需要在 shopify 产品页面上添加自定义文本框字段。 我的要求是在产品页面上添加文本框字段,当客户在购物车中添加产品时,该文本框字段值也会显示在购物车页面和结帐页面上。 我还需要在管理员自定义订
与 Shopify API您可以设置输入字段供用户调整主题,例如: { "type": "number", "id": "products_per_page", "label": "Pro
我想为我的 shopify 应用程序使用 Polaris css 组件。我看过他们的文件 https://polaris.shopify.com/components/get-started#navi
我是 Shopify 的新手,我正在尝试配置现有主题并遵循此处指南 (https://shopify.github.io/themekit/) 的完整流程,但是当我尝试运行命令主题下载时,它显示了错误
我是一名优秀的程序员,十分优秀!