Open KAMAELUA opened 4 years ago
Same issue here. When downgrading to Webpack 4, it works fine.
Same here.
Anyone able to workaround it somehow?
Looking at the code output by Webpack 😨 :
class Model extends sequelize_1.Model {
constructor(values, options) {
if (true) { // whaaat...
throw new model_not_initialized_error_1.ModelNotInitializedError(new.target, `${new.target.name} cannot be instantiated.`);
}
super(values, alias_inference_service_1.inferAlias(options, new.target));
}
This is a bug in Webpack 5.
Reported it here - https://github.com/webpack/webpack/issues/12339
Nothing to do with this package - I think this issue can now be resolved - upgrading to the next version of Webpack when released should do the trick.
@roni-frantchi are you sure? According to https://github.com/webpack/webpack/pull/12343 this was merged to Master in Jan and the latest version 5.37.0 released yesterday still produces this issue as far as I can tell.
This is a bug in Webpack 5. Reported it here - webpack/webpack#12339
Nothing to do with this package - I think this issue can now be resolved - upgrading to the next version of Webpack when released should do the trick.
@tomfree haven't upgraded to 5.37.0 - we're currently on 5.36.2 and I can confirm we're not seeing this error anymore with our configuration
Just came across this issue too, what fixed it for me was normalizing the paths used to import my models. In my sequelize init script i was using relative paths (./User
), but in my application I was using a path alias (@models/User
).
Switching it to use @models/User
everywhere solved this for me.
Versions
I'm submitting a ...
[x] bug report [ ] feature request
Actual behavior: Sequelize-typescript throwing " Model not initialized: UserModel cannot be instantiated. "UserModel" needs to be added to a Sequelize instance." exception when trying to run any queries,
The problem in model constructo:
new.target
is always undefined. But I can getisInitialized
property from model and its set totrue
.It works correct if I am trying to run that code without Webpack 5. Webpack 4 works correct.
Related code: https://github.com/KAMAELUA/sequelize-typescript-webpack-error
Steps to reproduce: ts-node works correct, so everything fine with my code:
Webpack fails: