What version of astro are you using?
1.0.0-beta.17
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
npm
What operating system are you using?
Mac
Describe the Bug
During astro build, third-party ecosystem modules that present as CJS modules under npm,
but typically have rollup build "module": "dist/builder-react.es5.js", type pseudo-ES6 module presentation that
works under vite, webpack, nextJS, etc. will fail. This section in esbuild docs does a good job explaining the history
I have put together a minimal reproduction repo linked below.
This project will work when run with npm start.
However, when trying to build with npm run build, it throws an error based on the import in
file /src/components/CMS.jsx:
error Named export 'Builder' not found. The requested module '@builder.io/react' is a CommonJS module, which may not support all module.exports as named exports.
CommonJS modules can always be imported via the default export, for example using:
import pkg from '@builder.io/react';
const { Builder, BuilderComponent, builder } = pkg;
If this recommendation is implemented, the code now fails under vite SSR because the imports are undefined.
This used to work in astro, but the change showed up in one of the 0.2x build prior to 1.0.0-beta. IMO, this error needs to be disabled or be configurable to allow these types of modules to be imported.
I'm happy to help with a PR, but would need some direction on 1) what the desired solution is, and 2) where to go in the code
Link to Minimal Reproducible Example
https://github.com/alchemycodelab/astro-module-issue
Participation
What version of
astroare you using?1.0.0-beta.17
Are you using an SSR adapter? If so, which one?
None
What package manager are you using?
npm
What operating system are you using?
Mac
Describe the Bug
During astro build, third-party ecosystem modules that present as CJS modules under npm,
but typically have rollup build
"module": "dist/builder-react.es5.js",type pseudo-ES6 module presentation thatworks under vite, webpack, nextJS, etc. will fail. This section in esbuild docs does a good job explaining the history
I have put together a minimal reproduction repo linked below.
This project will work when run with
npm start.However, when trying to build with
npm run build, it throws an error based on the import infile
/src/components/CMS.jsx:If this recommendation is implemented, the code now fails under vite SSR because the imports are
undefined.This used to work in astro, but the change showed up in one of the
0.2xbuild prior to1.0.0-beta. IMO, this error needs to be disabled or be configurable to allow these types of modules to be imported.I'm happy to help with a PR, but would need some direction on 1) what the desired solution is, and 2) where to go in the code
Link to Minimal Reproducible Example
https://github.com/alchemycodelab/astro-module-issue
Participation