Open ar-daniel opened 4 years ago
There's a lot here, so let me know if I missed anything.
React support in ionic generate
ionic generate library
is only supported in Ionic Angular 4+. Apologies for the confusion, you probably found the command in the online docs, but those are specific to Angular (we're working on a docs refactor). Use the terminal --help
flag for React-specific CLI documentation. React has no generators, see this issue for React support in ionic generate
: https://github.com/ionic-team/ionic-cli/issues/4432
Importing outside of src/
Looks like you found that this is the standard configuration of apps created with create-react-app
. If react-scripts
doesn't support it, we likely won't be able to support it for a while unless we roll our own webpack configuration. It's much better to keep using react-scripts
and let the devs eject when they need advanced configuration.
If you're using --multi-app
, there's going to be a lot of manual work you'll need to do in order to get it working, especially for React. Not many people use the multi-app feature and we try to prioritize as best we can.
Generating libraries
I'm interested in hearing more about this. This would basically generate a TypeScript library with package.json
, tsconfig.json
, src/index.ts
, etc? My first thoughts are it's easy enough to do manually and that people may not use it enough to warrant the feature.
Thanks for acknowledging and creating a new issue.
I don't feel good about ejecting and mess up with the build configuration / lose the benefits that come with the initial ionic setup. I just attempted to rewire the config as a work-around.
Multi app setup could be seen as a common scenario when the interface of mobile and web are done separately (for the majority of UI and routing) and all the components in it are placed in the shared library. This would prove viable when dealing with different screen sizes while needing to achieve acceptable UI standard for the web page. And on extension to create desktop app like electron -(with necessary changes for desktop UI), this case would prove more useful. Please consider prioritizing.
For creating libraries- Yes, The library files would contain package.json, tsconfig.json, capacitor.config.json, .gitignore and src template tsx files with
Creating it manually would be similar to setting up what the ionic start template gives from scratch.
For reference - I've found a tool - 'create-react-library' which can be used to create separate libraries that can be imported in any react project. Also has support for typescript. and sets up an example react app within the workspace (created with create-react-app) for integration and testing in an actual app environment, - all done through a CLI. https://github.com/transitive-bullshit/create-react-library
@dwieeb did you find a way to use react-app-rewired with ionic on a monorepo ?
Description:
In multi app react project
and when creating a shared lib folder manually
associated issue
Steps to Reproduce:
Output:
-- and when manually creating shared lib/ component and referencing from within a project throws an error
My
ionic info
:Other Information:
Expected behaviour:
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
and in the package.json updating scripts as
but didnt work for ionic serve. same error as before when executing npm start used gives