question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Building SSR fails with typescript errors out-of-the-box

See original GitHub issue

Describe the bug The index.js file generated from running quasar build -m ssr causes the command to fail with Typescript errors.

Codepen/jsFiddle/Codesandbox (required) N/A

To Reproduce

  1. Scaffold new Quasar project using quasar create with following configuration:
? Project name (internal usage for dev) foo
? Project product name (must start with letter if building mobile apps) Quasar App
? Project description A Quasar Framework app
? Author Pierre Pirault
? Pick your favorite CSS preprocessor: (can be changed later) Sass
? Pick a Quasar components & directives import strategy: (can be changed later) Auto import
? Check the features needed for your project: ESLint (recommended), TypeScript, Axios
? Pick a component style: Composition
? Pick an ESLint preset: Standard
? Continue to install project dependencies after the project has been created? (recommended) NPM
  1. Run quasar build -m ssr

Expected behavior App successfully builds

Actual behavior

 App · Added build artifact "/Users/pierrepirault/foo/foo/dist/ssr"

 App · ⚠️  27 errors encountered:

/Users/pierrepirault/foo/foo/src-ssr/index.js
ERROR in /Users/pierrepirault/foo/foo/src-ssr/index.js(14,17):
@typescript-eslint/no-var-requires: Require statement not part of import statement.
/Users/pierrepirault/foo/foo/src-ssr/index.js
ERROR in /Users/pierrepirault/foo/foo/src-ssr/index.js(15,7):
@typescript-eslint/no-unsafe-assignment: Unsafe assignment of an any value.
/Users/pierrepirault/foo/foo/src-ssr/index.js
ERROR in /Users/pierrepirault/foo/foo/src-ssr/index.js(15,21):
@typescript-eslint/no-var-requires: Require statement not part of import statement.
/Users/pierrepirault/foo/foo/src-ssr/index.js
ERROR in /Users/pierrepirault/foo/foo/src-ssr/index.js(17,7):
@typescript-eslint/no-unsafe-assignment: Unsafe assignment of an any value.
/Users/pierrepirault/foo/foo/src-ssr/index.js
ERROR in /Users/pierrepirault/foo/foo/src-ssr/index.js(17,13):
@typescript-eslint/no-var-requires: Require statement not part of import statement.
/Users/pierrepirault/foo/foo/src-ssr/index.js
ERROR in /Users/pierrepirault/foo/foo/src-ssr/index.js(18,19):
@typescript-eslint/no-var-requires: Require statement not part of import statement.
/Users/pierrepirault/foo/foo/src-ssr/index.js
ERROR in /Users/pierrepirault/foo/foo/src-ssr/index.js(22,47):
@typescript-eslint/no-unsafe-call: Unsafe call of an any typed value.
/Users/pierrepirault/foo/foo/src-ssr/index.js
ERROR in /Users/pierrepirault/foo/foo/src-ssr/index.js(22,47):
@typescript-eslint/no-unsafe-member-access: Unsafe member access .resolveWWW on an any value.
/Users/pierrepirault/foo/foo/src-ssr/index.js
ERROR in /Users/pierrepirault/foo/foo/src-ssr/index.js(27,9):
@typescript-eslint/no-unsafe-call: Unsafe call of an any typed value.
/Users/pierrepirault/foo/foo/src-ssr/index.js
ERROR in /Users/pierrepirault/foo/foo/src-ssr/index.js(30,5):
@typescript-eslint/no-unsafe-member-access: Unsafe member access .settings on an any value.
/Users/pierrepirault/foo/foo/src-ssr/index.js
ERROR in /Users/pierrepirault/foo/foo/src-ssr/index.js(31,11):
@typescript-eslint/no-unsafe-call: Unsafe call of an any typed value.
/Users/pierrepirault/foo/foo/src-ssr/index.js
ERROR in /Users/pierrepirault/foo/foo/src-ssr/index.js(31,11):
@typescript-eslint/no-unsafe-member-access: Unsafe member access .resolveUrl on an any value.
/Users/pierrepirault/foo/foo/src-ssr/index.js
ERROR in /Users/pierrepirault/foo/foo/src-ssr/index.js(35,9):
@typescript-eslint/no-unsafe-call: Unsafe call of an any typed value.
/Users/pierrepirault/foo/foo/src-ssr/index.js
ERROR in /Users/pierrepirault/foo/foo/src-ssr/index.js(35,9):
@typescript-eslint/no-unsafe-member-access: Unsafe member access .resolveUrl on an any value.
/Users/pierrepirault/foo/foo/src-ssr/index.js
ERROR in /Users/pierrepirault/foo/foo/src-ssr/index.js(38,28):
@typescript-eslint/no-unsafe-assignment: Unsafe assignment of an any value.
/Users/pierrepirault/foo/foo/src-ssr/index.js
ERROR in /Users/pierrepirault/foo/foo/src-ssr/index.js(41,9):
@typescript-eslint/no-unsafe-call: Unsafe call of an any typed value.
/Users/pierrepirault/foo/foo/src-ssr/index.js
ERROR in /Users/pierrepirault/foo/foo/src-ssr/index.js(41,9):
@typescript-eslint/no-unsafe-member-access: Unsafe member access .resolveUrl on an any value.
/Users/pierrepirault/foo/foo/src-ssr/index.js
ERROR in /Users/pierrepirault/foo/foo/src-ssr/index.js(74,3):
@typescript-eslint/no-unsafe-call: Unsafe call of an any typed value.
/Users/pierrepirault/foo/foo/src-ssr/index.js
ERROR in /Users/pierrepirault/foo/foo/src-ssr/index.js(74,3):
@typescript-eslint/no-unsafe-member-access: Unsafe member access .renderToString on an any value.
/Users/pierrepirault/foo/foo/src-ssr/index.js
ERROR in /Users/pierrepirault/foo/foo/src-ssr/index.js(76,11):
@typescript-eslint/no-unsafe-member-access: Unsafe member access .url on an any value.
/Users/pierrepirault/foo/foo/src-ssr/index.js
ERROR in /Users/pierrepirault/foo/foo/src-ssr/index.js(77,22):
@typescript-eslint/no-unsafe-member-access: Unsafe member access .url on an any value.
/Users/pierrepirault/foo/foo/src-ssr/index.js
ERROR in /Users/pierrepirault/foo/foo/src-ssr/index.js(78,7):
brace-style: Closing curly brace does not appear on the same line as the subsequent block.
/Users/pierrepirault/foo/foo/src-ssr/index.js
ERROR in /Users/pierrepirault/foo/foo/src-ssr/index.js(79,16):
@typescript-eslint/no-unsafe-member-access: Unsafe member access .code on an any value.
/Users/pierrepirault/foo/foo/src-ssr/index.js
ERROR in /Users/pierrepirault/foo/foo/src-ssr/index.js(83,7):
brace-style: Closing curly brace does not appear on the same line as the subsequent block.
/Users/pierrepirault/foo/foo/src-ssr/index.js
ERROR in /Users/pierrepirault/foo/foo/src-ssr/index.js(88,13):
@typescript-eslint/no-unsafe-member-access: Unsafe member access .settings on an any value.
/Users/pierrepirault/foo/foo/src-ssr/index.js
ERROR in /Users/pierrepirault/foo/foo/src-ssr/index.js(91,25):
@typescript-eslint/no-unsafe-member-access: Unsafe member access .stack on an any value.
/Users/pierrepirault/foo/foo/src-ssr/index.js
ERROR in /Users/pierrepirault/foo/foo/src-ssr/index.js(94,5):
brace-style: Closing curly brace does not appear on the same line as the subsequent block.

 App · ⚠️  [FAIL] Build failed with 27 errors. Check log above.

