[英]Multi module projects with create-react-app
我有一個名為Frontend-Core-Components
的項目,其中包含我的 App 組件。
我有另一個包含AlphaApiService
的項目(我們暫時稱它為Alpha
),我通過它的道具將它傳遞給 App 組件,我在 Alpha 的index.tsx
中執行此操作
Alpha
uses Create-react-app, I'm using rescript to modify the Webpack config to add Frontend-core-components as a module, Inside this Webpack configuration, I use resolve.alias
to map imports from Alpha index.tsx
to the Frontend-Core-Components
。
這一切似乎都有效,除了當我從 Alpha 項目運行構建時,我遇到以下情況。
SyntaxError: /Users/coolguy/project/alpha/src/index.tsx: Unexpected token (9:11)
7 |
8 | window.onload = () => {
> 9 | render(<App apiService={new AlphaApiService()} />,
document.getElementById('root'))
| ^
10 | }
11 |
有任何想法嗎?
或者,您可以在ts-loader
(或babel-loader
)規則中包含Frontend-Core-Components
。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.