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.

[build-storybook]: react publishable library TypeError: (0 , jsx_dev_runtime.jsxDEV) is not a function

See original GitHub issue

Current Behavior

Building for a react publishable lib using build-storybook, although it completes successfully, throws a runtime error when opening index.html from the generated output of the build.

This looks related to the new jsx transform: image

Note that if I change the .babelrc to use the classic transform and if I add import React from 'react' to my lib it works fine.

Expected Behavior

It should work out of the box with the new jsx transform (nx is configured to do so by default).

Steps to Reproduce

Either go to https://github.com/rodrigofariow/myorg for the generated output from the instructions bellow or run them directly:

  1. npx create-nx-workspace@latest --preset=react --packageManager=yarn --style=styled-components --name=myorg --appName=myapp
  2. yarn nx g @nrwl/react:library --importPath=@shared-lib --name=shared-lib --publishable
  3. yarn add -D @nrwl/storybook
  4. yarn nx g @nrwl/react:storybook-configuration shared-lib
  5. yarn nx run shared-lib:build-storybook
  6. Open index.html file from the output

image 7. image

Environment

>  NX  Report complete - copy this into the issue template

  Node : 16.13.1
  OS   : darwin x64
  yarn : 1.22.17
  
  nx : 13.4.3
  @nrwl/angular : undefined
  @nrwl/cli : 13.4.3
  @nrwl/cypress : 13.4.3
  @nrwl/devkit : 13.4.3
  @nrwl/eslint-plugin-nx : 13.4.3
  @nrwl/express : undefined
  @nrwl/jest : 13.4.3
  @nrwl/linter : 13.4.3
  @nrwl/nest : undefined
  @nrwl/next : undefined
  @nrwl/node : undefined
  @nrwl/nx-cloud : undefined
  @nrwl/react : 13.4.3
  @nrwl/react-native : undefined
  @nrwl/schematics : undefined
  @nrwl/tao : 13.4.3
  @nrwl/web : 13.4.3
  @nrwl/workspace : 13.4.3
  @nrwl/storybook : 13.4.3
  @nrwl/gatsby : undefined
  typescript : 4.4.4
  rxjs : 6.6.7
  ---------------------------------------
  Community plugins:

(node:28514) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at /Users/rodrigofaria/Documents/myorg/node_modules/tslib/package.json.
Update this package.json to use a subpath pattern like "./*".
(Use `node --trace-deprecation ...` to show where the warning was created)

Thanks in advance for your time!

Issue Analytics

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

github_iconTop GitHub Comments

13reactions
puku0xcommented, Jan 6, 2022

@rodrigofariow Does it work when NODE_ENV is set to production ?

NODE_ENV=production yarn nx run shared-lib:build-storybook 

You may add --skip-nx-cache option to ignore local cache.

8reactions
rodrigofariowcommented, Jan 6, 2022

Hye @puku0x

Yep, that works! 😄 In a way, I expected that shared-lib:build-storybook to assume production as the environment though. 🤔

I also expect more people to have the same issue as me as it wasn’t obvious what was the exact cause. Thinking about it, the jsxDEV part does indicate that the output is expecting the development version of “jsx runtime” to be there and it isn’t. But still.

Can’t nx do something about it?

Thank you very much the help and fast response! 😃

Cheers

Read more comments on GitHub >

github_iconTop Results From Across the Web

javascript - Stack Overflow
Server Error TypeError: (0 , react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV) is not a function This error happened while ...
Read more >
storybookjs/storybook (Raised $170.00) - Issuehunt
Create React App CRA - Error: You attempted to import [path/to/app]/node_modules/react/jsx-dev-runtime which falls outside of the project src/ directory.
Read more >
[Solved]-Error when running next js - TypeError - appsloveworld
[Solved]-Error when running next js - TypeError: (0 , react_jsx_dev_runtime__WEBPACK_IMPORTED_MODULE_0__.jsxDEV) is not a function-Reactjs. Search.
Read more >
Frequently Asked Questions - Storybook - JS.ORG
How can I opt-out of Angular ngcc? How can I run coverage tests with Create React App and leave out stories? ... How...
Read more >
Create React component libraries with Storybook and styled-jsx.
If you are creating a visual component library or a state ... Oh yes, awesome-components@0.1.0 (at this point of time) is published on...
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