Platform (please complete the following information): OS: MacOS Node: 12.16.1 NPM: 6.14.7 Quasar: 2.0.6

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:9 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
IlCallocommented, Aug 10, 2020

@papiro

Linting uses different rules depending on the preset you choose when creating the project and if you have TS support or not. Fixing those issues for your configuration would probably rise warnings for another devs. You can try running a yarn lint --fix after the mode installation, but some rules (@typescript-eslint/no-unsafe-member-access and similar in particular) are actually good advices.

We could add eslint-disable-next-line for those warnings as we know the current generated code Just Works™. Can you try to make the file comply with the linter (all 3 presets) and disable rules on a line-by-line basis, and propose a PR with the needed fixes?

You should also probably add /* eslint-env node */ at the top of the file, if not already there

0reactions
rstoenescucommented, Aug 23, 2020

Indeed this should have not been closed. The problem lies in the fact that those eslint errors are actually wrong. @typescript-eslint/no-var-requires: Require statement not part of import statement. --> wrong. The src-ssr runs in Node context, so “import” would actually break the app.

Fixed it in the starter kit. Unfortunately, it just ignores the /src-ssr folder, which should abide by different linting rules. @incorrupt

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular 11 SSR is compiled,but having issue with prod build ...
typescript - Angular 11 SSR is compiled,but having issue with prod build and serve no content showed up in browser - Stack Overflow....
Read more >
Basic Features: TypeScript - Next.js
Next.js fails your production build ( next build ) when TypeScript errors are present in your project. If you'd like Next.js to dangerously...
Read more >
Workaround for Issue with Server-Side Rendering in ... - SAP
This document describes a temporary workaround for a problem with running Spartacus 2.0 with Server-Side Rendering (SSR) on SAP Commerce Cloud in the...
Read more >
SSG vs. SSR in Next.js - LogRocket Blog
SSG describes the process of building websites that render at build time. The output is an HTML file, assets such as JavaScript and...
Read more >
Keeping Server-Side Rendering Cool With React Hydration
Frameworks like NextJS and GatsbyJS support SSR out of the box. ... such as layout shifts or errors that only appear at build-time....
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found