Skip to content
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

@Args() and @Ctx() breaks build when using babel-loader #571

Closed
tzarger opened this issue Mar 11, 2020 · 1 comment
Closed

@Args() and @Ctx() breaks build when using babel-loader #571

tzarger opened this issue Mar 11, 2020 · 1 comment
Labels
Community 👨‍👧 Something initiated by a community Duplicate 🔑 This issue or pull request already exists Question ❔ Not future request, proposal or bug issue

Comments

@tzarger
Copy link

tzarger commented Mar 11, 2020

Describe the bug
Using @Args() and @ctx() being empty function seems to cause issues with babel-loader when I am using the suggested method in previous issues. I think this issue is a new one, thus opening a new issue.

babel-plugin-transform-typescript-metadata

which actually still doesn't completely work as I have to also use:

babel-plugin-parameter-decorator

The issue seems to give the error:

TypeError: Cannot read property '0' of undefined

The issue is the fact the @Args() is undefined since it has no typing it seems.

Here is my babel-loader
{ test: /\.(j|t)s$/i, use: [ { loader: "babel-loader", options: { cacheDirectory: true, presets: ["@babel/preset-typescript"], plugins: [ "babel-plugin-parameter-decorator", "babel-plugin-transform-typescript-metadata", ["@babel/plugin-proposal-decorators", { legacy: true }], ["@babel/plugin-proposal-class-properties", { loose: true }] ] } } ], }

tsconfig.json
{ "compilerOptions":{ "target":"es2019", "moduleResolution":"node", "resolveJsonModule":true, "module":"commonjs", "noEmit":true, "strict":true, "esModuleInterop":true, "emitDecoratorMetadata":true, "experimentalDecorators":true, "skipLibCheck":true, "jsx":"preserve", "baseUrl":".", "paths":{ "@/*":[ "src/*" ] } }, "include":[ "src", "run", "types" ] }

Is there something I am missing? Or something to get this to work as there seems to be others that say this works. For clarity if only using @arg(...), that works. I need @ctx() for passing user and db connection through... unless there is a better injection method for that?

Is there any work-around for this?

Environment (please complete the following information):

  • OS: Mac OS
  • Node 11.15.0
  • Package version 0.17.6
  • TypeScript version 3.8.2

Additional context
"@babel/core": "^7.8.4",
"@babel/plugin-proposal-class-properties": "^7.8.3",
"@babel/plugin-proposal-decorators": "^7.8.3",
"@babel/plugin-proposal-nullish-coalescing-operator": "^7.8.3",
"@babel/plugin-proposal-numeric-separator": "^7.8.3",
"@babel/plugin-proposal-object-rest-spread": "^7.8.3",
"@babel/plugin-proposal-optional-chaining": "^7.8.3",
"@babel/plugin-syntax-dynamic-import": "^7.8.3",
"@babel/preset-react": "^7.8.3",
"@babel/preset-typescript": "^7.8.3",

This is being used in an SSR scenario, not sure that matters.

@MichalLytek
Copy link
Owner

There's no official support for JS yet, so you can't use babel or other JS tools.
And I'm afraid it won't change in the future as #296 gonna use custom TS compiler plugin so you will loose a lot of TypeGraphQL vNext goodness by sticking to babel.

Please read that thread and ask other guys for help if it still doesn't work for you:
#55 (comment)

@MichalLytek MichalLytek added Community 👨‍👧 Something initiated by a community Duplicate 🔑 This issue or pull request already exists Question ❔ Not future request, proposal or bug issue labels Mar 11, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Community 👨‍👧 Something initiated by a community Duplicate 🔑 This issue or pull request already exists Question ❔ Not future request, proposal or bug issue
Projects
None yet
Development

No branches or pull requests

2 participants