nx-extensions icon indicating copy to clipboard operation
nx-extensions copied to clipboard

devServer.root undefined when serving stencil library

Open Jefftopia opened this issue 3 years ago • 5 comments

Describe the bug

nx build "components" "--verbose" After setting up a new nx workspace and running the following command to add a stencil project:

npx nx g @nxext/stencil:lib components --style=’scss’ --buildable=true --publishable=true --importPath='components'

I receive the following error when running npx nx serve components:

nx run components:build --verbose Cannot read property 'replace' of undefined TypeError: Cannot read property 'replace' of undefined at /Users/foobar/dev/design-system.npm/node_modules/@nxext/stencil/src/executors/stencil-runtime/prepare-config-and-outputarget-paths.js:92:117 at Generator.next () at /Users/foobar/dev/design-system.npm/node_modules/tslib/tslib.js:117:75 at new Promise () at __awaiter (/Users/foobar/dev/design-system.npm/node_modules/tslib/tslib.js:113:16) at prepareConfigAndOutputargetPaths (/Users/foobar/dev/design-system.npm/node_modules/@nxext/stencil/src/executors/stencil-runtime/prepare-config-and-outputarget-paths.js:66:34) at /Users/foobar/dev/design-system.npm/node_modules/@nxext/stencil/src/executors/build/executor.js:37:92 at Generator.next () at fulfilled (/Users/foobar/dev/design-system.npm/node_modules/tslib/tslib.js:114:62)

This is with the latest version, 12.2.0. and node 14.17.

Adding the following to the StencilJs config:

  devServer: {
    root: '/'
  },

resolved the undefined error, but after that the serve/build commands still silently fail with an nondescript error.

Edit:

Other issues encountered: providing a logger to resolve an error from a missing logger. The build also fails on a missing 'flags' property ("Cannot read property 'flags' of null")

An updated working example/demo of an nx stencil monorepo would be helpful. The existing demo appears to use nx v1 rather than v2.

Jefftopia avatar Oct 14 '21 17:10 Jefftopia

Hi @Jefftopia, do you use Windows or macOS? I did a short try but wasn't able to reproduce. The serve command works as expected on my Mac

DominikPieper avatar Oct 15 '21 07:10 DominikPieper

I'm on a mac as well. I had three others reproduce. On the one hand, I can provide a full working example in a day or so. On the other hand, if the demo app was updated, that likely would help a great deal as well too.

Jefftopia avatar Oct 15 '21 12:10 Jefftopia

The demo app is on my list, but not sure I'll find time for that soon. ^^'

DominikPieper avatar Oct 15 '21 12:10 DominikPieper

I'm having the same issues and I'm not sure why since it's been about 2 months since I've tried this plugin and it worked. Let me know what I can do about it. This is the report:


   Node : 16.13.0
   OS   : darwin x64
   yarn : 1.22.17
   
   nx : 13.10.3
   @nrwl/angular : 13.10.3
   @nrwl/cypress : 13.10.3
   @nrwl/detox : Not Found
   @nrwl/devkit : 13.10.3
   @nrwl/eslint-plugin-nx : 13.10.3
   @nrwl/express : Not Found
   @nrwl/jest : 13.10.3
   @nrwl/js : 13.10.3
   @nrwl/linter : 13.10.3
   @nrwl/nest : Not Found
   @nrwl/next : Not Found
   @nrwl/node : Not Found
   @nrwl/nx-cloud : 13.3.1
   @nrwl/nx-plugin : Not Found
   @nrwl/react : 13.10.3
   @nrwl/react-native : Not Found
   @nrwl/schematics : Not Found
   @nrwl/storybook : 13.10.3
   @nrwl/web : 13.10.3
   @nrwl/workspace : 13.10.3
   typescript : 4.6.3
   rxjs : 7.4.0
   ---------------------------------------
   Community plugins:
         @ns3/nx-jest-playwright: 2.3.0
         @nxext/stencil: 13.2.3

After I set up the devServer.root property to /, I get the following error, which is kinda weird since I am already passing the verbose flag:

$ nx run ui:serve --verbose

> nx run ui:serve --verbose

Cannot read properties of undefined (reading 'error')

 ————————————————————————————————————————————————————————————————————————————————————————————————————————————————

 >  NX   Running target "ui:serve" failed

   Failed tasks:
   
   - ui:serve
   
   Hint: run the command with --verbose for more details.

rgolea avatar Apr 21 '22 06:04 rgolea

So it seems that if you call your library ui, the entire stencil library doesn't work. Could we validate the name of the project and maybe not allow it?

rgolea avatar Apr 25 '22 12:04 rgolea