stencil icon indicating copy to clipboard operation
stencil copied to clipboard

bug: results.fileNames undefined during compilation in stencil 2.17.3 in NX

Open orl99 opened this issue 2 years ago • 6 comments

Prerequisites

Stencil Version

2.17.3

Current Behavior

Currently, I we are having problems compiling one library that we recently created with a few components for a future DS that we plan to make, this is currently the CLI out when we run nx run aqua-elements:build

image

nx run aqua-elements:build


[ WARN  ]  exit 1

/Users/qismbp12/Documents/GitHub/cbhz-nx/node_modules/@stencil/core/compiler/stencil.js:41837
    results.fileNames = results.fileNames.filter((f) => {
                                ^

TypeError: Cannot read properties of undefined (reading 'fileNames')
    at Object.t.getParsedCommandLineOfConfigFile (/Users/qismbp12/Documents/GitHub/cbhz-nx/node_modules/@stencil/core/compiler/stencil.js:41837:33)
    at pe (/Users/qismbp12/Documents/GitHub/cbhz-nx/node_modules/@stencil/core/compiler/stencil.js:8913:2294592)
    at Object.e.createWatchProgram (/Users/qismbp12/Documents/GitHub/cbhz-nx/node_modules/@stencil/core/compiler/stencil.js:8913:2287601)
    at createTsBuildProgram (/Users/qismbp12/Documents/GitHub/cbhz-nx/node_modules/@stencil/core/compiler/stencil.js:63449:12)
    at /Users/qismbp12/Documents/GitHub/cbhz-nx/node_modules/@stencil/core/compiler/stencil.js:63483:5
    at new Promise (<anonymous>)
    at createFullBuild (/Users/qismbp12/Documents/GitHub/cbhz-nx/node_modules/@stencil/core/compiler/stencil.js:63459:10)
    at Object.build (/Users/qismbp12/Documents/GitHub/cbhz-nx/node_modules/@stencil/core/compiler/stencil.js:64732:23)
    at taskBuild (/Users/qismbp12/Documents/GitHub/cbhz-nx/node_modules/@stencil/core/cli/index.cjs:1671:40)
    at async runTask (/Users/qismbp12/Documents/GitHub/cbhz-nx/node_modules/@stencil/core/cli/index.cjs:2327:13)
image

It's important to mention that we use NX as monorepo.

Any reasons why we are having this problem? Is anyone also having the same problem?

Expected Behavior

Have a successful compilation process

Steps to Reproduce

1- npm i 2- nx run aqua-elements:build

Code Reproduction URL

N/A

Additional Information

No response

orl99 avatar Aug 04 '22 18:08 orl99

Hey @orl99 👋

The value stored in results there is determined by a call to a TypeScript compiler API, getParsedCommandLineOfConfigFiles. That code can be found here. Looking around that source, it appears as it this block might be the offending code that's returning undefined.

I think this could be related to attempting to resolve a TS configuration file, which may make sense if the file is in a monorepo.

I think that Stencil can handle this a little more gracefully, but in order to continue debugging this further, can you create a minimal reproduction case for us to investigate further?

rwaskiewicz avatar Aug 04 '22 21:08 rwaskiewicz

Thanks for the issue! This issue has been labeled as needs reproduction. This label is added to issues that need a code reproduction.

Please reproduce this issue in an Stencil starter component library and provide a way for us to access it (GitHub repo, StackBlitz, etc). Without a reliable code reproduction, it is unlikely we will be able to resolve the issue, leading to it being closed.

If you have already provided a code snippet and are seeing this message, it is likely that the code snippet was not enough for our team to reproduce the issue.

For a guide on how to create a good reproduction, see our Contributing Guide.

ionitron-bot[bot] avatar Aug 04 '22 21:08 ionitron-bot[bot]

Thanks for this thread, I have the same problem. I just want to link the related issue in the @nxext/stencil repo: https://github.com/nxext/nx-extensions/issues/771

m4s7 avatar Aug 05 '22 04:08 m4s7

Steps to reproduce:

yarn create nx-workspace
  • Name: test-stencil
  • Type: app
  • nx-cloud: no
yarn add --dev @nxext/stencil
yarn nx generate @nxext/stencil:application sample --no-interactive
yarn nx run sample:build

-> Working build

yarn add --dev @stencil/[email protected]
yarn nx run sample:build

-> Failing Build

Repo: https://github.com/m4s7/failing-sample

m4s7 avatar Aug 05 '22 08:08 m4s7

only way to fix as of now is to pin stencil/core at 2.17.1 , as 2.17.2 onwards it starts giving this error

pranav-js avatar Aug 05 '22 10:08 pranav-js

Thanks all, y'all are awesome! I've confirmed this is a bug, and relates to how the NX plugin calls Stencil's APIs. I've ID'ed the commit in the Stencil repo that causes this, and am going to have someone take a look at this early next week

rwaskiewicz avatar Aug 05 '22 14:08 rwaskiewicz

The PR that fixes this issue (#3518) is a part of today's v2.17.4 release. As a result, I'm going to close this issue. Should the issue reoccur on v2.17.4+ of Stencil, please open a new ticket, thanks!

rwaskiewicz avatar Aug 22 '22 16:08 rwaskiewicz