Ionic CLI: creating multi app - fails to generate to shared components for react project and not able to import files outside of src directory
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 32/100
- issue の種類
- 機能追加
- 明瞭さ
- おおむね明確
- 活発さ
- 停滞
- 技術スタック
- react, typescript
- 領域
- build-system, cli, frontend
調査の方向性
まず、ionic init --multi-app、ionic generate library sharedlib --project=mobile --dry-run、および報告されている共有フォルダーからのインポートで失敗を再現します。生成された ionic.config.json、capacitor.config.json、React プロジェクトの設定、および config-overrides.js を確認します。完了の条件は、bare プロジェクトと React プロジェクトで生成が機能し、共有ファイルを参照でき、React に対する Capacitor の webDir が正しいことです。
索引モデルが issue の本文から書いたものです。
説明
Description:
In multi app react project
-
unable to generate framework components using 'ionic generate' cmd (for creating a shared a library to be used by the mulitple apps.)
-
and when creating a shared lib folder manually
- unable reference files in the common folder from within the apps in a multi app setup. states that - Relative imports outside of src/ are not supported.
associated issue
- when setting up a capacitor ionic project within multiapp. In the capacitor.config.json
- the value of "webDir" is set to "www", rather to be set to "build" for react projects.
Steps to Reproduce:
after initializing and creating a multi app project
$ ionic init --multi-app
$ ionic start
//( for creating different apps in a sub-folder which would share a common library)
$ ionic generate library sharedlib --dry-run
//or shared component
$ ionic generate component sharedcompt --dry-run
Output:
$ ionic generate library sharedlib --dry-run
[WARN] Multi-app workspace detected, but cannot determine which project to use.
Please set a defaultProject in ./ionic.config.json or specify the project using the
global --project option. Read the documentation[1] for more information
[1]: https://ion.link/multi-app-docs
[ERROR] Cannot perform generate for bare projects.
The Ionic CLI doesn't know how to generate framework components for bare projects.
$ ionic generate library sharedlib --project=mobile --dry-run
[ERROR] Cannot perform generate for React projects.
Since you're using the React project type, this command won't work. The Ionic CLI
doesn't know how to generate framework components for React projects.
-- and when manually creating shared lib/ component and referencing from within a project
throws an error
Failed to compile
./src/pages/Home.tsx
Module not found: You attempted to import ../../../../common/src/tools/common/pages/ToolsPage which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
My ionic info:
Ionic:
Ionic CLI : 6.8.0 (/usr/lib/node_modules/@ionic/cli)
Ionic Framework : @ionic/react 5.1.0
Capacitor:
Capacitor CLI : 2.1.0
@capacitor/core : 2.1.0
Utility:
cordova-res : not installed
native-run : not installed
System:
NodeJS : v14.2.0 (/usr/bin/node)
npm : 6.14.4
OS : Linux 5.0
Other Information:
Expected behaviour:
- to be able to generate/create shared files in a multiapp setup in bare projects. ( not to be associated a particular project)
- ionic generate for react projects to work.
- even if the shared file to be created manually - referencing of files (shared library files) outside of application src folder to be possible. (as that's the purpose of creating a multi app setup )
Attempts made to fix:
-- tried to rewire the build config with a rewire tool
https://github.com/timarney/react-app-rewired
following the instructions to use and
with creating a config-overrides.js file in project folder - code as follows as per
https://stackoverflow.com/questions/44114436/the-create-react-app-imports-restriction-outside-of-src-directory
const ModuleScopePlugin = require('react-dev-utils/ModuleScopePlugin');
module.exports = function override(config, env) {
config.resolve.plugins = config.resolve.plugins.filter(plugin => !(plugin instanceof ModuleScopePlugin));
return config;
};
and in the package.json updating scripts as
"scripts": {
"start": "react-app-rewired start",
"build": "react-app-rewired build",
"test": "react-app-rewired test",
"eject": "react-scripts eject"
},
but didnt work for ionic serve. same error as before
when executing npm start used gives
Module parse failed: Unexpected token (17:17)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
|
|
> const route_Tools: React.FC = () => {
| return (
| <IonPage>
- 主要言語
- TypeScript
- スター
- 2k
- フォーク
- 681
- PR マージ指標
- 30日以内にマージされた PR はありません
コントリビューションガイド
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
ionic-team/ionic-cli のほかの issue
-
triage
難易度 1/5 1時間未満 初心者へのやさしさ 65/100
ionic-team/ionic-cli#5016 ·
-
triage
難易度 5/5 1週間以上 初心者へのやさしさ 15/100
ionic-team/ionic-cli#5131 ·
-
triage
難易度 3/5 1〜2日 初心者へのやさしさ 56/100
ionic-team/ionic-cli#5130 ·
-
triage
難易度 3/5 1〜2日 初心者へのやさしさ 72/100
ionic-team/ionic-cli#5129 ·
-
triage
難易度 3/5 1〜2日 初心者へのやさしさ 42/100
ionic-team/ionic-cli#5127 · コメント 2 件 ·
ionic-team/ionic-cli の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
copse-dev/agent-pane#2953 ·
-
難易度 2/5 1〜3時間 初心者へのやさしさ 84/100
Eynzof/Hermes-CN-Desktop#610 ·
-
bug clawsweeper:linked-pr-open clawsweeper:needs-live-repro clawsweeper:no-new-fix-pr impact:message-loss issue-rating: 🐚 platinum hermit P2 regression
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
-
enhancement
難易度 2/5 1〜3時間 初心者へのやさしさ 68/100
-
calcite-components needs triage refactor
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
Esri/calcite-design-system#15203 ·