-
-
Notifications
You must be signed in to change notification settings - Fork 6.2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ionic 4 mangles table names when using --prod #2164
Comments
|
Doesn't :( |
it must work. Are you sure its not your setup or any other issue? You have to provide a minimal reproduction code repo in the case if you can't find a resolution. |
Also confirmed with ionic-example repository that I am able to reproduce the same problem. Observations which are common across both my app and ionic-example.
I believe what is happening is in some queries tables get renamed to "a" and it fails since there's a cyclic dependency between the Table we are creating data and the FK relation. |
One of solutions is to disable mangling in your uglify options. |
I'm getting the exact same error on save.
|
@pleerock You are right, I was able to solve the issue by disabling mangling using custom uglify options. Described here: https://ionicframework.com/docs/developer-resources/app-scripts/ |
It also works if you disable uglify altogether. But is there an option where mangle can stay enabled? If its the relationship, can we pass the entity name like you can for the table name in @entity? |
@cjackson234 I don't know all issues you might face after magnification, so you might try that. Also disabling mangle practically doesn't affect your bundle size so much, so maybe its easier to simply disable it then keep maintaining names in your entities. |
The reason I don't want to do that is that my application is electron based. I don't want my code to be easily read. |
Just disabling mangling won't make it easily readable =) |
@pleerock Is there a solution/ a tool for checking that cyclic dependency with the |
But you do have uglify ability with even disabled mangle option, right? How much disabling mangle safes you? Few bytes? |
The funny thing is that it worked until yesterday.
Then I had to disable the mangle option because of cyclic dependency
…On Wed, Jul 11, 2018, 21:16 Umed Khudoiberdiev ***@***.***> wrote:
But you do have uglify ability with even disabled mangle option, right?
How much disabling mangle safes you? Few bytes?
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#2164 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AHsTt5-CpYh8zxxW7Vg_-Aouq4d96_Czks5uFkD8gaJpZM4UC48B>
.
|
Same applies for Nativescript, you have to disable mangle in the webpack config |
Same problem here. Is this still an open issue?
This problem only occurs when building production. This is my package file, but it doesn't work:
Ionic 3 with TypeORM 0.2.17 |
I found the solution by disabling the mangling. The link above is invalid. Use this one instead:
|
You can also put the class names of the entities to the mangle reserved option. So you don't have to get completely rid of the mangle stuff.
|
Hi all, If someone happens to have the same problem on a Ionic 5 project with vue.js, i managed to solve this adding this to module.exports = {
chainWebpack: config => {
if (process.env.NODE_ENV === 'production') {
config.optimization.minimizer('terser').tap((args) => {
// see https://cli.vuejs.org/guide/webpack.html#chaining-advanced
// https://cli.vuejs.org/migrating-from-v3/#vue-cli-service
// => chainWebpack for a chain override example
// https://github.com/terser/terser#minify-options for terser options
const terserOptions = args[0].terserOptions
// Avoid to mangle entities (leads to query errors)
terserOptions["keep_classnames"] = true
terserOptions["keep_fnames"] = true
// console.log(JSON.stringify(args[0], null, 2))
return args
})
}
},
// ...rest of your vue.config.js...
} (I left in the code some comments with useful links for the options.) The solutions with Cheers. |
I can't replicate with the ionic example When opening an issue, people will be better able to provide help if you provide code that they can easily understand and use to reproduce the problem. This boils down to ensuring your code that reproduces the problem follows the following guidelines:
MinimalThe more code there is to go through, the less likely people can find your problem. Streamline your example in one of two ways:
Don't sacrifice clarity for brevity when creating a minimal example. Use consistent naming and indentation, and include code comments if needed. Use your code editor’s shortcut for formatting code. Don't include any passwords or credentials that must be kept secret. CompleteMake sure all information necessary to reproduce the problem is included in the issue itself. If the problem requires some code as well as some XML-based configuration, include code for both. The problem might not be in the code that you think it is in. Use individual code blocks for each file or snippet you include. Provide a description for the purpose of each block. DO NOT use images of code. Copy the actual text from your code editor, paste it into the issus, then format it as code. This helps others more easily read and test your code. ReproducibleTo help you solve your problem, others will need to verify that it exists. Describe the problem. "It doesn't work" isn't descriptive enough to help people understand your problem. Instead, tell other readers what the expected behavior should be. Tell other readers what the exact wording of the error message is, and which line of code is producing it. Use a brief but descriptive summary of your problem as the title of your question. Eliminate any issues that aren't relevant to the problem. If your question isn’t about a compiler error, ensure that there are no compile-time errors. Double-check that your example reproduces the problem! If you inadvertently fixed the problem while composing the example but didn't test it again, you'd want to know that before asking someone else to help. |
I finally got the migration after adding this in the root as well. Thank you! |
Not related to Ionic, but may help someone as I ended up here while looking for a solution for my case: I had the same issue in a project using Vue/Electron and couldn't figure out a way to solve the mangling issue, after several hours, I ended up with this hacky (and quite unsafe type-wise) solution, but so far it is working: Migration: // @ts-nocheck
import { MigrationInterface, QueryRunner, Table } from 'typeorm';
export let classes = {}; // <- this and ts-nocheck is important
classes['CreatePersonTable1627234546000'] = class implements MigrationInterface {
} Migration List: // @ts-nocheck
import { classes as CreatePersonTable1627234546000 } from "./1627234546000_CreatePersonTable";
export const MigrationList = [
CreatePersonTable1627234546000['CreatePersonTable1627234546000'],
]; I am not sure if my explanation is correct, it is a total guess, but: |
Thanks! |
Issue type:
[ ] question
[x] bug report
[ ] feature request
[ ] documentation issue
Database system/driver:
[x]
cordova
[ ]
mongodb
[ ]
mssql
[ ]
mysql
/mariadb
[ ]
oracle
[ ]
postgres
[ ]
sqlite
[ ]
sqljs
[ ]
react-native
TypeORM version:
[x]
latest
[x]
@next
[ ]
0.x.x
(or put your version here)Steps to reproduce or a small repository showing the problem:
Can't make Ionic work using the --prod flag.
Everything works perfectly when using
ionic cordova run android
orionic cordova run android --release
but as soon as we add the--prod
flag, things start to break.My SQL queries show that all the Queries running look like
FROM TABLE a
irrespective of what model is being used.I have tried the workaround suggested in Ionic example: https://github.com/typeorm/ionic-example
@Entity('user')
getRepository('user')
The text was updated successfully, but these errors were encountered: