Comments (16)
Sounds like a bug, will investigate!
from bunchee.
Thanks for having a look!
Adding index.development.js as source file works for you?
Unfortunately not, it seems.
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"development": "./dist/index.development.mjs",
"production": "./dist/index.production.mjs",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"production": "./dist/index.production.js",
"development": "./dist/index.development.js",
"default": "./dist/index.js"
},
"default": "./dist/index.js"
}
},
src
src/index.development.tsx
src/index.production.tsx
src/index.tsx
Output:
Exports File Size
. dist/index.js 10.5 kB
dist/index.mjs 9.97 kB
dist/index.d.ts 23.4 kB
dist/index.d.mts 23.4 kB
✓ bunchee 4.4.0 build completed
Here's a minimal reproduction if that helps: https://github.com/amannn/bunchee-test
from bunchee.
Ah true, that main
entry was outdated. I've fixed it in e961321.
The output still has .d.undefined
entries though.
Did you see the output for dist/core.d.ts
? Seems like some runtime code accidentally makes it into the declaration file there.
from bunchee.
That sounds like a bug, will investigate 🙏 appreciate the feedback
from bunchee.
Based on my first tests I think this works now, thanks a bunch!! I'll continue my investigation of switching to bunchee by trying out the new shared modules from #480.
from bunchee.
Thank you @amannn ! Make sure you're using the latest beta, I patched some follow up fixes for it
from bunchee.
Seems not a quick fix, would you try if Adding index.development.js
as source file works for you? Just re-exports everything from index.js
from bunchee.
@amannn Landed a fix in 4.4.2, would you like to give it another shot? 🙏
from bunchee.
Thanks! I can confirm the snippet from above works now, yes! 🎉
However, I noticed that once I introduce sub-exports apart from .
, only the last entry gets a dev and prod build:
"exports": {
".": {
"import": {
"types": "./dist/index.d.mts",
"development": "./dist/index.development.mjs",
"production": "./dist/index.production.mjs",
"default": "./dist/index.mjs"
},
"require": {
"types": "./dist/index.d.ts",
"production": "./dist/index.production.js",
"development": "./dist/index.development.js",
"default": "./dist/index.js"
},
"default": "./dist/index.js"
},
"./core": {
"import": {
"types": "./dist/core.d.mts",
"development": "./dist/core.development.mjs",
"production": "./dist/core.production.mjs",
"default": "./dist/core.mjs"
},
"require": {
"types": "./dist/core.d.ts",
"production": "./dist/core.production.js",
"development": "./dist/core.development.js",
"default": "./dist/core.js"
},
"default": "./dist/core.js"
},
"./react": {
"import": {
"types": "./dist/react.d.mts",
"development": "./dist/react.development.mjs",
"production": "./dist/react.production.mjs",
"default": "./dist/react.mjs"
},
"require": {
"types": "./dist/react.d.ts",
"production": "./dist/react.production.js",
"development": "./dist/react.development.js",
"default": "./dist/react.js"
},
"default": "./dist/react.js"
}
},
Output:
> bunchee
Exports File Size
./ (production) dist/react.development.mjs 203 B
dist/react.production.js 681 B
dist/react.development.js 739 B
dist/index.js 783 B
dist/index.mjs 247 B
dist/react.production.mjs 145 B
dist/index.d.mts 123 B
dist/index.d.ts 123 B
dist/react.development.d.ts 123 B
dist/react.production.d.mts 123 B
dist/react.development.d.mts 123 B
dist/react.production.d.ts 123 B
./core dist/core.js 107 B
dist/core.mjs 39 B
dist/core.d.ts 47 B
dist/core.d.mts 47 B
./react dist/react.mjs 42 B
dist/react.js 111 B
dist/react.d.ts 50 B
dist/react.d.mts 50 B
✓ bunchee 4.4.3 build completed
See my updated repro.
I also noticed that somehow the react
sub-export gets the code for .
(react.development.mjs
).
Am I missing something?
from bunchee.
Looks like need to rewrite a lot of exports parsing, only the last export with dev/prod condition one has been found
from bunchee.
Almost rewrite whole exports parsing in PR #465 with the test covered, gonna release in the next major version 🙏
from bunchee.
@huozhi I've updated my example with [email protected]
, here's the new build output:
Exports File Size
./core dist/core.d.undefined 51 B
dist/core.mjs 158 B
dist/core.production.mjs 57 B
dist/core.development.mjs 114 B
dist/core.js 226 B
dist/core.development.js 182 B
dist/core.production.js 125 B
dist/core.development.d.mts 51 B
dist/core.production.d.mts 51 B
dist/core.d.ts 51 B
dist/core.d.mts 51 B
dist/core.development.d.ts 51 B
dist/core.production.d.ts 51 B
dist/core.d.mts 226 B
dist/core.d.ts 226 B
. dist/index.d.undefined 109 B
dist/index.production.mjs 132 B
dist/index.development.mjs 190 B
dist/index.mjs 234 B
dist/index.js 770 B
dist/index.development.js 726 B
dist/index.production.js 668 B
index.js 770 B
index.d.ts 119 B
dist/index.development.d.mts 109 B
dist/index.d.mts 109 B
dist/index.production.d.mts 109 B
dist/index.development.d.ts 119 B
dist/index.production.d.ts 119 B
dist/index.d.ts 119 B
dist/index.d.mts 770 B
dist/index.d.ts 770 B
./react dist/react.d.undefined 53 B
dist/react.production.js 129 B
dist/react.mjs 162 B
dist/react.development.mjs 118 B
dist/react.production.mjs 60 B
dist/react.development.js 187 B
dist/react.js 231 B
dist/react.production.d.ts 53 B
dist/react.production.d.mts 53 B
dist/react.development.d.mts 53 B
dist/react.d.mts 53 B
dist/react.d.ts 53 B
dist/react.development.d.ts 53 B
dist/react.d.mts 231 B
dist/react.d.ts 231 B
Looking at the output, these look a bit suspicious:
- There are entries with
.undefined
. - There are two entries for
dist/core.d.ts
anddist/core.d.mts
(same for.
andreact
). These artifacts seem to not be type definitions but contain runtime code (dist/core.d.ts
,dist/core.d.mts
)
Are these bugs?
from bunchee.
- Is that
main: "index.js"
coming frombunchee --prepare
? I think the.undefined
is caused by that. - The
.d.mts
is for.mjs
extension. I should remove them after the exports parser refactor, ideally they will be gone in v5 stable. Will keep check
from bunchee.
Looks like fixed by #475
Exports File Size
. dist/index.mjs 234 B
dist/index.production.js 668 B
dist/index.development.mjs 190 B
dist/index.development.js 726 B
dist/index.production.mjs 132 B
dist/index.js 770 B
dist/index.d.ts 109 B
dist/index.d.mts 109 B
./core dist/core.development.mjs 114 B
dist/core.development.js 182 B
dist/core.production.mjs 57 B
dist/core.production.js 125 B
dist/core.mjs 158 B
dist/core.js 226 B
dist/core.d.mts 51 B
dist/core.d.ts 51 B
./react dist/react.development.mjs 118 B
dist/react.mjs 162 B
dist/react.production.mjs 60 B
dist/react.development.js 187 B
dist/react.production.js 129 B
dist/react.js 231 B
dist/react.d.ts 53 B
dist/react.d.mts 53 B
from bunchee.
That's great, thanks @huozhi! Let me know when there's a new beta version and I'll give it a go! 🙂
from bunchee.
5.0.0-beta.2 is out on npm with the above changes 🙏
from bunchee.
Related Issues (20)
- How can I build umd output? HOT 2
- Tree shaking / code splitting HOT 1
- Memory issue
- Hide non entry chunks in output
- [Feature Request] Bundle Analyzer
- Generate types for shared modules
- Handling nested exports
- After update to v5, not working correctly HOT 4
- Generate the js with relative imports
- Loading indicator in terminal during building HOT 4
- Missing type generation
- [question] Should `prepare` use mjs entry for `main` field? HOT 1
- [Feature Request] Conditional configuration for CLI HOT 3
- `--dts` does not generate `.d.ts` for JavaScript files HOT 6
- Custom jsx factory
- bunchee do not read `.swcrc` config HOT 1
- lint on module field
- 'use client' directive should be at the top of the file when combine with `css` import HOT 1
- Support for Bun could easily be added HOT 1
- Build crashing with OOM HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from bunchee.