You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/TypeORM-Usage.md
+115-1Lines changed: 115 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -72,7 +72,7 @@ module.exports = {
72
72
73
73
## Ionic/Angular app
74
74
75
-
An example of a Ionic/Vue app has been developed https://github.com/jepiqueau/ionic-sqlite-typeorm-app demonstrating the use of TypeORM with migrations. The migration files have been created manually, not using the TypeORM cli ( generate, create ). If one find the way of using the TypeORM cli he or she will be welcome to make a PR to this documentation and make a PR to the application.
75
+
An example of a Ionic/Angular app has been developed https://github.com/jepiqueau/ionic-sqlite-typeorm-app demonstrating the use of TypeORM with migrations. The migration files have been created manually, not using the TypeORM cli ( generate, create ). If one find the way of using the TypeORM cli he or she will be welcome to make a PR to this documentation and make a PR to the application.
76
76
77
77
### Requirements
78
78
@@ -153,4 +153,118 @@ An example of a Ionic/Vue app has been developed https://github.com/jepiqueau/io
153
153
},
154
154
```
155
155
156
+
## Ionic/React app
157
+
158
+
An example of a Ionic/React app has been developed https://github.com/cosentino/capacitor-sqlite-react-typeorm-app demonstrating the use of TypeORM with migrations. The migration files have been created manually, not using the TypeORM cli ( generate, create ). If one find the way of using the TypeORM cli he or she will be welcome to make a PR to this documentation and make a PR to the application.
159
+
160
+
### Requirements
161
+
162
+
Since Create React App does not allow to tweek the react project compilation as required by TypeORM.
163
+
We thus need to replace react-script with a tool such as [CRACO](https://craco.js.org/) and then override the default configurations (note: ejecting CRA is a viable solution).
164
+
CRACO will allow us to customize the default CRA Webpack configuration.
165
+
166
+
#### 1. Install the latest version of the package from npm as a dev dependency
167
+
168
+
```bash
169
+
npm i -D @craco/craco craco-swc
170
+
```
171
+
172
+
#### 2. Create a CRACO configuration file in your project's root directory and configure
173
+
174
+
Create the files craco.config.js and .swcrc the files in the project root.
175
+
The following will tell CRACO to:
176
+
177
+
- force the minimizer (Terser) settings "keep_classnames" and "keep_fnames" to true
178
+
- use SWC instead of Babel as transpiler
179
+
- configure SWC parser and tranformer so that uses "legacyDecorator" and "decoratorMetadata"
180
+
181
+
craco.config.js:
182
+
183
+
```js
184
+
const CracoSwcPlugin = require('craco-swc');
185
+
186
+
module.exports = {
187
+
plugins: [
188
+
{
189
+
plugin: CracoSwcPlugin, // see .swcrc for SWC configuration (that will replace Babel)
0 commit comments