vite-plugins icon indicating copy to clipboard operation
vite-plugins copied to clipboard

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

Open chengwen-zheng opened this issue 1 year ago • 1 comments

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?

https://github.com/originjs/vite-plugins/blob/568f5b79ba14723c13e5476efeb4cbf28494acd0/packages/vite-plugin-commonjs/src/lib.ts#L37 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 avatar Feb 04 '24 03:02 chengwen-zheng

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

chengwen-zheng avatar Feb 11 '24 13:02 chengwen-zheng