-
-
Notifications
You must be signed in to change notification settings - Fork 6.1k
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
fix(dev): transform import for commonjs dependencies #837
Conversation
onjs dependencies
Does this feature deprecate |
|
This comment has been minimized.
This comment has been minimized.
This is exactly what my previous PR was doing. |
Yes you are right, this is definitely a better approach |
@csr632 Can you have a try with rollup/plugins#604 instead of |
@underfin I would like to migrate the optimizer to Also, the use of Edit: forget about it, i will just use |
@knightly-bot build this |
Thanks for this |
mark |
The upstream rollup plugins have been released. Now this PR is ready to be merged! @yyx990803 |
@underfin @yyx990803 @antfu |
Any solution for reexporting commonjs module? // a.ts
export * from 'moduleTranspiledToCommonjs' // b.ts
import { foo } from './a' will produce warning:
|
I have the same error as @zheeeng. Any updates on this? |
It may become too complicated if we support re-exporting cjs. What is the expected behavior of this and how to implement it? 🤔 // a.ts
export * from 'moduleTranspiledToCommonjs1' // may contain `module.exports.foo = 'value1'`
export * from 'moduleTranspiledToCommonjs2' // may contain `module.exports.foo = 'value2'`
export * from 'someESModule' // may contain `export const foo = 'value3'`. It may also contain cjs re-export // b.ts
import { foo } from './a'
console.log(foo); |
...so that user can do named import from them.
This is a different approach from pull/825 to fix #720
In the optimze step, it collect information about optimized deps (whether it is cjs).
When rewriting import during
vite serve
, if the importee is a "optimized cjs deps", it will get named import from the default export.For example,
will become
It is better than #825 because it doesn't require users to manually specific export names.