Open wexstorm opened 6 years ago
thanks for the feedback!
This fixes indeed some compiler issues, but not all of them. I now get this:
Module not found: Error: Can't resolve 'react-native-sqlite-storage' in '/Users/mzrinck/projects/ionic4/node_modules/typeorm/browser/driver/react-native'
I'm not sure whats the issue now.
What do you mean that window.SQL is now undefined? Does this happen for you during runtime or during some build step?
It looks like its the same problem I had in my original issue after upgrading manually to angular6 https://github.com/typeorm/ionic-example/issues/23#issue-339441578
Hi,
you can cirumvent this issue in commenting out some lines (yeah, dirty hack) in
node_modules/typeorm/browser/driver/react-native/ReactNativeDriver.js:
try { this.sqlite = require("react-native-sqlite-storage"); } catch (e) { throw new DriverPackageNotInstalledError("React-Native", "react-native-sqlite-storage"); }
Then you get another issue with sqljs an that is the part I'm working on at the moment.
The problem seems to be that in all Tutorials for ionic and typeorm webpack is being used, where
window.SQL is provided as plugin
new webpack.ProvidePlugin({ 'window.SQL': 'sql.js/js/sql.js' })
That's the point where I'm stuck now (doing this without webpack).
Okay, I got it working. The "fix" from my previous post is not necessary. Due to incompatibilities of Angular 6 an "fs" you have to edit some files:
require("fs")
with
null
node: false,
to
node: { crypto: true, stream: true },
var sql = require('sql.js');
in line 306 above
if (PlatformTools.type === "browser") { //this.sqlite = window.SQL; this.sqlite = window.SQL; }
I know this is REALLY dirty, but you can now test in the Browser.
Cheers
yes, the build works indeed with these changes. And of course, this is no solution that should be used in any serious project.
Point 1 and 3 could be fixed in sql.js/typeorm but the change in angular-devkit seems to be one the angular devs explicitely have changed in angular 6 so I see no chance that it will be changed there.
I'm sorry, that I'm no real help, but I know next to nothing about webpack.
Any updates on this, seems to still be happening on Angular 7 and is a rather significant blocker
Hi,
just reverted all changes from my last Post and did these changes:
package.json (add config):
"browser": { "http": false, "https": false, "net": false, "path": false, "stream": false, "tls": false }
app/tsconfig.app.json (change line under compiler options):
"types" : []
to
"types" : ["node"]
This seems to compile a freshly installed ionic 4 App including typeorm.
Cheers
@wexstorm Hi, im having the same issues. What do you mean by "... (add config):"?
After that, should I run npm i
or just ionic serve
?
hey @varogonz95 please have a look at https://github.com/coturiv/ionic4-typeorm-starter it works almost perfect as a starter project for ionic4 and typeorm.
I have only 2 problems:
@varogonz95: It means, you have to add those lines, if they are not there.
@marcorinck: I cannot get it to work with sql.js 1.0 - this is frustrating...
@wexstorm like this?
{
//etc...
"config":
{ "browser": { "http": false, "https": false, "net": false, "path": false, "stream": false, "tls": false } }
}
@marcorinck Hi, I saw this issue yesterday while doing some testing. I think you can completely ignore those warnings. But if you want to suppress them: https://stackoverflow.com/questions/50798660/suppress-circular-dependency-detected-suppress-warning-in-angular-6
@varogonz95 the thing is you can choose to suppress or ignore those warnings, but in this case they are reported for a reason. The imported dependencies (entities) are null and can‘t be used for anything. You have to fix the underlying problem if you want to use them. Without using strings in the decorator to describe your relations, your only solution is using EntitySchemas.
@wexstorm I‘m using sqlite in Cordova, works without a problem so far.
hey @varogonz95 please have a look at https://github.com/coturiv/ionic4-typeorm-starter it works almost perfect as a starter project for ionic4 and typeorm.
I have only 2 problems:
- it tries to patch a driver file of typeorm after installation, this fails on my mac but I can do it manually, see scripts/patch.sh (of course, even the need to do this is still a problem for real world projects, but what can we do)
- angular CLI is complaining about circular dependencies with the entities as they are checked in (because of OneToMany/ManyToOne relations). You can use either EntitySchemas or use a new approach to define those relations introduced in typeorm 0.2.18 (its using strings, instead of typesafe classes), see their changelog how to do this
How to run this patch.sh in ionic4?
Hi,
thanks for your effort. You can try to get this to run with the following "fix":
"paths": { "typeorm": ["../node_modules/typeorm/browser"] },
Sadly now window.SQL is undefined, because of no webpack compilation. Does this work for you?Cheers