antfu / antfu/export-size

Error when using this with React

Open
#4 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
197
Forks
8
PR merge metrics
No merged PRs in 30d

Description

Describe the bug

When bundler is rollup, there is some error when trying to execute export packages

I think this issue might be fixed if @rollup/plugin-commonjs is used


npx export-size . --bundler "rollup"
████████████████████████████████████████ 0/0 Error: 'jsx' is not exported by node_modules/react/jsx-runtime.js, imported by dist/coms
    at error (/Users/malolan/.npm/_npx/614a55f223c4d059/node_modules/rollup/dist/shared/rollup.js:198:30)
    at Module.error (/Users/malolan/.npm/_npx/614a55f223c4d059/node_modules/rollup/dist/shared/rollup.js:12543:16)
    at Module.traceVariable (/Users/malolan/.npm/_npx/614a55f223c4d059/node_modules/rollup/dist/shared/rollup.js:12902:29)
    at ModuleScope.findVariable (/Users/malolan/.npm/_npx/614a55f223c4d059/node_modules/rollup/dist/shared/rollup.js:11554:39)
    at FunctionScope.findVariable (/Users/malolan/.npm/_npx/614a55f223c4d059/node_modules/rollup/dist/shared/rollup.js:6486:38)
    at ChildScope.findVariable (/Users/malolan/.npm/_npx/614a55f223c4d059/node_modules/rollup/dist/shared/rollup.js:6486:38)
    at Identifier.bind (/Users/malolan/.npm/_npx/614a55f223c4d059/node_modules/rollup/dist/shared/rollup.js:7553:40)
    at CallExpression.bind (/Users/malolan/.npm/_npx/614a55f223c4d059/node_modules/rollup/dist/shared/rollup.js:5383:23)
    at CallExpression.bind (/Users/malolan/.npm/_npx/614a55f223c4d059/node_modules/rollup/dist/shared/rollup.js:9049:15)
    at ReturnStatement.bind (/Users/malolan/.npm/_npx/614a55f223c4d059/node_modules/rollup/dist/shared/rollup.js:5383:23) {
  code: 'MISSING_EXPORT',
  url: 'https://rollupjs.org/guide/en/#error-name-is-not-exported-by-module',
  id: '/Users/malolan/Growfin/pkgexp/cashapps/dist/components/Alert/index.js',
  pos: 9,
  loc: {
    column: 9,
    file: '/Users/malolan/Growfin/pkgexp/cashapps/dist/components/Alert/index.js',
    line: 1
  },
  frame: "1: import { jsx } from 'react/jsx-runtime';\n" +
    '            ^\n' +
    "2: import { Alert } from 'antd';",
  watchFiles: [
    'export-size-virtual',
    '/Users/malolan/Growfin/pkgexp/cashapps/dist/index.js',
    '/Users/malolan/Growfin/pkgexp/cashapps/dist/components/Heyo.js',
    '/Users/malolan/Growfin/pkgexp/cashapps/dist/components/Hello/index.js',
    '/Users/malolan/Growfin/pkgexp/cashapps/dist/components/World/index.js',
    '/Users/malolan/Growfin/pkgexp/cashapps/dist/components/Counter/index.js',
    '/Users/malolan/Growfin/pkgexp/cashapps/dist/components/CurrentUserBio/index.js',
    '/Users/malolan/Growfin/pkgexp/cashapps/dist/components/CashAppsQueryClient/index.js',
    '/Users/malolan/Growfin/pkgexp/cashapps/dist/pages/Payments/index.js',
    '/Users/malolan/Growfin/pkgexp/cashapps/dist/utils/fetcher.js',
    '/Users/malolan/Growfin/pkgexp/cashapps/dist/utils/query-client.js',
    '/Users/malolan/Growfin/pkgexp/cashapps/dist/components/Alert/index.js',
    '/Users/malolan/Growfin/pkgexp/cashapps/node_modules/react/jsx-runtime.js'
  ]
Reproduction

https://github.com/ma101an/cashapps

System Info
System:
    OS: macOS 12.5
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 36.62 MB / 16.00 GB
    Shell: 5.8.1 - /bin/zsh
  Binaries:
    Node: 16.15.1 - ~/Library/Caches/fnm_multishells/73842_1659985333292/bin/node
    Yarn: 1.22.15 - ~/Library/Caches/fnm_multishells/73842_1659985333292/bin/yarn
    npm: 8.12.1 - ~/Library/Caches/fnm_multishells/73842_1659985333292/bin/npm
    Watchman: 2022.03.21.00 - /usr/local/bin/watchman
  Browsers:
    Brave Browser: 103.1.41.100
    Firefox Developer Edition: 104.0
    Safari: 15.6
Used Package Manager

npm

Validations
  • Follow our Code of Conduct
  • Read the Contributing Guide.
  • Check that there isn't already an issue that reports the same bug to avoid creating a duplicate.
  • Check that this is a concrete bug. For Q&A, please open a GitHub Discussion instead.
  • The provided reproduction is a minimal reproducible of the bug.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reproducing the failure with npx export-size . --bundler "rollup" against the linked cashapps example, focusing on dist/components/Alert/index.js and its react/jsx-runtime import. The issue is done when Rollup processes this React export without the reported MISSING_EXPORT error.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, rollup, typescript
Domain
build-system, cli
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.