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.

Stencil: Build fails, (0 , workspace_1.readJsonFile) is not a function

See original GitHub issue

Describe the bug I can not build a Stencil library immediately after creating it. It fails with the following error:

> nx run web-components:build --verbose
(0 , workspace_1.readJsonFile) is not a function
TypeError: (0 , workspace_1.readJsonFile) is not a function
    at copyOrCreatePackageJson (C:\Users\eglove\Projects\ethan-gone\node_modules\.pnpm\@nxext+stencil@13.1.0_c85b6e2e4017c9570146ef9fc4663e52\node_modules\@nxext\stencil\src\executors\stencil-runtime\prepare-config-and-outputarget-paths.js:27:58)
    at prepareDistDirAndPkgJson (C:\Users\eglove\Projects\ethan-gone\node_modules\.pnpm\@nxext+stencil@13.1.0_c85b6e2e4017c9570146ef9fc4663e52\node_modules\@nxext\stencil\src\executors\stencil-runtime\prepare-config-and-outputarget-paths.js:63:5)
    at C:\Users\eglove\Projects\ethan-gone\node_modules\.pnpm\@nxext+stencil@13.1.0_c85b6e2e4017c9570146ef9fc4663e52\node_modules\@nxext\stencil\src\executors\stencil-runtime\prepare-config-and-outputarget-paths.js:67:9
    at Generator.next (<anonymous>)
    at C:\Users\eglove\Projects\ethan-gone\node_modules\.pnpm\tslib@2.3.1\node_modules\tslib\tslib.js:117:75
    at new Promise (<anonymous>)
    at __awaiter (C:\Users\eglove\Projects\ethan-gone\node_modules\.pnpm\tslib@2.3.1\node_modules\tslib\tslib.js:113:16)
    at prepareConfigAndOutputargetPaths (C:\Users\eglove\Projects\ethan-gone\node_modules\.pnpm\@nxext+stencil@13.1.0_c85b6e2e4017c9570146ef9fc4663e52\node_modules\@nxext\stencil\src\executors\stencil-runtime\prepare-config-and-outputarget-paths.js:66:34)
    at C:\Users\eglove\Projects\ethan-gone\node_modules\.pnpm\@nxext+stencil@13.1.0_c85b6e2e4017c9570146ef9fc4663e52\node_modules\@nxext\stencil\src\executors\build\executor.js:37:92
    at Generator.next (<anonymous>)

β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”β€”

>  NX   ERROR  Running target "web-components:build" failed

  Failed tasks:

  - web-components:build

To Reproduce

nx g @nxext/stencil:library web-components

nx g @nxext/stencil:make-lib-buildable --importPath='@companyName/web-components' web-components

Expected behavior

Build files are generated in dist/packages/web-components of Nx repo.

Additional context

@nrwl versions: 13.4.1 @nxext/stencil: 13.1.0 @stencil/core: 2.12.0

This is on a fresh build, no changes to default configs.

Issue Analytics

  • State:closed
  • Created 2 years ago
  • Reactions:1
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
eglovecommented, Dec 25, 2021

@DominikPieper I moved @nrwl/workspace back to 13.3.12 to get past this issue. However, there still seems to be a misconfiguration between Rollup and TypeScript when running the build on the dev server.

Rollup: Parse Error
Unexpected character '@' (Note that you need plugins to import files that are not JavaScript)
@Component({
  shadow: true,

I tried using @rollup/plugin-typescript and adding this to stencil.config.ts

rollupPlugins: {
  before: [typescript()],
},

No luck. Is there another workaround for this?

EDIT: Removing the extension of the NX base tsconfig worked. I’m not sure what the cause here is. But here is a diff for reference.

https://imgur.com/a/J2gCUej

0reactions
pranav-jscommented, Dec 26, 2021

@DominikPieper no worries. for now downgraded workspace package only. enjoy ur xmas holidays πŸ˜ƒ

Read more comments on GitHub >

github_iconTop Results From Across the Web

Error when building Stencil app that uses Stencil lib ... - GitHub
I have done a little debugging inside the index.js of the compiler. I think what is being returned from prerender.stenciljs.com (?) is faulty:....
Read more >
Stencil: Sudden build error without message after adding ...
The exact problem here is, that the stencil-compiler seems to assume that the elements parameter is of type Element that is imported fromΒ ......
Read more >
Vue - Stencil.js
Stencil can generate Vue component wrappers for your web components. This allows your Stencil components to be used within a Vue 3 application....
Read more >
The Basics of Unit Testing in StencilJS - Elite Ionic
In this tutorial, we investigate how to use Jest to create unit tests for our StencilJS components.
Read more >
Creating Web Components with Stencil - Auth0
A practical tutorial showing how to create Web Components using Stencil.
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