thepassle / barrel-begone

50 stars 1 forks source link

React exports causing error #9

Closed Akkuma closed 2 months ago

Akkuma commented 2 months ago

React has the following:

'use strict';

if (process.env.NODE_ENV === 'production') {
  module.exports = require('./cjs/react.production.min.js');
} else {
  module.exports = require('./cjs/react.development.js');
}

This is producing:

Error [RollupError]: dist/index-CT_QfAs_.js (1:9): "useCallback" is not exported by "../../node_modules/.pnpm/react@18.2.0/node_modules/react/index.js", imported by "dist/index-CT_QfAs_.js".
    at getRollupError (file:///Users/omni/Library/pnpm/store/v3/tmp/dlx-68174/node_modules/.pnpm/rollup@4.14.3/node_modules/rollup/dist/es/shared/parseAst.js:392:41)
    at error (file:///Users/omni/Library/pnpm/store/v3/tmp/dlx-68174/node_modules/.pnpm/rollup@4.14.3/node_modules/rollup/dist/es/shared/parseAst.js:388:42)
    at Module.error (file:///Users/omni/Library/pnpm/store/v3/tmp/dlx-68174/node_modules/.pnpm/rollup@4.14.3/node_modules/rollup/dist/es/shared/node-entry.js:13688:16)
    at Module.traceVariable (file:///Users/omni/Library/pnpm/store/v3/tmp/dlx-68174/node_modules/.pnpm/rollup@4.14.3/node_modules/rollup/dist/es/shared/node-entry.js:14136:29)
    at ModuleScope.findVariable (file:///Users/omni/Library/pnpm/store/v3/tmp/dlx-68174/node_modules/.pnpm/rollup@4.14.3/node_modules/rollup/dist/es/shared/node-entry.js:11817:39)
    at FunctionScope.findVariable (file:///Users/omni/Library/pnpm/store/v3/tmp/dlx-68174/node_modules/.pnpm/rollup@4.14.3/node_modules/rollup/dist/es/shared/node-entry.js:6037:38)
    at FunctionBodyScope.findVariable (file:///Users/omni/Library/pnpm/store/v3/tmp/dlx-68174/node_modules/.pnpm/rollup@4.14.3/node_modules/rollup/dist/es/shared/node-entry.js:6037:38)
    at Identifier.bind (file:///Users/omni/Library/pnpm/store/v3/tmp/dlx-68174/node_modules/.pnpm/rollup@4.14.3/node_modules/rollup/dist/es/shared/node-entry.js:7311:40)
    at CallExpression.bind (file:///Users/omni/Library/pnpm/store/v3/tmp/dlx-68174/node_modules/.pnpm/rollup@4.14.3/node_modules/rollup/dist/es/shared/node-entry.js:4753:23)
    at CallExpression.bind (file:///Users/omni/Library/pnpm/store/v3/tmp/dlx-68174/node_modules/.pnpm/rollup@4.14.3/node_modules/rollup/dist/es/shared/node-entry.js:8975:15) {
  binding: 'useCallback',
  code: 'MISSING_EXPORT',
  exporter: '/Users/omni/git/bison-design-system/node_modules/.pnpm/react@18.2.0/node_modules/react/index.js',
  id: '/Users/omni/git/bison-design-system/packages/gigashad/dist/index-CT_QfAs_.js',
  url: 'https://rollupjs.org/troubleshooting/#error-name-is-not-exported-by-module',
  pos: 9,
  loc: {
    column: 9,
    file: '/Users/omni/git/bison-design-system/packages/gigashad/dist/index-CT_QfAs_.js',
    line: 1
  },
  frame: '1: import { useCallback as h, forwardRef as $, Children as s, isValidElement as a, createElement as u, cloneElement as m...\n' +
    '            ^\n' +
    '2: function f() {\n' +
    '3:   return f = Object.assign ? Object.assign.bind() : function(e) {',
thepassle commented 2 months ago

barrel-begone is ESM-first, you probably need a rollup plugin to support commonjs: https://github.com/thepassle/barrel-begone?tab=readme-ov-file#config-file

Akkuma commented 2 months ago

Got it thanks.