Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bundle typescript with export default foo for both esm and cjs targets. #8658

Open
romainmenke opened this issue Nov 24, 2022 · 3 comments
Open

Comments

@romainmenke
Copy link

🙋 feature request

A a library author I want to write TypeScript as :

const foo = 1;

export default foo;

I also want my users to be able to do this :

// app.cjs
const foo = require('some-package');

console.log(foo) // 1;
// app.mjs
import foo from 'some-package';

console.log(foo) // 1;

🤔 Expected Behavior

// app.cjs
const foo = require('some-package');

console.log(foo) // 1;

prints 1

😯 Current Behavior

// app.cjs
const foo = require('some-package');

console.log(foo) // 1;

prints { default: [Getter] }

💁 Possible Solution

N/A

🔦 Context

I want to adopt Parcel for everything authored under https://github.com/csstools/postcss-plugins
But I don't want this to be a breaking change for users.

I tried searching the issues and docs, maybe I am not using the right keywords, but I did not find a way forward.

@mischnic
Copy link
Member

mischnic commented Nov 25, 2022

This isn't possible by default, but a resolver plugin can achieve this: https://github.com/mischnic/parcel-resolver-dual-default

@mischnic mischnic added 💬 RFC Request For Comments 🙋‍♀️ Feature and removed 💬 RFC Request For Comments labels Nov 25, 2022
@romainmenke
Copy link
Author

romainmenke commented Nov 25, 2022

Thank you for this working example @mischnic 🎉
This is extremely helpful 🙇

It's already pretty late here but I will try to get this setup in the next few days and get back to you!

@romainmenke
Copy link
Author

@mischnic I tested this and it works perfectly in isolation.

Unfortunately I encountered the same issue as : #8419

Ironically I was hoping to adopt Parcel because of issues between Rollup and TypeScript.


I think this issue can be closed?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants