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

Bug Report - Issue with exporting boolean values in vite-plugin-commonjs #53

Open
chengwen-zheng opened this issue Feb 4, 2024 · 1 comment

Comments

@chengwen-zheng
Copy link

chengwen-zheng commented Feb 4, 2024

Versions

  • originjs: "@originjs/vite-plugin-commonjs": "^1.0.3",
  • node: v18.15.0

Reproduction

Additional Details

in a.js

  var a = false;
  export default a; 

in index.js

  var hasA = require("./a.js");

  const a = hasA || "A";
  
  console.log(a);
  
  module.exports = a;

a compressed value
image

Steps to reproduce

What is Expected?

a compressed value :A

What is actually happening?

code = code.replace(item[0], `(${packageName}.default || ${packageName})`);

If the line use ||, it will directly export a boolean value itself, such as false, which will cause the subsequent case to be used.

@chengwen-zheng
Copy link
Author

这个问题可以帮忙回复下吗?

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

No branches or pull requests

1 participant