-
-
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
Serverless framework + webpack #4788
Comments
About the second error. src/driver/aurora-data-api/AuroraDataApiDriver.ts
|
I believe this is related to this: webpack/webpack#4742 The fix provided by @h-takenori worked for us as well; I will submit a pull request so it gets included in the main package. |
…typeorm#4788) TypeORM uses require() within PlatformTools to load driver packages. The typeorm-aurora-data-api-driver is exported with export default and packaged with rollup, which, as per webpack/webpack#4742, causes the require'd module to be available via require('typeorm-aurora-data-api-driver').default property.
I currently moved |
…#4788) (#5302) TypeORM uses require() within PlatformTools to load driver packages. The typeorm-aurora-data-api-driver is exported with export default and packaged with rollup, which, as per webpack/webpack#4742, causes the require'd module to be available via require('typeorm-aurora-data-api-driver').default property.
Issue type:
[x] question
Database system/driver:
[x]
mysql
/mariadb
(+ aurora data api)TypeORM version:
[x]
latest
Steps to reproduce or a small repository showing the problem:
Add this on handler.ts
And then invoke the lamda from the url.
The issue
Greeting and thanks for this amazing library.
I have a problem while i try to make typeorm work with the serverless framework, and especially the template with typescript+webpack +aws. I tried this with the aurora-data-api, but I have a similar problem with MySQL.
I think it's a 2-part problem.
The first problem is the dynamic load of typeorm. Webpack is compiling code and libraries on a single file, while perfoming tree-shaking (correct me if I'm wrong).
So when you invoke the function on aws lambda, you would get
My workaround for that was to add on
node_modules/typeorm/platform/PlatformTools.js
file, on theload
function the following code:This way webpack is forced to import the module, which leads as to the next error.
When you invoke again the lambda, you get this error:
After digging around, i saw that the way you have compiled the library, the module is loaded like
{default: DataApiDriver}
So my second "workaround" was change the
loadDependencies
method ofnode_modules/typeorm/driver/aurora-data-api/AuroraDataApiDriver.js
to:So with those 2 changes, i was able to use the 2 libraries(typeorm + typeorm-aurora-data-api-driver). Obviously, changing directly the library files is a big no-no, but also because those changes are specific for aws+serverless framework+ webpack, i guess I can't make a PR.
I think my backup plan is to fork this and try to stay up to date, but i would like to discuss it if there is a cleaner solution.
Thanks in advance!
The text was updated successfully, but these errors were encountered: