How to alias modules in Next at runtime, e.g. type-graphql's browser shim as type-graphl #14891
Replies: 3 comments
-
also...
is being ignored @timneutkens @Timer do you have a clue and know what is going on? |
Beta Was this translation helpful? Give feedback.
-
@timneutkens @Timer this was moved without any notice to discussions. :/ I guess you are busy but a small hint why you think this is not a bug and something like a config error would be nice. I asked on reddit, reactiflux, type-graphql and tried a lot, so some hint would be appreciated. |
Beta Was this translation helpful? Give feedback.
-
@timneutkens @Timer found the solution: for others driving by:
|
Beta Was this translation helpful? Give feedback.
-
Bug report
Describe the bug
I'm using webpack's
NormalModuleReplacementPlugin
to replacetype-graphql
on the client with its shimtype-graphql/dist/browser-shim.js
.Next.js still uses the full version and not the shim.
I assume that it's not a webpack config problem because the function gets executed two times and the resource.request gets properly overwritten (tested with
console.log
s), so I assume that it's also executed on the server side and respectively should pull the shim.Edit: I get the error of the real
type-graphql
module both on the server logs and on the client's console/Inspector.To Reproduce
npm i type-graphql
Add
Movie.ts
:Import and initiate it in
index.ts
:FWIW, it aso does not work, when doing
next.config.js
:Expected behavior
type-graphql
should not be executed but just its shim, so the decorators get literally just decoration.System information
Additional context
Background: I need the classes for type-safety and validation for the client but without the graphql-layer of
type-graphql
.Beta Was this translation helpful? Give feedback.
All reactions